Exemplo n.º 1
0
        public void MultiplyVector4()
        {
            var a = new SrtTransform(new Vector3(1, 2, 7), new Quaternion(1, 2, 3, 4).Normalized, new Vector3(4, -5, 6));
            var v = new Vector4(7, 9, -12, -2);

            var result1 = a * v;
            var result2 = a.ToMatrix() * v;

            Assert.IsTrue(Vector4.AreNumericallyEqual(result1, result2));

            result1 = SrtTransform.Multiply(a, v);
            result2 = a.ToMatrix() * v;
            Assert.IsTrue(Vector4.AreNumericallyEqual(result1, result2));
        }
Exemplo n.º 2
0
        public void ToLocalPosition()
        {
            var a = new SrtTransform(new Vector3(1, 2, 7), new Quaternion(1, 2, 3, 4).Normalized, new Vector3(4, -5, 6));
            var v = new Vector3(7, 9, -12);

            var result1 = a.ToLocalPosition(v);
            var result2 = a.ToMatrix().Inverse.TransformPosition(v);

            Assert.IsTrue(Vector3.AreNumericallyEqual(result1, result2));
        }
Exemplo n.º 3
0
        public void MultiplyWithUniformScaleIsTheSameAsMatrixMultiply()
        {
            // Result is the same as Matrix mulitiplication without scale.
            var a = new SrtTransform(new Vector3(7), new Quaternion(1, 2, 3, 4).Normalized, new Vector3(4, -5, 6));
            var b = new SrtTransform(new Vector3(-3), new Quaternion(3, -2, 1, 9).Normalized, new Vector3(7, -4, 2));

            var result1 = (a * b).ToMatrix();
            var result2 = a.ToMatrix() * b.ToMatrix();

            Assert.IsTrue(Matrix.AreNumericallyEqual(result1, result2));
        }
Exemplo n.º 4
0
        public void MultiplyWithoutRotationIsTheSameAsMatrixMultiply()
        {
            // Result is the same as Matrix mulitiplication without scale.
            var a = new SrtTransform(new Vector3(1, 2, 3), Quaternion.Identity, new Vector3(4, -5, 6));
            var b = new SrtTransform(new Vector3(5, 6, -3), Quaternion.Identity, new Vector3(7, -4, 2));

            var result1 = (a * b).ToMatrix();
            var result2 = a.ToMatrix() * b.ToMatrix();

            Assert.IsTrue(Matrix.AreNumericallyEqual(result1, result2));
        }