Example #1
0
        public void TestInverse()
        {
            float x = TK.MathHelper.PiOver6;
            float y = TK.MathHelper.Pi;

            TK.Matrix4 tkM = TK.Matrix4.CreateRotationX(x) * TK.Matrix4.CreateRotationY(y);
            Matrix3x3  m   = Matrix3x3.FromRotationX(x) * Matrix3x3.FromRotationY(y);

            tkM.Invert();
            m.Inverse();

            TestHelper.AssertEquals(tkM, m, "Testing inverse");
        }
 /// <summary>Transform a Normal by the given Matrix</summary>
 /// <remarks>
 /// This calculates the inverse of the given matrix, use TransformNormalInverse if you
 /// already have the inverse to avoid this extra calculation
 /// </remarks>
 /// <param name="norm">The normal to transform</param>
 /// <param name="mat">The desired transformation</param>
 /// <returns>The transformed normal</returns>
 public static Vector3 TransformNormal(Vector3 norm, Matrix4 mat)
 {
     mat.Invert();
     return(TransformNormalInverse(norm, mat));
 }
        /// <summary>Transform a Normal by the given Matrix</summary>
        /// <remarks>
        /// This calculates the inverse of the given matrix, use TransformNormalInverse if you
        /// already have the inverse to avoid this extra calculation
        /// </remarks>
        /// <param name="norm">The normal to transform</param>
        /// <param name="mat">The desired transformation</param>
        /// <param name="result">The transformed normal</param>
        public static void TransformNormal(ref Vector3 norm, ref Matrix4 mat, out Vector3 result)
        {
            Matrix4 Inverse = Matrix4.Invert(mat);

            Vector3.TransformNormalInverse(ref norm, ref Inverse, out result);
        }