Math.atan2(x,y), what is this doing and where it can be used?

Greetings! I am interested in atan2(x,y) and experiment with it, but I do not really know where it is used nor what it is used for.
I’ve already tried searching on youtube and google but it is still not too clear for me in a programming language.

It would be greatly appreciated if you would answer. Have a great day everyone!

Great, have you read this?

It has every single math needed for you to understand!
Let me know if you still don’t get it!

2 Likes

Thank you very much! But can I please know where it can be used?

The way I would use it, were to calculate angles as it takes two Variables for you would be x,y Variable.

4 Likes

Okay, thank you so much once again. This will surely help me! Good day and stay safe!

2 Likes

With pleasure, same for you! <3

2 Likes

To add just a bit more:

When you’re converting from cartesian coordinates (x,y) to polar coordinates (r, θ), θ = arctan(y/x) for x > 0. For other coordinates you need to do a little bit more arithmetic.

math.atan2() will give you θ without the need to worry about the Quadrant. If you want to know a bit more about it, just look up atan2 as it is not exclusive to Roblox.

2 Likes

Thank you, this helped me alot too, have a great day and stay safe! :slightly_smiling_face:

4 Likes