Exemple #1
0
        public void QuaternionSlerpTest4()
        {
            Vector3    axis = Vector3.Normalize(new Vector3(1.0f, 2.0f, 3.0f));
            Quaternion a    = Quaternion.CreateFromAxisAngle(axis, MathHelper.ToRadians(10.0f));
            Quaternion b    = -Quaternion.CreateFromAxisAngle(axis, MathHelper.ToRadians(30.0f));

            Single t = 0.0f;

            Quaternion expected = new Quaternion(a.X, a.Y, a.Z, a.W);
            Quaternion actual   = Quaternion.Slerp(a, b, t);

            Assert.True(MathHelper.Equal(expected, actual), $"Quaternion.Slerp did not return the expected value: expected {expected} actual {actual}");
        }
Exemple #2
0
        public void QuaternionSlerpTest3()
        {
            Vector3    axis = Vector3.Normalize(new Vector3(1.0f, 2.0f, 3.0f));
            Quaternion a    = Quaternion.CreateFromAxisAngle(axis, MathHelper.ToRadians(10.0f));
            Quaternion b    = -a;

            Single t = 1.0f;

            Quaternion expected = a;
            Quaternion actual   = Quaternion.Slerp(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 == expected, $"Quaternion.Slerp did not return the expected value: expected {expected} actual {actual}");
        }
Exemple #3
0
        public void QuaternionSlerpTest()
        {
            Vector3    axis = Vector3.Normalize(new Vector3(1.0f, 2.0f, 3.0f));
            Quaternion a    = Quaternion.CreateFromAxisAngle(axis, MathHelper.ToRadians(10.0f));
            Quaternion b    = Quaternion.CreateFromAxisAngle(axis, MathHelper.ToRadians(30.0f));

            Single t = 0.5f;

            Quaternion expected = Quaternion.CreateFromAxisAngle(axis, MathHelper.ToRadians(20.0f));
            Quaternion actual;

            actual = Quaternion.Slerp(a, b, t);
            Assert.True(MathHelper.Equal(expected, actual), $"Quaternion.Slerp did not return the expected value: expected {expected} actual {actual}");

            // Case a and b are same.
            expected = a;
            actual   = Quaternion.Slerp(a, a, t);
            Assert.True(MathHelper.Equal(expected, actual), $"Quaternion.Slerp did not return the expected value: expected {expected} actual {actual}");
        }