Trig question

Hello forum,
I had a question. I’m working on a project that involves very heavy math. Especially with trigonometry. The equation I’m using requires arctan but in the options I only see arctan2. Is there a workaround. Is it even going to matter. Please help me.

5 Likes

As long as your angle is between – π/2 and + π/2, then you can get an equivalent value with Math.atan2(). Instead of using Math.atan(x), use Math.atan2(x, 1).

let x: number = 1 // tan(pi / 4) = 1

// All of these should be the same, then: ~ 0.785398
game.splash(Math.PI / 4)
game.splash(Math.atan(x))
game.splash(Math.atan2(x, 1))
5 Likes

Thank you.

2 Likes

Is it possible to set the mode from radians to degrees?
Is it already in degrees?

No, there is no way to switch “modes” for the trig functions. They always work in radians. The easiest way to deal with this is to use a pair of functions that convert between degrees and radians.

2 Likes