Пример #1
0
        public void NormalizeTest()
        {
            var vector = new KtVector2D(Degrees.Create(45)) * 20;

            vector.Normalize();
            Assert.AreEqual(vector, new KtVector2D(Math.Sqrt(2) / 2, Math.Sqrt(2) / 2));
        }
Пример #2
0
        public void AngleBetweenTest()
        {
            var vector  = new KtVector2D(3, 2);
            var vector2 = new KtVector2D(2, 3);

            Assert.AreEqual(vector.AngleBetween(vector2), Degrees.Create(-(Math.Atan2(2, 3) - Math.Atan2(3, 2)) * 180 / Math.PI));
            Assert.AreEqual(vector2.AngleBetween(vector), Degrees.Create((Math.Atan2(2, 3) - Math.Atan2(3, 2)) * 180 / Math.PI));
        }
Пример #3
0
        public void RotateTest()
        {
            var vector = new KtVector2D(1, 0);

            vector.Rotate(Degrees.Create(45));
            Assert.AreEqual(vector, new KtVector2D(Math.Sqrt(2) / 2, Math.Sqrt(2) / 2));
            var vector2 = new KtVector2D(-1, 1);

            vector2.Rotate(Degrees.Create(-135));
            Assert.AreEqual(vector2, new KtVector2D(Math.Sqrt(2), 0));
        }
Пример #4
0
 private static Angle InteriorAngle(this CircularStack <KtPoint2D> points, KtPoint2D point) =>
 points.Aggregate(Degrees.Create(0.0), (total, c) => total + c.InteriorAngle(point));
Пример #5
0
        public void DirectionTest()
        {
            var vector = new KtVector2D(3, 2);

            Assert.AreEqual(vector.Direction, Degrees.Create(Math.Atan2(2, 3) * 180 / Math.PI));
        }
Пример #6
0
        public void KtVector2DTest1()
        {
            var vector = new KtVector2D(Degrees.Create(45));

            Assert.AreEqual(vector, new KtVector2D(Math.Sqrt(2) / 2, Math.Sqrt(2) / 2));
        }
Пример #7
0
 public static Angle TotalInternalAngle(this CircularStack <KtPoint2D> points, KtPoint2D point) =>
 points.Aggregate(Degrees.Create(0), (total, c) => total + (c?.Next?.Value - point).ToKtVector2D().AngleBetween((c?.Value - point).ToKtVector2D()));
Пример #8
0
 public override Angle Complementary() => Degrees.Create(Value + 0.5);
Пример #9
0
 public override Angle Complementary() => Degrees.Create(Value + Math.PI);