public void rotateTest() { Point p = new Point(1, 0); double rotation = Math.PI / 2; Point expected = new Point(0, 1); Point actual = p.rotatePointAboutOrigin(rotation); double epsilon = Math.Pow(10, -10); Assert.IsTrue(Math.Abs(expected.x - actual.x) < epsilon); Assert.IsTrue(Math.Abs(expected.y - actual.y) < epsilon); rotation *= -1; expected.x = 0; expected.y = -1; actual = p.rotatePointAboutOrigin(rotation); Assert.IsTrue(Math.Abs(expected.x - actual.x) < epsilon); Assert.IsTrue(Math.Abs(expected.y - actual.y) < epsilon); rotation = Math.PI / 4; expected.x = 1 / Math.Sqrt(2); expected.y = 1 / Math.Sqrt(2); actual = p.rotatePointAboutOrigin(rotation); Assert.IsTrue(Math.Abs(expected.x - actual.x) < epsilon); Assert.IsTrue(Math.Abs(expected.y - actual.y) < epsilon); }
public static Point rotatePointAboutOrigin(double rotation, Point p) { return p.rotatePointAboutOrigin(rotation); }