You missed an important fact about Math.atan2. It's not just the arctangent of the quotient of the arguments; it uses the signs of the arguments to determine the actual angle in [-π, π], whereas Math.atan's range is (-π/2, π/2). Another benefit is that atan2 can compute a value when x is 0 (using atan you end up dividing by 0).
You missed an important fact about
Math.atan2
. It's not just the arctangent of the quotient of the arguments; it uses the signs of the arguments to determine the actual angle in [-π, π], whereasMath.atan
's range is (-π/2, π/2). Another benefit is that atan2 can compute a value when x is 0 (using atan you end up dividing by 0).Thanks for pointing that out. I should update that.