mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-06-07 07:04:26 +08:00
Fix negative angles
This commit is contained in:
parent
649ecb9c0c
commit
559659b1d2
26
nodes.py
26
nodes.py
@ -2750,12 +2750,24 @@ def camera_embeddings(elevation, azimuth):
|
|||||||
return embeddings
|
return embeddings
|
||||||
|
|
||||||
def interpolate_angle(start, end, fraction):
|
def interpolate_angle(start, end, fraction):
|
||||||
# Calculate the difference in angles and adjust for wraparound if necessary
|
# Normalize angles between -180 and 180
|
||||||
diff = (end - start + 540) % 360 - 180
|
start = ((start + 180) % 360) - 180
|
||||||
# Apply fraction to the difference
|
end = ((end + 180) % 360) - 180
|
||||||
interpolated = start + fraction * diff
|
|
||||||
# Normalize the result to be within the range of -180 to 180
|
# Compute the difference in angles and wrap it properly
|
||||||
return (interpolated + 180) % 360 - 180
|
diff = (end - start + 180) % 360 - 180
|
||||||
|
|
||||||
|
# Use the shortest path
|
||||||
|
if diff > 180:
|
||||||
|
diff -= 360
|
||||||
|
elif diff < -180:
|
||||||
|
diff += 360
|
||||||
|
|
||||||
|
# Interpolate and wrap the result again
|
||||||
|
interpolated = (start + diff * fraction + 360) % 360
|
||||||
|
if interpolated > 180:
|
||||||
|
interpolated -= 360
|
||||||
|
return interpolated
|
||||||
|
|
||||||
class StableZero123_BatchSchedule:
|
class StableZero123_BatchSchedule:
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -2847,7 +2859,7 @@ class StableZero123_BatchSchedule:
|
|||||||
interpolated_azimuth = interpolate_angle(azimuth_points[prev_point][1], azimuth_points[next_point][1], fraction)
|
interpolated_azimuth = interpolate_angle(azimuth_points[prev_point][1], azimuth_points[next_point][1], fraction)
|
||||||
else:
|
else:
|
||||||
interpolated_azimuth = azimuth_points[prev_point][1]
|
interpolated_azimuth = azimuth_points[prev_point][1]
|
||||||
|
print(interpolated_azimuth)
|
||||||
# Interpolate the elevation
|
# Interpolate the elevation
|
||||||
next_elevation_point = 1
|
next_elevation_point = 1
|
||||||
while next_elevation_point < len(elevation_points) and i >= elevation_points[next_elevation_point][0]:
|
while next_elevation_point < len(elevation_points) and i >= elevation_points[next_elevation_point][0]:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user