c++ - Does it really inverse a transform matrix? -
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 function do?
mtx3_t definition of 3*3 matrix. mtx4_mtx3 gets sub matrix. mtx3_vec_multiply_t multiply vector , matrix.
yes. please see this link compute inverse of transformation matrix. basic idea scaling/rotation combination of transformation matrix (first 3x3 sub-matrix) orthonormal matrix , inverse of on orthonormal matrix equal the transpose. so, first part transpose computation. second part (starting line trans[0] = matrix[3]) computation inverse translation part (last column of matrix.
Comments
Post a Comment