Exemplo n.º 1
0
        // This should be added to SharpDX.
        private static Matrix3x2 Invert(Matrix3x2 value)
        {
            Matrix3x2 result = Matrix3x2.Identity;

            float determinant = value.Determinant();

            if (determinant == 0.0f)
            {
                return(value);
            }

            float invdet  = 1.0f / determinant;
            float offsetX = value.M31;
            float offsetY = value.M32;

            return(new Matrix3x2(
                       value.M22 * invdet,
                       -value.M12 * invdet,
                       -value.M21 * invdet,
                       value.M11 * invdet,
                       ((value.M21 * offsetY) - (offsetX * value.M22)) * invdet,
                       ((offsetX * value.M12) - (value.M11 * offsetY)) * invdet));
        }