Пример #1
0
            public void wrong_size_throws()
            {
                var a = new VectorD(5);
                var b = new VectorD(3);

                Assert.Throws <ArgumentOutOfRangeException>(() => a.GetDistanceSquared(b));
            }
Пример #2
0
            public void zero_lengths_have_zero_distance()
            {
                var a        = new VectorD(0);
                var b        = new VectorD(0);
                var expected = 0.0;

                var actual = a.GetDistanceSquared(b);

                Assert.Equal(expected, actual);
            }
Пример #3
0
            public void can_find_distance_in_both_directions()
            {
                var a = new VectorD(5);

                a.Set(0, 1);
                a.Set(1, 2);
                a.Set(2, 3);
                var b = new VectorD(5);

                b.Set(1, -9);
                b.Set(2, 5);
                b.Set(4, 3);
                var expected = a.GetDistanceSquared(b);

                var actual = b.GetDistanceSquared(a);

                Assert.Equal(expected, actual);
            }
Пример #4
0
            public void can_find_distance()
            {
                var a = new VectorD(5);

                a.Set(0, 1);
                a.Set(1, 2);
                a.Set(2, 3);
                var b = new VectorD(5);

                b.Set(1, -9);
                b.Set(2, 5);
                b.Set(3, 2);
                b.Set(4, 3);
                var expected = 139.0;

                var actual = a.GetDistanceSquared(b);

                Assert.Equal(expected, actual);
            }
Пример #5
0
            public void null_vector_throws()
            {
                var a = new VectorD(5);

                Assert.Throws <ArgumentNullException>(() => a.GetDistanceSquared((VectorD)null));
            }