lundi 1 juin 2015

atan2 gives wrong with right arguments, while correct with wrong arguments

Lets say I need to draw a line. I have 4 arguments startX, startY, endX, and endY.

Then I use the following to calculate the angle of the line:

float diffX = endX - startX;
float diffY = endY - startY;

float rotation = atan2f(diffX, diffY) * (180/M_PI);

Could someone explain why the above gives a correct answer whereas switching diffX with diffY gives an incorrect answer, since the atan2() function should have arguments in the order of Y and X, not X and Y.

Any ideas? Thank you.

Aucun commentaire:

Enregistrer un commentaire