Ejemplo n.º 1
0
        public void BarycentricByRefTest()
        {
            Quaternion value1         = Utilities.GenerateQuaternion();
            Quaternion value1Expected = value1;
            Quaternion value2         = Utilities.GenerateQuaternion();
            Quaternion value2Expected = value2;
            Quaternion value3         = Utilities.GenerateQuaternion();
            Quaternion value3Expected = value3;
            float      amount1        = Utilities.GenerateFloat();
            float      amount2        = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.BaryCentric(
                                                                  Utilities.ConvertToMdx(value1),
                                                                  Utilities.ConvertToMdx(value2),
                                                                  Utilities.ConvertToMdx(value3),
                                                                  amount1,
                                                                  amount2));

            Quaternion.Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out result);
            Utilities.AreEqual(value1Expected, value1);
            Utilities.AreEqual(value2Expected, value2);
            Utilities.AreEqual(value3Expected, value3);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 2
0
        public void SquadByRefTest()
        {
            Quaternion value1         = Utilities.GenerateQuaternion();
            Quaternion value1Expected = value1;
            Quaternion value2         = Utilities.GenerateQuaternion();
            Quaternion value2Expected = value2;
            Quaternion value3         = Utilities.GenerateQuaternion();
            Quaternion value3Expected = value3;
            Quaternion value4         = Utilities.GenerateQuaternion();
            Quaternion value4Expected = value4;
            float      amount         = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Squad(
                                                                  Utilities.ConvertToMdx(value1),
                                                                  Utilities.ConvertToMdx(value2),
                                                                  Utilities.ConvertToMdx(value3),
                                                                  Utilities.ConvertToMdx(value4),
                                                                  amount));

            Quaternion.Squad(ref value1, ref value2, ref value3, ref value4, amount, out result);
            Utilities.AreEqual(value1Expected, value1);
            Utilities.AreEqual(value2Expected, value2);
            Utilities.AreEqual(value3Expected, value3);
            Utilities.AreEqual(value4Expected, value4);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 3
0
        public void SquadSetupTest()
        {
            Quaternion value1 = Utilities.GenerateQuaternion();
            Quaternion value2 = Utilities.GenerateQuaternion();
            Quaternion value3 = Utilities.GenerateQuaternion();
            Quaternion value4 = Utilities.GenerateQuaternion();

            Quaternion[] expected             = new Quaternion[3];
            Microsoft.DirectX.Quaternion outa = new Microsoft.DirectX.Quaternion();
            Microsoft.DirectX.Quaternion outb = new Microsoft.DirectX.Quaternion();
            Microsoft.DirectX.Quaternion outc = new Microsoft.DirectX.Quaternion();
            Microsoft.DirectX.Quaternion.SquadSetup(
                ref outa,
                ref outb,
                ref outc,
                Utilities.ConvertToMdx(value1),
                Utilities.ConvertToMdx(value2),
                Utilities.ConvertToMdx(value3),
                Utilities.ConvertToMdx(value4));
            expected[0] = Utilities.ConvertFrom(outa);
            expected[1] = Utilities.ConvertFrom(outb);
            expected[2] = Utilities.ConvertFrom(outc);

            Quaternion[] actual;
            actual = Quaternion.SquadSetup(value1, value2, value3, value4);

            Assert.IsNotNull(actual);
            Assert.IsTrue(expected.Length == actual.Length);

            for (int i = 0; i < expected.Length; ++i)
            {
                Utilities.AreEqual(expected[i], actual[i]);
            }
        }
Ejemplo n.º 4
0
        public void IsIdentityTest()
        {
            Quaternion target = Utilities.GenerateQuaternion();

            Utilities.AreNotEqual(Quaternion.Identity, target);
            Utilities.AreEqual(Quaternion.Identity, Quaternion.Identity);
        }
Ejemplo n.º 5
0
        public void QuaternionConstructorTest4()
        {
            Vector4    value  = Utilities.GenerateVector4();
            Quaternion target = new Quaternion(value);

            Utilities.AreEqual(value.X, target.X, 0f);
            Utilities.AreEqual(value.Y, target.Y, 0f);
            Utilities.AreEqual(value.Z, target.Z, 0f);
            Utilities.AreEqual(value.W, target.W, 0f);
        }
