src/Colourful/Utils/Internals/MatrixUtils.cs
/// <summary>
/// Matrix inverse for 3 by 3 matrices.
/// </summary>
Matrix inverse for 3 by 3 matrices.
Matrix inverse for 3 by 3 matrices .
public static double[,] Inverse(in double[,] matrix)
        {
            var A = matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1];
            var D = -(matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]);
            var G = matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1];
            var B = -(matrix[1, 0] * matrix[2, 2] - matrix[1, 2] * matrix[2, 0]);
            var E = matrix[0, 0] * matrix[2, 2] - matrix[0, 2] * matrix[2, 0];
            var H = -(matrix[0, 0] * matrix[1, 2] - matrix[0, 2] * matrix[1, 0]);
            var C = matrix[1, 0] * matrix[2, 1] - matrix[1, 1] * matrix[2, 0];
            var F = -(matrix[0, 0] * matrix[2, 1] - matrix[0, 1] * matrix[2, 0]);
            var I = matrix[0, 0] * matrix[1, 1] - matrix[0, 1] * matrix[1, 0];
            var det = matrix[0, 0] * A + matrix[0, 1] * B + matrix[0, 2] * C;
            double[,] result =
            {
                { A / det, D / det, G / det },
                { B / det, E / det, H / det },
                { C / det, F / det, I / det },
            };
            return result;
        }
public static double [ , ] Inverse ( in double [ , ] matrix ) { var A = matrix [ 1 , 1 ] * matrix [ 2 , 2 ] - matrix [ 1 , 2 ] * matrix [ 2 , 1 ] ; var D = - ( matrix [ 0 , 1 ] * matrix [ 2 , 2 ] - matrix [ 0 , 2 ] * matrix [ 2 , 1 ] ) ; var G = matrix [ 0 , 1 ] * matrix [ 1 , 2 ] - matrix [ 0 , 2 ] * matrix [ 1 , 1 ] ; var B = - ( matrix [ 1 , 0 ] * matrix [ 2 , 2 ] - matrix [ 1 , 2 ] * matrix [ 2 , 0 ] ) ; var E = matrix [ 0 , 0 ] * matrix [ 2 , 2 ] - matrix [ 0 , 2 ] * matrix [ 2 , 0 ] ; var H = - ( matrix [ 0 , 0 ] * matrix [ 1 , 2 ] - matrix [ 0 , 2 ] * matrix [ 1 , 0 ] ) ; var C = matrix [ 1 , 0 ] * matrix [ 2 , 1 ] - matrix [ 1 , 1 ] * matrix [ 2 , 0 ] ; var F = - ( matrix [ 0 , 0 ] * matrix [ 2 , 1 ] - matrix [ 0 , 1 ] * matrix [ 2 , 0 ] ) ; var I = matrix [ 0 , 0 ] * matrix [ 1 , 1 ] - matrix [ 0 , 1 ] * matrix [ 1 , 0 ] ; var det = matrix [ 0 , 0 ] * A + matrix [ 0 , 1 ] * B + matrix [ 0 , 2 ] * C ; double [ , ] result = { { A / det , D / det , G / det } , { B / det , E / det , H / det } , { C / det , F / det , I / det } , } ; return result ; }
Matrix inverse for 3 by 3 matrices.
Matrix inverse for 3 by 3 matrices .
double[,]
in