void inverse44(
double *inverse,
double *matrix
)
{
double trans[3], trans_xf[3];
MTX3_t matrix3;
inverse[0] = matrix[0];
inverse[1] = matrix[4];
inverse[2] = matrix[8];
inverse[4] = matrix[1];
inverse[5] = matrix[5];
inverse[6] = matrix[9];
inverse[8] = matrix[2];
inverse[9] = matrix[6];
inverse[10] = matrix[10];
inverse[15] = 1.0;
inverse[12] = inverse[13] = inverse[14] = 0.0;
trans[0] = matrix[3];
trans[1] = matrix[7];
trans[2] = matrix[11];
MTX4_mtx3(MTX4_cast_pc(matrix),&matrix3);
MTX3_vec_multiply_t(VEC3_cast_pc(trans),&matrix3,VEC3_cast(trans_xf));
inverse[3] = -trans_xf[0];
inverse[7] = -trans_xf[1];
inverse[11] = -trans_xf[2];
}
What does this function do?
MTX3_t is a definition of 3*3 matrix. MTX4_mtx3 gets a sub matrix. MTX3_vec_multiply_t multiply a vector and a matrix.