[Insight-users] Rotation around x-axis wrong ?

Nic itk at fete.ch
Tue Aug 28 09:48:38 EDT 2007

Hello everybody,
    seems that there is a little error in my rotation around x.
If I construct a 3D image black with a single slice in the middle that is 
not black, and try to transform this stack through a versorigid3dtransform, 
rotations around y-axis and z-axis by 45° or 90° are ok, but not around 
Does someone see where there is an error in my quaternion ?

double RotX = angleX * vnl_math::pi / 180.0;
double RotY = angleY * vnl_math::pi / 180.0;
double RotZ = angleZ * vnl_math::pi / 180.0;
vnl_quaternion<double> Rx(vcl_sin(RotX/2.0), 0, 0, vcl_cos(RotX/2.0));
vnl_quaternion<double> Ry(0, vcl_sin(RotY/2.0), 0, vcl_cos(RotY/2.0));
vnl_quaternion<double> Rz(0, 0, vcl_sin(RotZ/2.0), vcl_cos(RotZ/2.0));
vnl_quaternion<double> RR = Rx * Ry * Rz;
//vnl_matrix_fixed<double,3,3> RMat = RR.rotation_matrix_transpose();
transform->SetRotation( rotation );
registration->SetInitialTransformParameters( transform->GetParameters() ); 

More information about the Insight-users mailing list