以下是arGetTransMatSub()函数的一些代码。
if( arFittingMode == AR_FITTING_TO_INPUT )
{
for( i = 0; i < num; i++ )
{
arParamIdeal2Observ(dist_factor, ppos2d[i][0], ppos2d[i][1],
&pos2d[i][0], &pos2d[i][1]);
}
}
else
{
for( i = 0; i < num; i++ )
{
pos2d[i][0] = ppos2d[i][0];
pos2d[i][1] = ppos2d[i][1];
}
}
for( j = 0; j < num; j++ )
{
wx = rot[0][0] * pos3d[j][0]
+ rot[0][1] * pos3d[j][1]
+ rot[0][2] * pos3d[j][2];
wy = rot[1][0] * pos3d[j][0]
+ rot[1][1] * pos3d[j][1]
+ rot[1][2] * pos3d[j][2];
wz = rot[2][0] * pos3d[j][0]
+ rot[2][1] * pos3d[j][1]
+ rot[2][2] * pos3d[j][2];
mat_a->m[j*6+0] = mat_b->m[num*0+j*2] = cpara[0][0];
mat_a->m[j*6+1] = mat_b->m[num*2+j*2] = cpara[0][1];
mat_a->m[j*6+2] = mat_b->m[num*4+j*2] = cpara[0][2] - pos2d[j][0];
mat_c->m[j*2+0] = wz * pos2d[j][0]
- cpara[0][0]*wx - cpara[0][1]*wy - cpara[0][2]*wz;
mat_a->m[j*6+3] = mat_b->m[num*0+j*2+1] = 0.0;
mat_a->m[j*6+4] = mat_b->m[num*2+j*2+1] = cpara[1][1];
mat_a->m[j*6+5] = mat_b->m[num*4+j*2+1] = cpara[1][2] - pos2d[j][1];
mat_c->m[j*2+1] = wz * pos2d[j][1]
- cpara[1][1]*wy - cpara[1][2]*wz;
}
arMatrixMul( mat_d, mat_b, mat_a );
arMatrixMul( mat_e, mat_b, mat_c );
arMatrixSelfInv( mat_d );
arMatrixMul( mat_f, mat_d, mat_e );
trans[0] = mat_f->m[0];
trans[1] = mat_f->m[1];
trans[2] = mat_f->m[2];
ret = arModifyMatrix( rot, trans, cpara, pos3d, pos2d, num );