/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkHomogeneousTransformTest.cxx,v $ Language: C++ Date: $Date: 2007-03-14 12:37:08 $ Version: $Revision: 1.1 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. This test was contributed by Rupert Brooks, McGill Centre for Intelligent Machines, Montreal, Canada. It is based loosely on itkAffineTransformTest but actually tests the output of most methods. =========================================================================*/ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #define MSG(A) std::cout< #include "itkHomogeneousTransform.h" #include "itkAffineTransform.h" #include "itkImage.h" #include "vnl/vnl_vector_fixed.h" typedef itk::Matrix Matrix2DType; typedef itk::Vector Vector2DType; typedef itk::Point Point2DType; typedef itk::Point HomogPoint2DType; typedef itk::Matrix Matrix3DType; typedef itk::Vector Vector3DType; typedef itk::Point Point3DType; typedef itk::Point HomogPoint3DType; typedef itk::HomogeneousTransform Homogeneous2DType; typedef itk::AffineTransform Affine2DType; typedef itk::HomogeneousTransform Homogeneous3DType; typedef itk::AffineTransform Affine3DType; namespace { void PrintPoint2D( const Point2DType & v ) { for( unsigned int i=0; iGetMatrix(); idpoint = id2->GetCenter(); std::cout << "Matrix from instantiating an identity transform:" << std::endl << idmatrix; std::cout << "Center from instantiating an identity transform:" << std::endl; PrintPoint2D( idpoint ); id2->SetIdentity(); testmatrix=(id2->GetMatrix())-idmatrix; double sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, either does not initialize to identity, or set identity broken"); } MSG("Test complete "<SetMatrix( matrix1 ); homog2->SetCenter( point2 ); MSG( "Instantiation of a given 2D transform:" ); MSG( homog2 ); inverse2 = homog2->GetInverseMatrix(); // try multiplying this inverse by the matrix, to see if it gives the identity testmatrix=matrix1*inverse2-idmatrix; sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, inverse times matrix not equal to identity"); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; } MSG("Test complete "<SetMatrix( matrix1 ); MSG( "Instantiated with center 0:" ); MSG( homog3 ); inverse2 = homog3->GetInverseMatrix(); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; MSG("Test complete "<Metric(homog3); b=homog3->Metric(homog2); MSG( "Metric 1-2:"<SetMatrix( matrix2 ); MSG( "Just changed the matrix of this one" ); MSG( homog3 ); inverse2 = homog3->GetInverseMatrix(); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; // try multiplying this inverse by the matrix, to see if it gives the identity testmatrix=matrix2*inverse2-idmatrix; sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, inverse times matrix not equal to identity"); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; } MSG("Test complete "<TransformPoint(inpoint1); outpoint2=homog3->BackTransformPoint(outpoint1); int flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point is not equal to input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point: "); PrintPoint2D(outpoint1); MSG("Backtransformed Point: "); PrintPoint2D(outpoint2); } tempmatrix=homog3->GetMatrix(); MSG("Matrix for homog 3"); MSG(tempmatrix); temppoint =homog3->GetCenter(); MSG("Center for homog 3"); MSG(temppoint); for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, manually computed point is not equal to output"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point: "); PrintPoint2D(outpoint1); MSG("Homogeneous Point 1: "); PrintHPoint2D(hpoint1); MSG("Homogeneous Point 2: "); PrintHPoint2D(hpoint2); MSG("Manually Calced Point 2: "); PrintPoint2D(outpoint2); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2=homog3->BackTransformPoint(outpoint1); tempmatrix=homog3->DeCenter(); MSG("Decentered Matrix for homog 3"); MSG(tempmatrix); for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, manually computed on decentered matrix is not equal to output"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point: "); PrintPoint2D(outpoint1); MSG("Homogeneous Point 1: "); PrintHPoint2D(hpoint1); MSG("Homogeneous Point 2: "); PrintHPoint2D(hpoint2); MSG("Manually Calced Point 2: "); PrintPoint2D(outpoint2); } MSG("Test complete "<ReCenter( point2 ); MSG("Recentering Matrix:"); testmatrix=homog3->ReCenter(matrix2,point2); MSG(testmatrix); MSG("Going back:"); for (unsigned int i=0;iReCenter(testmatrix,point3); MSG(testmatrix2); MSG( "Just changed the center to:" ); PrintPoint2D(point2); MSG( homog3 ); outpoint1a=homog3->TransformPoint(inpoint1); outpoint2a=homog3->BackTransformPoint(outpoint1a); flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same with new center"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Old Transformed Point: "); PrintPoint2D(outpoint1); MSG("New transformed Point: "); PrintPoint2D(outpoint1a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, backtransformed point is not the same with new center"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Point to backtransform: "); PrintPoint2D(outpoint1a); MSG("New Backtransformed Point: "); PrintPoint2D(outpoint2a); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2a=homog2->TransformPoint(outpoint1a); outpoint3a=homog2->BackTransformPoint(outpoint2a); outpoint4a=homog3->BackTransformPoint(outpoint3a); homog3->Compose(homog2); outpoint2b=homog3->TransformPoint(inpoint1); outpoint4b=homog3->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint2D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4b); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2a=homog3->TransformPoint(outpoint1a); outpoint3a=homog3->BackTransformPoint(outpoint2a); outpoint4a=homog2->BackTransformPoint(outpoint3a); homog3->Compose(homog2,1); outpoint2b=homog3->TransformPoint(inpoint1); outpoint4b=homog3->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint2D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4b); } MSG("Test complete "<GetParameters(); for(unsigned int i=0;iGetNumberOfParameters();i++) { params[i]+=i*0.1; } aff1->SetParameters(params); MSG("... Affine transform has parameters"<TransformPoint(inpoint1); outpoint2a=aff1->TransformPoint(outpoint1a); outpoint3a=aff1->BackTransformPoint(outpoint2a); outpoint4a=homog2->BackTransformPoint(outpoint3a); MSG("Composed result"); homog2->Compose(aff1); MSG(homog2); outpoint2b=homog2->TransformPoint(inpoint1); outpoint4b=homog2->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint2D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4b); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2a=homog2->TransformPoint(outpoint1a); outpoint3a=homog2->BackTransformPoint(outpoint2a); outpoint4a=aff1->BackTransformPoint(outpoint3a); homog2->Compose(aff1,TRUE); outpoint2b=homog2->TransformPoint(inpoint1); outpoint4b=homog2->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint2D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint2D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint2D(outpoint4b); } MSG("Test complete "<GetParameters(); if(homog2->GetNumberOfParameters()!=(dim+1)*(dim+1)-1) { any++; MSG("TEST FAILED: Get Number of parameters is incorrect"); } testmatrix=homog2->GetMatrix(); flag=0; unsigned int count=0; for(unsigned int i=0;iGetNumberOfParameters();i++) { params2[i]+=(i+1)*0.1; } homog2->SetParameters(params2); Homogeneous2DType::ParametersType params3=homog2->GetParameters(); flag=0; for(unsigned int i=0;iGetNumberOfParameters();i++) { if(params3[i]!=params2[i]) { flag++; } } if(flag) { any++; MSG("Test FAILED: parameters from get parameters do not agree with "); MSG("what was just set"); MSG("Parameters were just set to: "<GetInverseMatrix(); matrix2 = homog2->GetMatrix(); // try multiplying this inverse by the matrix, to see if it gives the identity testmatrix=matrix2*inverse2-idmatrix; sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, inverse times matrix not equal to identity"); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; } MSG("Test complete "<GetNumberOfParameters();i++) { params2[i]=paramvalues2D[i]; } homog2->SetCenter(pointJ); homog2->SetParameters(params2); Homogeneous2DType::JacobianType jacobian=homog2->GetJacobian(inpointJ); flag=0; for(unsigned int d=0;dGetNumberOfParameters();p++) { if(fabs(jacobian[d][p]-jacobianvalues2D[d][p])>0.0001) { flag++; } } } if(flag) { any++; MSG("Jacobian calculation failed"); MSG("Hand computed jacobian:"); for(unsigned int d=0;dGetNumberOfParameters();p++) { std::cout<GetTranslation(); tempmatrix=homog2->GetMatrix(); // Translation should be the upper right column flag=0; for(unsigned int d=0;d0.0001) { flag++; } } if(flag) { any++; MSG("GetTranslation failed()"); MSG("Matrix:"); MSG(tempmatrix); MSG("Translation reported:"); MSG(trans); } for(unsigned int d=0;dSetTranslation(trans); tempmatrix=homog2->GetMatrix(); // Translation should be the upper right column flag=0; for(unsigned int d=0;d0.0001) { flag++; } } if(flag) { any++; MSG("SetTranslation() failed()"); MSG("Matrix:"); MSG(tempmatrix); MSG("Translation reported:"); MSG(trans); } MSG("Test complete "<GetMatrix(); idpoint = id2->GetCenter(); std::cout << "Matrix from instantiating an identity transform:" << std::endl << idmatrix; std::cout << "Center from instantiating an identity transform:" << std::endl; PrintPoint3D( idpoint ); id2->SetIdentity(); testmatrix=(id2->GetMatrix())-idmatrix; double sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, either does not initialize to identity, or set identity broken"); } MSG("Test complete "<SetMatrix( matrix1 ); homog2->SetCenter( point2 ); MSG( "Instantiation of a given 3D transform:" ); MSG( homog2 ); inverse2 = homog2->GetInverseMatrix(); // try multiplying this inverse by the matrix, to see if it gives the identity testmatrix=matrix1*inverse2-idmatrix; sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, inverse times matrix not equal to identity"); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; } MSG("Test complete "<SetMatrix( matrix1 ); MSG( "Instantiated with center 0:" ); MSG( homog3 ); inverse2 = homog3->GetInverseMatrix(); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; MSG("Test complete "<Metric(homog3); b=homog3->Metric(homog2); MSG( "Metric 1-2:"<SetMatrix( matrix2 ); MSG( "Just changed the matrix of this one" ); MSG( homog3 ); inverse2 = homog3->GetInverseMatrix(); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; // try multiplying this inverse by the matrix, to see if it gives the identity testmatrix=matrix2*inverse2-idmatrix; sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, inverse times matrix not equal to identity"); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; } MSG("Test complete "<TransformPoint(inpoint1); outpoint2=homog3->BackTransformPoint(outpoint1); int flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point is not equal to input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point: "); PrintPoint3D(outpoint1); MSG("Backtransformed Point: "); PrintPoint3D(outpoint2); } tempmatrix=homog3->GetMatrix(); MSG("Matrix for homog 3"); MSG(tempmatrix); temppoint =homog3->GetCenter(); MSG("Center for homog 3"); MSG(temppoint); for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, manually computed point is not equal to output"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point: "); PrintPoint3D(outpoint1); MSG("Homogeneous Point 1: "); PrintHPoint3D(hpoint1); MSG("Homogeneous Point 2: "); PrintHPoint3D(hpoint2); MSG("Manually Calced Point 2: "); PrintPoint3D(outpoint2); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2=homog3->BackTransformPoint(outpoint1); tempmatrix=homog3->DeCenter(); MSG("Decentered Matrix for homog 3"); MSG(tempmatrix); for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, manually computed on decentered matrix is not equal to output"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point: "); PrintPoint3D(outpoint1); MSG("Homogeneous Point 1: "); PrintHPoint3D(hpoint1); MSG("Homogeneous Point 2: "); PrintHPoint3D(hpoint2); MSG("Manually Calced Point 2: "); PrintPoint3D(outpoint2); } MSG("Test complete "<ReCenter( point2 ); MSG("Recentering Matrix:"); testmatrix=homog3->ReCenter(matrix2,point2); MSG(testmatrix); MSG("Going back:"); for (unsigned int i=0;iReCenter(testmatrix,point3); MSG(testmatrix2); MSG( "Just changed the center to:" ); PrintPoint3D(point2); MSG( homog3 ); outpoint1a=homog3->TransformPoint(inpoint1); outpoint2a=homog3->BackTransformPoint(outpoint1a); flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same with new center"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Old Transformed Point: "); PrintPoint3D(outpoint1); MSG("New transformed Point: "); PrintPoint3D(outpoint1a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, backtransformed point is not the same with new center"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Point to backtransform: "); PrintPoint3D(outpoint1a); MSG("New Backtransformed Point: "); PrintPoint3D(outpoint2a); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2a=homog2->TransformPoint(outpoint1a); outpoint3a=homog2->BackTransformPoint(outpoint2a); outpoint4a=homog3->BackTransformPoint(outpoint3a); homog3->Compose(homog2); outpoint2b=homog3->TransformPoint(inpoint1); outpoint4b=homog3->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint3D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4b); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2a=homog3->TransformPoint(outpoint1a); outpoint3a=homog3->BackTransformPoint(outpoint2a); outpoint4a=homog2->BackTransformPoint(outpoint3a); homog3->Compose(homog2,TRUE); outpoint2b=homog3->TransformPoint(inpoint1); outpoint4b=homog3->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint3D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4b); } MSG("Test complete "<GetParameters(); for(unsigned int i=0;iGetNumberOfParameters();i++) { params[i]+=i*0.1; } aff1->SetParameters(params); MSG("... Affine transform has parameters"<TransformPoint(inpoint1); outpoint2a=aff1->TransformPoint(outpoint1a); outpoint3a=aff1->BackTransformPoint(outpoint2a); outpoint4a=homog2->BackTransformPoint(outpoint3a); MSG("Composed result"); homog2->Compose(aff1); MSG(homog2); outpoint2b=homog2->TransformPoint(inpoint1); outpoint4b=homog2->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint3D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4b); } MSG("Test complete "<TransformPoint(inpoint1); outpoint2a=homog2->TransformPoint(outpoint1a); outpoint3a=homog2->BackTransformPoint(outpoint2a); outpoint4a=aff1->BackTransformPoint(outpoint3a); homog2->Compose(aff1,TRUE); outpoint2b=homog2->TransformPoint(inpoint1); outpoint4b=homog2->BackTransformPoint(outpoint2b); // So now outpoint2a and 2b should be equal // outpoint4a and 4b should be equal to inpoint flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, transformed point is not the same when transform composed"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint2a); MSG("Transformed Point composed: "); PrintPoint3D(outpoint2b); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (two transforms) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4a); } flag=0; for (unsigned int i=0; itolerance) { flag++; } } if(flag) { any++; MSG("Test failed, back transformed point (composed) is not the same as input"); MSG("Input Point: "); PrintPoint3D(inpoint1); MSG("Transformed Point two transforms: "); PrintPoint3D(outpoint4b); } MSG("Test complete "<GetParameters(); if(homog2->GetNumberOfParameters()!=(dim+1)*(dim+1)-1) { any++; MSG("TEST FAILED: Get Number of parameters is incorrect"); } testmatrix=homog2->GetMatrix(); flag=0; unsigned int count=0; for(unsigned int i=0;iGetNumberOfParameters();i++) { params2[i]+=(i+1)*0.1; } homog2->SetParameters(params2); Homogeneous3DType::ParametersType params3=homog2->GetParameters(); flag=0; for(unsigned int i=0;iGetNumberOfParameters();i++) { if(params3[i]!=params2[i]) { flag++; } } if(flag) { any++; MSG("Test FAILED: parameters from get parameters do not agree with "); MSG("what was just set"); MSG("Parameters were just set to: "<GetInverseMatrix(); matrix2 = homog2->GetMatrix(); // try multiplying this inverse by the matrix, to see if it gives the identity testmatrix=matrix2*inverse2-idmatrix; sum=0.0; for (unsigned int i=0;itolerance) { any++; MSG("Test failed, inverse times matrix not equal to identity"); std::cout << "Inverse matrix for the given transform:" << std::endl << inverse2; } MSG("Test complete "<GetNumberOfParameters();i++) { params2[i]=paramvalues3D[i]; } homog2->SetCenter(pointJ); homog2->SetParameters(params2); Homogeneous3DType::JacobianType jacobian=homog2->GetJacobian(inpointJ); flag=0; for(unsigned int d=0;dGetNumberOfParameters();p++) { if(fabs(jacobian[d][p]-jacobianvalues3D[d][p])>0.0001) { flag++; } } } if(flag) { any++; MSG("Jacobian calculation failed"); MSG("Hand computed jacobian:"); for(unsigned int d=0;dGetNumberOfParameters();p++) { std::cout<GetTranslation(); tempmatrix=homog2->GetMatrix(); // Translation should be the upper right column flag=0; for(unsigned int d=0;d0.0001) { flag++; } } if(flag) { any++; MSG("GetTranslation failed()"); MSG("Matrix:"); MSG(tempmatrix); MSG("Translation reported:"); MSG(trans); } for(unsigned int d=0;dSetTranslation(trans); tempmatrix=homog2->GetMatrix(); // Translation should be the upper right column flag=0; for(unsigned int d=0;d0.0001) { flag++; } } if(flag) { any++; MSG("SetTranslation() failed()"); MSG("Matrix:"); MSG(tempmatrix); MSG("Translation reported:"); MSG(trans); } MSG("Test complete "<