- Edited
I googled and didn't find an answer. The vector math tutorial doesn't explain, either. Degrees are more common and don't require you to use pi. What's the rationale?
(Yes I know about deg2rad() and rad2deg().)
I googled and didn't find an answer. The vector math tutorial doesn't explain, either. Degrees are more common and don't require you to use pi. What's the rationale?
(Yes I know about deg2rad() and rad2deg().)
Most all engines (and math or scientific stuff too) uses radians. Degrees are the more commonly known format, but, under the hood, the equations are based on radians, even if the API exposes Euler angles to be easier to use.
If you divide the circumference of a circle by its diameter, the result is Pi (3.1416...), not 180. It takes extra steps to convert to/from degrees.
Using degrees causes problems in 3d math. Problems that cannot be solved easy. But with quaternion, those problems are solved. It works more better.
Actually there's many cases where it's easier to deal with radians than degrees. edit: misread, my bad.
Certainly it's useful to have functions to easily convert between the two.
https://docs.godotengine.org/en/stable/classes/class@gdscript.html#class-gdscript-method-deg2rad https://docs.godotengine.org/en/stable/classes/class@gdscript.html#class-gdscript-method-rad2deg
You may be interested in these changes for Godot 4.0: https://github.com/godotengine/godot/pull/50009
That is a puzzling change for 4.0. Smarter people than me say that radians are more normal and common---fair enough. But why in the world remove a couple utility functions for converting radians/degrees and break existing code that used those functions?
Removing those two functions seems like a strange decision, if that was actually done. But they're trivial functions, and could easily be added to one's own project.
The deg2rad()
and rad2deg()
conversion functions were not removed in 4.0. What was removed were "virtual" properties such as rotation_degrees
. If you need to change rotation in code with values in degrees, set rotation = deg2rad(value_in_degrees)
instead. This prevents having two properties that represent the same value in different ways, which is often confusing. We've had this issue with mass
and weight
in RigidBody too – and that one's been solved in 4.0 :)
I'm so glad I learned about this now. rotation_degrees has been my main function for rotating the y axis. And for also doing some rotations on x, when positioning objects.