+2 votes

I've seen a couple tutorials use radians instead of degrees, but I've been trying to figure out how exactly this works out...

I mean, a random equation like PI/6 * velocity.y/jump_impulse doesn't really make sense to a beginner now does it?

So can someone explain how exactly radians work in godot? is it like an invisible circle drawn around the node? And what's with the use of PI? How can I use degrees in the above equation?

tl;dr : Can someone please just explain to me how radians work?

Godot version I'm using version 3.5.1 for windows
in Engine by (20 points)

2 Answers

+2 votes
Best answer

Radians and degrees are two different ways to say the same thing.

If you turn 90 degrees, you turn PI / 2 radians (1.570...).
If you turn 180 degrees, you turn PI radians (3.141...).
If you turn 360 degrees, you turn 2 * PI radians (6.283...).

Math works with radians only. There shouldn't be any reason to use degrees in code.

However most people learn degrees first and think in degrees instead of in radians. Because of that the web is full of code examples where degrees are turned to radians and vice versa and that causes a lot of confusion. What everyone should do instead is to start to think in radians when writing a code. Then there is no need to do conversions and code will be faster and easier to understand. It takes some time to get used to it but it's worth it.

However degrees can be useful in other situations, for example if you need to rotate something in Godot editor, for example 90 degrees, it is easier to write 90 to rotation box instead of writing something like 1.570...

by (95 points)
selected by

So is there like a theoretical circle around the node?

+1 vote

Radians are just another measurement of turning like degrees. 360deg = PI*2 radians. 180deg = PI radians. PI/6 radians = 30deg. There are also functions deg2rad and rad2deg to convert between the two.

by (1,053 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.