Example #1
0
        public void QuaternionNegateTest()
        {
            Quaternion a = new Quaternion(1.0f, 2.0f, 3.0f, 4.0f);

            Quaternion expected = new Quaternion(-1.0f, -2.0f, -3.0f, -4.0f);
            Quaternion actual;

            actual = Quaternion.Negate(a);
            Assert.Equal(expected, actual);
        }
Example #2
0
        public void QuaternionLerpTest3()
        {
            Vector3    axis = Vector3.Normalize(new Vector3(1.0f, 2.0f, 3.0f));
            Quaternion a    = Quaternion.CreateFromAxisAngle(axis, MathHelper.ToRadians(10.0f));
            Quaternion b    = Quaternion.Negate(a);

            Single t = 1.0f;

            Quaternion actual = Quaternion.Lerp(a, b, t);

            // Note that in quaternion world, Q == -Q. In the case of quaternions dot product is zero,
            // one of the quaternion will be flipped to compute the shortest distance. When t = 1, we
            // expect the result to be the same as quaternion b but flipped.
            Assert.True(actual == a, $"Quaternion.Lerp did not return the expected value: expected {a} actual {actual}");
        }