mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-06-08 21:17:58 +08:00
Update nodes.py
This commit is contained in:
parent
559659b1d2
commit
c233afc27f
26
nodes.py
26
nodes.py
@ -2750,23 +2750,25 @@ def camera_embeddings(elevation, azimuth):
|
|||||||
return embeddings
|
return embeddings
|
||||||
|
|
||||||
def interpolate_angle(start, end, fraction):
|
def interpolate_angle(start, end, fraction):
|
||||||
# Normalize angles between -180 and 180
|
# Normalize start angle to range [0, 360)
|
||||||
start = ((start + 180) % 360) - 180
|
start = start % 360
|
||||||
end = ((end + 180) % 360) - 180
|
|
||||||
|
|
||||||
# Compute the difference in angles and wrap it properly
|
# If end angle is negative, convert it to the equivalent positive angle
|
||||||
diff = (end - start + 180) % 360 - 180
|
if end < 0:
|
||||||
|
end = 360 + end
|
||||||
|
|
||||||
# Use the shortest path
|
# Ensure the end angle is greater than the start angle for clockwise interpolation
|
||||||
if diff > 180:
|
if end <= start:
|
||||||
diff -= 360
|
end += 360
|
||||||
elif diff < -180:
|
|
||||||
diff += 360
|
|
||||||
|
|
||||||
# Interpolate and wrap the result again
|
# Calculate the clockwise distance from start to end
|
||||||
interpolated = (start + diff * fraction + 360) % 360
|
distance = end - start
|
||||||
|
|
||||||
|
# Interpolate the angle using the fraction and wrap it to range [-180, 180)
|
||||||
|
interpolated = (start + distance * fraction) % 360
|
||||||
if interpolated > 180:
|
if interpolated > 180:
|
||||||
interpolated -= 360
|
interpolated -= 360
|
||||||
|
|
||||||
return interpolated
|
return interpolated
|
||||||
|
|
||||||
class StableZero123_BatchSchedule:
|
class StableZero123_BatchSchedule:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user