예제 #1
0
        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);
        }
예제 #2
0
파일: Point.cs 프로젝트: ase-lab/Skyhunter
 public static Point rotatePointAboutOrigin(double rotation, Point p)
 {
     return p.rotatePointAboutOrigin(rotation);
 }