Videos
Math.java it define as
public static double atan2(double y, double x) {
return StrictMath.atan2(y, x); // default impl. delegates to StrictMath
}
and this will return the counter-clock wise angle with respect to X- axis.
If you interchange those two you will get the clock wise angle with respect to X- axis.
In Cartesian coordinate system we consider counter-clock wise angle with respect to X-axis. That is why Math.java use this as above.
Swapping the order of the arguments means that instead of the (counter-clockwise) angle with the X-axis you get the (clockwise) angle with the Y-axis. It's not wrong, just unusual.
I've been calculating rotation needed between two 3d points, and I'm having some slight trouble.
You can use very basic sohcahtoa to find the angle needed between the two points by making a right triangle and just doing arctan of opposite/adjacent (the two sides). Now this only works if all of the values are positive, as, for example, arctan(-5/-4) == arctan(5/4). I do remember learning something about fixing this back when I learned about trig identities in school, and how to fix it, but my friend sent me some code, and he used Math.atan2 instead of tangent.
Now his code works perfectly, and was not too different from mine, and it really made me wonder what Math.atan2 does. I searched up on the internet, and didn't understand a word of the descriptions. Can someone show me what Math.atan2 is in normal math writing?