Пример #1
0
        public void AngleBetween()
        {
            const double epsilon = 0.0001;
            const double angle   = 63.435; // polar angle of (1,2)

            Assert.AreEqual(0, pointD.AngleBetween(pointD));
            Assert.AreEqual(0, PointD.Empty.AngleBetween(pointD, pointD));
            Assert.AreEqual(Math.PI, PointD.Empty.AngleBetween(new PointD(1, 0), new PointD(-2, 0)));
            Assert.AreEqual(-angle, pointD.AngleBetween(new PointD(2, 0)) * Angle.RadiansToDegrees, epsilon);
            Assert.AreEqual(90.0 - angle, pointD.AngleBetween(new PointD(0, 2)) * Angle.RadiansToDegrees, epsilon);

            Assert.AreEqual(0, pointF.AngleBetween(pointF));
            Assert.AreEqual(0, PointF.Empty.AngleBetween(pointF, pointF));
            Assert.AreEqual(Math.PI, PointF.Empty.AngleBetween(new PointF(1, 0), new PointF(-2, 0)));
            Assert.AreEqual(-angle, pointF.AngleBetween(new PointF(2, 0)) * Angle.RadiansToDegrees, epsilon);
            Assert.AreEqual(90.0 - angle, pointF.AngleBetween(new PointF(0, 2)) * Angle.RadiansToDegrees, epsilon);

            Assert.AreEqual(0, pointI.AngleBetween(pointI));
            Assert.AreEqual(0, PointI.Empty.AngleBetween(pointI, pointI));
            Assert.AreEqual(Math.PI, PointI.Empty.AngleBetween(new PointI(1, 0), new PointI(-2, 0)));
            Assert.AreEqual(-angle, pointI.AngleBetween(new PointI(2, 0)) * Angle.RadiansToDegrees, epsilon);
            Assert.AreEqual(90.0 - angle, pointI.AngleBetween(new PointI(0, 2)) * Angle.RadiansToDegrees, epsilon);
        }