public void MultiplyVector4() { var a = new SrtTransform(new Vector3F(1, 2, 7), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, -5, 6)); var v = new Vector4F(7, 9, -12, -2); var result1 = a * v; var result2 = a.ToMatrix44F() * v; Assert.IsTrue(Vector4F.AreNumericallyEqual(result1, result2)); result1 = SrtTransform.Multiply(a, v); result2 = a.ToMatrix44F() * v; Assert.IsTrue(Vector4F.AreNumericallyEqual(result1, result2)); }
public void ToLocalPosition() { var a = new SrtTransform(new Vector3F(1, 2, 7), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, -5, 6)); var v = new Vector3F(7, 9, -12); var result1 = a.ToLocalPosition(v); var result2 = a.ToMatrix44F().Inverse.TransformPosition(v); Assert.IsTrue(Vector3F.AreNumericallyEqual(result1, result2)); }
public void MultiplyWithUniformScaleIsTheSameAsMatrixMultiply() { // Result is the same as Matrix mulitiplication without scale. var a = new SrtTransform(new Vector3F(7), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, -5, 6)); var b = new SrtTransform(new Vector3F(-3), new QuaternionF(3, -2, 1, 9).Normalized, new Vector3F(7, -4, 2)); var result1 = (a * b).ToMatrix44F(); var result2 = a.ToMatrix44F() * b.ToMatrix44F(); Assert.IsTrue(Matrix44F.AreNumericallyEqual(result1, result2)); }
public void MultiplyWithoutRotationIsTheSameAsMatrixMultiply() { // Result is the same as Matrix mulitiplication without scale. var a = new SrtTransform(new Vector3F(1, 2, 3), QuaternionF.Identity, new Vector3F(4, -5, 6)); var b = new SrtTransform(new Vector3F(5, 6, -3), QuaternionF.Identity, new Vector3F(7, -4, 2)); var result1 = (a * b).ToMatrix44F(); var result2 = a.ToMatrix44F() * b.ToMatrix44F(); Assert.IsTrue(Matrix44F.AreNumericallyEqual(result1, result2)); }
public void ToParentPosition() { var a = new SrtTransform(new Vector3F(1, 2, 7), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, -5, 6)); var v = new Vector3F(7, 9, -12); var result1 = a.ToParentPosition(v); var result2 = a.ToMatrix44F().TransformPosition(v); Assert.IsTrue(Vector3F.AreNumericallyEqual(result1, result2)); }