Amend quirk behavior of mod operator

This commit is contained in:
Andrea Lanfranchi 2024-02-27 11:31:41 +01:00
parent 923f2cfb4c
commit d0ffc1bfde
No known key found for this signature in database
GPG Key ID: 2D623A60BB279915

View File

@ -164,11 +164,13 @@ def rotate_facial_area(
""" """
# Normalize the witdh of the angle so we don't have to # Normalize the witdh of the angle so we don't have to
# worry about rotations greater than 360 degrees # worry about rotations greater than 360 degrees.
angle = angle % 360 # We workaround the quirky behavior of the modulo operator
# for negative angle values.
direction = (1, -1)[angle < 0]
angle = abs(angle) % 360
if angle == 0: if angle == 0:
return facial_area # No rotation needed return facial_area
direction = 1 if angle > 0 else -1
# Angle in radians # Angle in radians
angle = angle * np.pi / 180 angle = angle * np.pi / 180