Questions about Angles and rotation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IHate

I have a couple of questions about angles and the property rotation in Godot.

-Why is the property rotation of a node2D measured in radians while rect_rotation on a Control node is measured in degrees?.

I know you can transform from radians to degrees but it took me a while to check the documentation for rect_rotation to realise I was using the wrong measurement. So I was wondering if there is a reason. Do degrees work better on Control nodes and that’s why it’s their default?.

-My second question is about angles and this may be more of a math problem more than an engine thing.

When I add degrees to the rotation_degree property of a Node2D the rotation property goes over and under 360 and -360 is there a use for this?

Personally I don’t understand why would you use negative degrees a part from the obvious clockwise rotation from subtracting degrees. But once you hit 0 you can make the rotation 360 and achieve the same result right?.

I’m achieving this by manually resetting the rotation, let me know if there’s a better way of doing this:

if rotation_degrees >= 360 or rotation_degrees <= 0: 
rotation_degrees = fposmod(rotation_degrees,360.0)

So why does the engine not do that automatically is there a reason to save the rotation of an object as 1000 degrees? or -1000 degrees?

:bust_in_silhouette: Reply From: Serafij

There is a lerp_angle() function.

Although this is not 100% what You asked, it could solve it.
Plus, this might is what Someone else is looking for (like Me before)

:bust_in_silhouette: Reply From: Drachenbauer

about the different angle units (degrees and radians):
where radians are needed, you can use deg2rad(your_degrees_angle) and calculate your degrees angle inside it´s brackets
deg2rad(90.0 / 60.0)
can be used to rotate 90° in 60 steps