游戏开发中的数学和物理算法(15):矩阵的加减法 矩阵加法数学表示 矩阵减法数学表示: 计算机中矩阵加法的实现: Matrix3X3 addMatrices(Matrix3X3 a, Matrix3X3 b) { Matrix3X3 temp; for(int i = 0;i<3;i++) { for(int j=0;j<3;j++) { temp.index[i][j] = (a.index[i][j] + b.index[i][j]); } } return temp; } 计算机中矩阵减法的实现: Matrix4X4 subtractMatrices(Matrix4X4 a, Matrix4X4 b) { Matrix4X4 temp; for(int i = 0;i<4;i++) { for(int j=0;j<4;j++) { temp.index[i][j] = (a.index[i][j] - b.index[i][j]); } } return temp; }