What is the usage of ToDeg and ToRad?

How are ToDeg and ToRad supposed to be used?

Basically, angle in degrees start from 0, goes to 180, then it jumps to -180 and go all the way up to 0

Angle in Radians, start from 0 to 360 and it loops.

Using ToDeg(270) wont convert it to -90, it converts it to 15469.46… (something near that)

So, I want to know what is the utility of ToDeg and ToRad? What are the occasions where they should be used?

Is there really a event where we can use a number over or equal to 361 as angle?

Are these expressions actually working as intended?

They convert between degrees and radians. Some math functions like sin() and cos() expect the value to be in radians. I don’t know how they work only that they convert between the 2 formats.

This might help. I plan to read it more myself.

https://betterexplained.com/articles/intuitive-guide-to-angles-degrees-and-radians/

2 Likes

I’ve been using some ToRad in a project.
I have my player object and a crosshair a certain distance away. ToRad comes in handy to get the X and Y coordinates to keep the crosshair positioned based on the angle of where the player is facing and the distance that’s been set.

The formula I’m using goes like this:
Player.X() + (cos(ToRad(Player.Angle()))) * ([distance variable]))
Player.Y() + (sin(ToRad(Player.Angle()))) * ([distance variable])

2 Likes

I’m using it in a similar way.

FYI: getXFromAngleAndDistance() and getYFromAngleAndDistance() does the same thing but in my case it’s not as flexible.