DEV Community

JavaScript Math Methods and Constants You don't Know Existed

John Au-Yeung on January 07, 2020

Subscribe to my email list now at http://jauyeung.net/subscribe/ Follow me on Twitter at https://twitter.com/AuMayeung Many more articles at http...
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.

Collapse
 
ca0v profile image
Corey Alix

Can't believe I missed hypot all these years.

Collapse
 
aumayeung profile image
John Au-Yeung

Handy for writing games or graphical programs.

Collapse
 
fareeha profile image
Fareeha

Yes