DEV Community

Discussion on: JavaScript Math Methods and Constants You don't Know Existed

Collapse
 
craigmc08 profile image
Craig McIlwrath

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).

Collapse
 
aumayeung profile image
John Au-Yeung

Thanks for pointing that out. I should update that.