コード例 #1
0
            public void zero_size_vector_has_zero_squared_magnitude()
            {
                var vector   = new VectorD(0);
                var expected = 0.0;

                var actual = vector.GetMagnitude();

                Assert.Equal(expected, actual);
            }
コード例 #2
0
            public void can_normalize_sample()
            {
                var vector   = new VectorD(new[] { 3.0, 4, 5, -6 });
                var expected = vector.GetQuotient(vector.GetMagnitude());

                var actual = vector.GetNormal();

                Assert.Equal(expected, actual);
            }
コード例 #3
0
            public void negative_values_produce_same_magnitude()
            {
                var vector = new VectorD(3);

                vector.Set(0, 3);
                vector.Set(1, -4);
                vector.Set(2, 5);
                var expected = vector.GetMagnitude();

                var actual = vector.GetNegative().GetMagnitude();

                Assert.Equal(expected, actual);
            }
コード例 #4
0
            public void can_get_magnitude()
            {
                var vector = new VectorD(3);

                vector.Set(0, 3);
                vector.Set(1, -4);
                vector.Set(2, 5);
                var expected = Math.Sqrt(50.0);

                var actual = vector.GetMagnitude();

                Assert.Equal(expected, actual);
            }