Videos
atan function gives value in range -Pi/2..Pi/2 (-90..90 degrees), while atan2 is intended for full circle range -Pi..Pi (look at specifications in Math description).
You can see that you result difference is exactly 180=Pi for cases when angle is in the second and third quarters.
So results are correct, and you just have to interpret them properly. For vectors (direction!) we need angle in full range, while line might be described with half-range angle value provided by atan
Use atan2() -- With atan(), you might enter 123/0 and get into mathematical trouble.
"accurate results" -- That depends. If the points are cities, 2 decimal places are adequate for lat/lng; if you need to distinguish between the GPS location of your daughter and the guy she is kissing, 6 decimal places should do.
The number of decimal places in the result of atan2 is tricker -- we need to see what it will be used for.
If you are drawing graphics on your computer monitor, 4 significant digits everywhere should be plenty.
oldY = 360 -- That is suspiciously like an angle, not a y-value??
Hey guys,
linky. so, i am expecting something like this when solving for θ but instead i'm seeing outputs like this. As i understand it, the radians should begin at 0 and counter-clockwise go to 6.28, roughly.
Instead, an angle in the 1st quadrant is 0 to -1.57, from the 2nd quadrant from -1.57 to -3.14. And then if i keep going into the 3rd quadrant it goes from 3.14 to 1.57, and 1.57 to 0.
