David Wolever
David Wolever

Reputation: 154454

Why are the parameters to `atan2` “backwards”?

Why is it that the parameters to the atan2 function are “backwards”? Ie, why does it accepts coordinates in the form y, x instead of the standard x, y?

Upvotes: 16

Views: 949

Answers (3)

JoshD
JoshD

Reputation: 12824

The single argument version of arctangent requires the ratio of opposite divided by adjacent sides. This is y/x. It's fairly similar to say atan2(y,x) as it's remenicent of atan(y/x).

Upvotes: 5

Benoit
Benoit

Reputation: 79155

Probably because atan2(y,x) = atan(y/x) ± nπ and here, y and x come in the same order.

Upvotes: 8

Sheldon L. Cooper
Sheldon L. Cooper

Reputation: 3260

Because it's similar to atan(y / x), with y as numerator and x as denominator.

Upvotes: 16

Related Questions