求转换矩阵的逆矩阵

void invert44(
        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];

}

输入为matrix, 输出为inverse.

MTX3_t为3*3的矩阵,MTX4_mtx3取3*3的子阵,MTX3_vec_multiply_t为向量乘矩阵

 

Solution:

http://www.cg.info.hiroshima-cu.ac.jp/~miyazaki/knowledge/teche53.html

你可能感兴趣的:(求转换矩阵的逆矩阵)