Firstly, my math is not strong! But I calculated the point angle from the origin (0, 0) to (-1, -1).
This angle is 225 Β° or 5Ο / 4.
- 5Ο / 4 = 3.9269908169872415480783042290994
- Math.Atan2 (-1, -1) = -2.3561944901923448
Perhaps my understanding of Math.Atan2 is incorrect, but I thought that he should have returned the degree of the angle given by two points on the circle, the beginning of which (0, 0). I assume that what happens here is that the result from Atan2 βflippedβ because it is on the negative side of the X axis ... can someone confirm and provide an appropriate way to do this?
This is my test that fails:
Assert.AreEqual((5 * Math.PI) / 4, Math.Atan2(-1, -1));
And here is my PointD class, which contains points X and Y:
public double ToRadians() { double radians = Math.Atan2(this.Y, this.X); return radians; }
source share