Пример #1
0
        public void CanCalculateTheDotProductOfTwoVectors()
        {
            var a = Tuple.NewVector(1, 2, 3);
            var b = Tuple.NewVector(2, 3, 4);

            Assert.True(FloatMath.AreEqual(20, a.Dot(b)));
        }
Пример #2
0
        public void CanCreateAVectorTuple()
        {
            var t = new Tuple4(4.3, -4.2, 3.1, 0.0);

            Assert.True(FloatMath.AreEqual(4.3, t.X));
            Assert.True(FloatMath.AreEqual(-4.2, t.Y));
            Assert.True(FloatMath.AreEqual(3.1, t.Z));
            Assert.True(FloatMath.AreEqual(0.0, t.W));
            Assert.False(t.IsPoint);
            Assert.True(t.IsVector);
        }
Пример #3
0
        public void VectorsHaveAFloatingPointMagnitude(double a, double b, double c)
        {
            var v = Tuple.NewVector(a, b, c);

            Assert.True(FloatMath.AreEqual(v.Magnitude, Math.Sqrt(14)));
        }
Пример #4
0
        public void MagnitudeOfANormalizedVectorEqualsOne()
        {
            var v = Tuple.NewVector(1, 2, 3);

            Assert.True(FloatMath.AreEqual(1, v.Normalized.Magnitude));
        }
Пример #5
0
        public void VectorsHaveAMagnitude(double a, double b, double c, double expected)
        {
            var v = Tuple.NewVector(a, b, c);

            Assert.True(FloatMath.AreEqual(v.Magnitude, expected));
        }