Ejemplo n.º 6
0
        public void QuaternionConstructorTest3()
        {
            float      value  = Utilities.GenerateFloat();
            Quaternion target = new Quaternion(value);

            Utilities.AreEqual(value, target.X, 0f);
            Utilities.AreEqual(value, target.Y, 0f);
            Utilities.AreEqual(value, target.Z, 0f);
            Utilities.AreEqual(value, target.W, 0f);
        }
Ejemplo n.º 7
0
        public void NormalizeTest()
        {
            Quaternion target = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Normalize(
                                                            Utilities.ConvertToXna(target)));

            target.Normalize();
            Utilities.AreEqual(expected, target);
        }
Ejemplo n.º 8
0
        public void QuaternionConstructorTest5()
        {
            Vector3    value  = Utilities.GenerateVector3();
            float      w      = Utilities.GenerateFloat();
            Quaternion target = new Quaternion(value, w);

            Utilities.AreEqual(value.X, target.X, 0f);
            Utilities.AreEqual(value.Y, target.Y, 0f);
            Utilities.AreEqual(value.Z, target.Z, 0f);
            Utilities.AreEqual(w, target.W, 0f);
        }
Ejemplo n.º 9
0
        public void LengthSquaredTest()
        {
            Quaternion target = Utilities.GenerateQuaternion();

            float expected = Microsoft.DirectX.Quaternion.LengthSq(
                Utilities.ConvertToMdx(target));

            float actual;

            actual = target.LengthSquared;
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 10
0
        public void ExponentialTest()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Exp(
                                                            Utilities.ConvertToMdx(value)));

            Quaternion actual;

            actual = Quaternion.Exponential(value);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 11
0
        public void LogarithmTest()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Ln(
                                                            Utilities.ConvertToMdx(value)));

            Quaternion actual;

            actual = Quaternion.Logarithm(value);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 12
0
        public void op_UnaryNegationTest()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Negate(
                                                            Utilities.ConvertToXna(value)));

            Quaternion actual;

            actual = -(value);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 13
0
        public void NormalizeTest1()
        {
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Normalize(
                                                            Utilities.ConvertToXna(value)));

            Quaternion actual;

            actual = Quaternion.Normalize(value);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 14
0
        public void RotationMatrixTest()
        {
            Matrix matrix = Utilities.GenerateMatrix();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.CreateFromRotationMatrix(
                                                            Utilities.ConvertToXna(matrix)));

            Quaternion actual;

            actual = Quaternion.RotationMatrix(matrix);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 15
