<DIV>I'm using vtk to solve a problem which can use IterativeClosestPoint(ICP) arithmetic to match the source points with the target points.</DIV>
<DIV>What I can get is a Matrix4x4 from the functions in vtk. Now I want to check if the result is correct. So I try to use JacobiN(,,,) in vtk to get the </DIV>
<DIV>quaternion and then use the quaternion to get the rotation matrix. At last , I can get the translation vector.</DIV>
<DIV>But when I compare the translation vector I get and the translation vector I set, I find they are not similar at all.</DIV>
<DIV> </DIV>
<DIV>I can give you the part of the code to show my mean:</DIV>
<DIV> </DIV>
<DIV> //the sourcedata and target data have been set.Both of them have 100 points.And I set the translation vector(No rotation matrix)</DIV>
<DIV> </DIV>
<DIV> vtkIterativeClosestPointTransform * icp = vtkIterativeClosestPointTransform::New();<BR> icp->SetSource(SourcePolydata);<BR> icp->SetTarget(TargetPolydata);<BR> icp->GetLandmarkTransform()->SetModeToRigidBody(); <BR> icp->SetMaximumNumberOfIterations(20);<BR> icp->StartByMatchingCentroidsOn();<BR> icp->Modified();<BR> icp->Update();</DIV>
<DIV> </DIV>
<DIV> vtkMatrix4x4* M = icp->GetMatrix();<BR> cout << "Get the Matrix4X4 " << endl;</DIV>
<DIV> </DIV>
<DIV> double ** a;<BR> a = (double **)malloc(sizeof(double *)*4);<BR> for( i = 0; i < 4; i++ )<BR> *(a+i)=(double *)malloc(sizeof(double)*4);</DIV>
<DIV> double ** R;<BR> R = (double **)malloc(sizeof(double *)*4);<BR> for( i = 0; i < 4; i++ )<BR> *(R+i)=(double *)malloc(sizeof(double)*4);<BR> double * T;<BR> T = (double *)malloc(sizeof(double)*4);</DIV>
<DIV> for( i = 0; i <= 3; i++ )<BR> {<BR> printf("\n");<BR> for( int j = 0; j <= 3; j++ )<BR> {<BR> printf("%e\t",M->Element[i][j]);<BR> a[i][j] = M->Element[i][j]; <BR> }<BR> }<BR> cout << endl;<BR> </DIV>
<DIV> //Get the quaternion</DIV>
<DIV> vtkMath::JacobiN( (double **)a, 4, (double *)T, (double **)R );</DIV>
<DIV> </DIV>
<DIV> //Get the rotation matrix</DIV>
<DIV> double Rr[3][3];</DIV>
<DIV> Rr[0][0] = R[0][0]*R[0][0]+R[0][1]*R[0][1]-R[0][2]*R[0][2]-R[0][3]*R[0][3];<BR> Rr[0][1] = 2*(R[0][1]*R[0][2]-R[0][0]*R[0][3]);<BR> Rr[0][2] = 2*(R[0][1]*R[0][3]+R[0][0]*R[0][2]);<BR> Rr[1][0] = 2*(R[0][1]*R[0][2]+R[0][0]*R[0][3]);<BR> Rr[1][1] = -(R[0][0]*R[0][0]-R[0][1]*R[0][1]+R[0][2]*R[0][2]-R[0][3]*R[0][3]);<BR> Rr[1][2] = 2*(R[0][2]*R[0][3]-R[0][0]*R[0][1]);<BR> Rr[2][0] = 2*(R[0][1]*R[0][3]-R[0][0]*R[0][2]);<BR> Rr[2][1] = 2*(R[0][2]*R[0][3]+R[0][0]*R[0][1]);<BR> Rr[2][2] = -(R[0][0]*R[0][0]-R[0][1]*R[0][1]-R[0][2]*R[0][2]+R[0][3]*R[0][3]);</DIV>
<DIV> </DIV>
<DIV> double C3[3];</DIV>
<DIV> // C2[] is the centre point of target points,C1[] is the centre point of source points <BR> C3[0] = C2[0] * Rr[0][0] + C2[1] * Rr[1][0] + C2[2] * Rr[2][0] ;<BR> C3[1] = C2[0] * Rr[0][1] + C2[1] * Rr[1][1] + C2[2] * Rr[2][1] ;<BR> C3[2] = C2[0] * Rr[0][2] + C2[1] * Rr[1][2] + C2[2] * Rr[2][2] ;</DIV>
<DIV> </DIV>
<DIV> for( i = 0; i < 3; i++ )<BR> cout << C1[i] - C3[i] << " ";<BR> cout << endl;</DIV>
<DIV> </DIV>
<DIV>Maybe my way to test was wrong.But I want to get the rotation matrix and translation vector. Could you please solve the problem or give me another way to get what I want.</DIV>
<DIV>Thank you.</DIV>
<DIV> Tranks</DIV>
<DIV> </DIV>
<DIV>
<DIV style="HEIGHT: 1px; CLEAR: both; OVERFLOW: hidden"></DIV></DIV>
<DIV> </DIV>
<DIV>
<DIV style="HEIGHT: 1px; CLEAR: both; OVERFLOW: hidden"></DIV></DIV>
<DIV> </DIV>