public static void Invert(ref Matrix3 matrix, out Matrix3 result) { float determinant = 1 / matrix.Determinant(); result.X.X = (matrix.Y.Y * matrix.Z.Z - matrix.Y.Z * matrix.Z.Y) * determinant; result.X.Y = (matrix.X.Z * matrix.Z.Y - matrix.Z.Z * matrix.X.Y) * determinant; result.X.Z = (matrix.X.Y * matrix.Y.Z - matrix.Y.Y * matrix.X.Z) * determinant; result.Y.X = (matrix.Y.Z * matrix.Z.X - matrix.Y.X * matrix.Z.Z) * determinant; result.Y.Y = (matrix.X.X * matrix.Z.Z - matrix.X.Z * matrix.Z.X) * determinant; result.Y.Z = (matrix.X.Z * matrix.Y.X - matrix.X.X * matrix.Y.Z) * determinant; result.Z.X = (matrix.Y.X * matrix.Z.Y - matrix.Y.Y * matrix.Z.X) * determinant; result.Z.Y = (matrix.X.Y * matrix.Z.X - matrix.X.X * matrix.Z.Y) * determinant; result.Z.Z = (matrix.X.X * matrix.Y.Y - matrix.X.Y * matrix.Y.X) * determinant; }