0
        public void AngleTest()
        {
            //angle = 2 * arcos(qw)

            Quaternion target = Utilities.GenerateQuaternion();
            float      actual;

            actual = target.Angle;

            float expected = 2.0f * (float)Math.Acos(target.W);

            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 16
0
        public void NormalizeByRefTest()
        {
            Quaternion value         = Utilities.GenerateQuaternion();
            Quaternion valueExpected = value;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Normalize(
                                                                  Utilities.ConvertToXna(value)));

            Quaternion.Normalize(ref value, out result);
            Utilities.AreEqual(valueExpected, value);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 17
0
        public void RotationMatrixByRefTest()
        {
            Matrix     matrix         = Utilities.GenerateMatrix();
            Matrix     matrixExpected = matrix;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.CreateFromRotationMatrix(
                                                                  Utilities.ConvertToXna(matrix)));

            Quaternion.RotationMatrix(ref matrix, out result);
            Utilities.AreEqual(matrixExpected, matrix);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 18
0
        public void LogarithmByRefTest()
        {
            Quaternion value         = Utilities.GenerateQuaternion();
            Quaternion valueExpected = value;
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Ln(
                                                                  Utilities.ConvertToMdx(value)));

            Quaternion.Logarithm(ref value, out result);
            Utilities.AreEqual(valueExpected, value);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 19
0
        public void QuaternionConstructorTest1()
        {
            float      x      = Utilities.GenerateFloat();
            float      y      = Utilities.GenerateFloat();
            float      z      = Utilities.GenerateFloat();
            float      w      = Utilities.GenerateFloat();
            Quaternion target = new Quaternion(x, y, z, w);

            Utilities.AreEqual(x, target.X, 0f);
            Utilities.AreEqual(y, target.Y, 0f);
            Utilities.AreEqual(z, target.Z, 0f);
            Utilities.AreEqual(w, target.W, 0f);
        }
Ejemplo n.º 20
0
        public void op_MultiplyTest()
        {
            float      scale = Utilities.GenerateFloat();
            Quaternion value = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Multiply(
                                                            Utilities.ConvertToXna(value),
                                                            scale));

            Quaternion actual;

            actual = (scale * value);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 21
0
        public void op_AdditionTest()
        {
            Quaternion left  = Utilities.GenerateQuaternion();
            Quaternion right = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Add(
                                                            Utilities.ConvertToXna(left),
                                                            Utilities.ConvertToXna(right)));

            Quaternion actual;

            actual = (left + right);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 22
0
        public void SubtractTest()
        {
            Quaternion left  = Utilities.GenerateQuaternion();
            Quaternion right = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Subtract(
                                                            Utilities.ConvertToXna(left),
                                                            Utilities.ConvertToXna(right)));

            Quaternion actual;

            actual = Quaternion.Subtract(left, right);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 23
0
        public void DotTest()
        {
            Quaternion left  = Utilities.GenerateQuaternion();
            Quaternion right = Utilities.GenerateQuaternion();

            float expected = Microsoft.Xna.Framework.Quaternion.Dot(
                Utilities.ConvertToXna(left),
                Utilities.ConvertToXna(right));

            float actual;

            actual = Quaternion.Dot(left, right);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 24
0
        public void MultiplyTest()
        {
            Quaternion left  = Utilities.GenerateQuaternion();
            Quaternion right = Utilities.GenerateQuaternion();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.Multiply(
                                                            Utilities.ConvertToMdx(left),
                                                            Utilities.ConvertToMdx(right)));

            Quaternion actual;

            actual = Quaternion.Multiply(left, right);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 25
0
        public void RotationAxisTest()
        {
            Vector3 axis  = Utilities.GenerateVector3();
            float   angle = Utilities.GenerateFloat();

            Quaternion expected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.RotationAxis(
                                                            Utilities.ConvertToMdx(axis),
                                                            angle));

            Quaternion actual;

            actual = Quaternion.RotationAxis(axis, angle);
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 26
0
        public void IsNormalizedTest()
        {
            Quaternion target   = Utilities.GenerateQuaternion();
            bool       expected = false;
            bool       actual;

            actual = target.IsNormalized;
            Utilities.AreEqual(expected, actual);

            target = Utilities.GenerateQuaternion();
            target.Normalize();
            expected = true;
            actual   = target.IsNormalized;
            Utilities.AreEqual(expected, actual);
        }
Ejemplo n.º 27
0
        public void RotationYawPitchRollByRefTest()
        {
            float      yaw   = Utilities.GenerateFloat();
            float      pitch = Utilities.GenerateFloat();
            float      roll  = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.CreateFromYawPitchRoll(
                                                                  yaw,
                                                                  pitch,
                                                                  roll));

            Quaternion.RotationYawPitchRoll(yaw, pitch, roll, out result);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 28
0
        public void MultiplyScaleByRefTest()
        {
            Quaternion value         = Utilities.GenerateQuaternion();
            Quaternion valueExpected = value;
            float      scale         = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.Xna.Framework.Quaternion.Multiply(
                                                                  Utilities.ConvertToXna(value),
                                                                  scale));

            Quaternion.Multiply(ref value, scale, out result);
            Utilities.AreEqual(valueExpected, value);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 29
0
        public void RotationAxisByRefTest()
        {
            Vector3    axis         = Utilities.GenerateVector3();
            Vector3    axisExpected = axis;
            float      angle        = Utilities.GenerateFloat();
            Quaternion result;

            Quaternion resultExpected = Utilities.ConvertFrom(Microsoft.DirectX.Quaternion.RotationAxis(
                                                                  Utilities.ConvertToMdx(axis),
                                                                  angle));

            Quaternion.RotationAxis(ref axis, angle, out result);
            Utilities.AreEqual(axisExpected, axis);
            Utilities.AreEqual(resultExpected, result);
        }
Ejemplo n.º 30
0
        public void op_EqualityTest()
        {
            Quaternion left     = Utilities.GenerateQuaternion();
            Quaternion right    = new Quaternion(left.X + 1f, left.Y - 1f, left.Z, left.W + 2f);
            bool       expected = false;
            bool       actual;

            actual = left == right;
            Utilities.AreEqual(expected, actual);

            left     = Utilities.GenerateQuaternion();
            right    = left;
            expected = true;
            actual   = left == right;
            Utilities.AreEqual(expected, actual);
        }