/// <summary> /// Constructs an identity matrix from another matrix. /// </summary> public Matrix4D(Matrix4D matrix) { values = (double [,]) matrix.values.Clone(); }
/// <summary> /// Used to multiply (concatenate) two 4x4 Matrices. /// </summary> /// <param name="left"></param> /// <param name="right"></param> /// <returns></returns> public static Matrix4D operator * (Matrix4D left, Matrix4D right) { Matrix4D result = new Matrix4D(); result.values[0, 0] = left.values[0, 0] * right.values[0, 0] + left.values[0, 1] * right.values[1, 0] + left.values[0, 2] * right.values[2, 0] + left.values[0, 3] * right.values[3, 0]; result.values[0, 1] = left.values[0, 0] * right.values[0, 1] + left.values[0, 1] * right.values[1, 1] + left.values[0, 2] * right.values[2, 1] + left.values[0, 3] * right.values[3, 1]; result.values[0, 2] = left.values[0, 0] * right.values[0, 2] + left.values[0, 1] * right.values[1, 2] + left.values[0, 2] * right.values[2, 2] + left.values[0, 3] * right.values[3, 2]; result.values[0, 3] = left.values[0, 0] * right.values[0, 3] + left.values[0, 1] * right.values[1, 3] + left.values[0, 2] * right.values[2, 3] + left.values[0, 3] * right.values[3, 3]; result.values[1, 0] = left.values[1, 0] * right.values[0, 0] + left.values[1, 1] * right.values[1, 0] + left.values[1, 2] * right.values[2, 0] + left.values[1, 3] * right.values[3, 0]; result.values[1, 1] = left.values[1, 0] * right.values[0, 1] + left.values[1, 1] * right.values[1, 1] + left.values[1, 2] * right.values[2, 1] + left.values[1, 3] * right.values[3, 1]; result.values[1, 2] = left.values[1, 0] * right.values[0, 2] + left.values[1, 1] * right.values[1, 2] + left.values[1, 2] * right.values[2, 2] + left.values[1, 3] * right.values[3, 2]; result.values[1, 3] = left.values[1, 0] * right.values[0, 3] + left.values[1, 1] * right.values[1, 3] + left.values[1, 2] * right.values[2, 3] + left.values[1, 3] * right.values[3, 3]; result.values[2, 0] = left.values[2, 0] * right.values[0, 0] + left.values[2, 1] * right.values[1, 0] + left.values[2, 2] * right.values[2, 0] + left.values[2, 3] * right.values[3, 0]; result.values[2, 1] = left.values[2, 0] * right.values[0, 1] + left.values[2, 1] * right.values[1, 1] + left.values[2, 2] * right.values[2, 1] + left.values[2, 3] * right.values[3, 1]; result.values[2, 2] = left.values[2, 0] * right.values[0, 2] + left.values[2, 1] * right.values[1, 2] + left.values[2, 2] * right.values[2, 2] + left.values[2, 3] * right.values[3, 2]; result.values[2, 3] = left.values[2, 0] * right.values[0, 3] + left.values[2, 1] * right.values[1, 3] + left.values[2, 2] * right.values[2, 3] + left.values[2, 3] * right.values[3, 3]; result.values[3, 0] = left.values[3, 0] * right.values[0, 0] + left.values[3, 1] * right.values[1, 0] + left.values[3, 2] * right.values[2, 0] + left.values[3, 3] * right.values[3, 0]; result.values[3, 1] = left.values[3, 0] * right.values[0, 1] + left.values[3, 1] * right.values[1, 1] + left.values[3, 2] * right.values[2, 1] + left.values[3, 3] * right.values[3, 1]; result.values[3, 2] = left.values[3, 0] * right.values[0, 2] + left.values[3, 1] * right.values[1, 2] + left.values[3, 2] * right.values[2, 2] + left.values[3, 3] * right.values[3, 2]; result.values[3, 3] = left.values[3, 0] * right.values[0, 3] + left.values[3, 1] * right.values[1, 3] + left.values[3, 2] * right.values[2, 3] + left.values[3, 3] * right.values[3, 3]; return result; }