18 #include <itkVector.h>
24 itk::Vector<double,3> point;
25 point[0] = rotationVector[0];
26 point[1] = rotationVector[1];
27 point[2] = rotationVector[2];
33 itk::Matrix<double,3,3> rotMatrixA;
34 for(
int i=0; i<3; i++)
for(
int j=0; j<3; j++) rotMatrixA[i][j] = a.rotation_matrix_transpose().transpose()[i][j];
36 itk::Matrix<double,3,3> rotMatrixB;
37 for(
int i=0; i<3; i++)
for(
int j=0; j<3; j++) rotMatrixB[i][j] = b.rotation_matrix_transpose().transpose()[i][j];
39 itk::Vector<double,3> pt1 = rotMatrixA * point;
40 itk::Vector<double,3> pt2 = rotMatrixB * point;
42 returnValue = (pt1[0]*pt2[0]+pt1[1]*pt2[1]+pt1[2]*pt2[2]) / ( sqrt(pow(pt1[0],2.0)+pow(pt1[1],2.0)+pow(pt1[2],2.0)) * sqrt(pow(pt2[0],2.0)+pow(pt2[1],2.0)+pow(pt2[2],2.0)));
43 returnValue = acos(returnValue) * 57.296;
50 itk::Vector<double,3> rotationVector = itk::Vector<double,3>();
51 rotationVector[0] = 0;
52 rotationVector[1] = 0;
53 rotationVector[2] = 1000;
54 return GetAngleBetweenTwoQuaterions(a,b,rotationVector);
59 double PI = 3.141592653589793;
60 alpha = alpha * PI / 180;
61 beta = beta * PI / 180;
62 gamma = gamma * PI / 180;
65 itk::Matrix<double,3,3> matrix;
82 matrix[0][0] = cos(beta) * cos(alpha);
83 matrix[0][1] = cos(beta) * sin(alpha);
84 matrix[0][2] = -sin(beta);
86 matrix[1][0] = sin(gamma) * sin(beta) * cos(alpha) - cos(gamma) * sin(alpha) ;
87 matrix[1][1] = sin(gamma) * sin(beta) * sin(alpha) + cos(gamma) * cos(alpha);
88 matrix[1][2] = sin(gamma) * cos(beta);
90 matrix[2][0] = cos(gamma) * sin(beta) * cos(alpha) + sin(gamma) * sin(alpha);
91 matrix[2][1] = cos(gamma) * sin(beta) * sin(alpha) - sin(gamma) * cos(alpha);
92 matrix[2][2] = cos(gamma) * cos(beta);
99 if (imageFiducials->GetSize() != realWorldFiducials->GetSize())
return -1;
101 for (
int i = 0; i < imageFiducials->GetSize(); i++)
103 itk::Point<double> current_image_fiducial_point = imageFiducials->GetPoint(i);
104 if (transform != NULL)
106 current_image_fiducial_point = transform->TransformPoint(imageFiducials->GetPoint(i)[0], imageFiducials->GetPoint(i)[1], imageFiducials->GetPoint(i)[2]);
108 double cur_error_squared = current_image_fiducial_point.SquaredEuclideanDistanceTo(realWorldFiducials->GetPoint(i));
109 FRE += cur_error_squared;
112 FRE = sqrt(FRE / (
double)imageFiducials->GetSize());
const mitk::ScalarType PI
vnl_quaternion< ScalarType > Quaternion
static itk::Matrix< double, 3, 3 > ConvertEulerAnglesToRotationMatrix(double alpha, double beta, double gamma)
static double GetAngleBetweenTwoQuaterions(mitk::Quaternion a, mitk::Quaternion b, itk::Vector< double, 3 > rotationVector)
static double ComputeFRE(mitk::PointSet::Pointer imageFiducials, mitk::PointSet::Pointer realWorldFiducials, vtkSmartPointer< vtkLandmarkTransform > transform=NULL)
Computes the fiducial registration error out of two sets of fiducials. The two sets must have the sam...