[Insight-users] Euler3D transform, how to set the rotation matrix?

michiel mentink michael.mentink at st-hughs.ox.ac.uk
Tue Mar 9 11:59:42 EST 2010


I have 3 rotation angles, that I got from a registration algorithm.
rx = 0.0664    ry = -0.0625    rz = -0.0078
Now I would like to apply to rotation.

The Euler3D transform needs a rotation matrix. How can that matrix be
calculated?
This is what I've come up with so far, but it doesn't do anything:


  typedef itk::Euler3DTransform<double>TransformType2;
  TransformType2::Pointer transform2 =TransformType2::New();

// Rotation matrix:

//  Rx(θ)                x                y cos theta - z sin theta      z
cos theta + y sin theta
//  Ry(θ)     x cos theta + z sin theta                y                -x
sin theta + z cos theta
//  Rz(θ)     x cos theta - y sin theta    y cos theta + x sin theta
        z

  typedef itk::Matrix<double> MatrixType;
  MatrixType rotMatrix;

  //   column  row
  rotMatrix[0][0] = 1;
  rotMatrix[0][1] =  cos( atof(argv[7]) ) + sin( atof(argv[7]) );
  rotMatrix[0][2] =  cos( atof(argv[9]) ) - sin( atof(argv[9]) );

  rotMatrix[1][0] =  cos( atof(argv[7]) ) - sin( atof(argv[7]) );
  rotMatrix[1][1] = 1;
  rotMatrix[1][2] =  cos( atof(argv[7]) ) + sin( atof(argv[7]) );

  rotMatrix[2][0] =  cos( atof(argv[7]) ) + sin( atof(argv[7]) );
  rotMatrix[2][1] = -cos( atof(argv[7]) ) + sin( atof(argv[7]) );
  rotMatrix[2][2] = 1;

  transform->SetMatrix( rotMatrix);


I'm not to sure about the '1' entries too, since they should by x, y, or
z...

cheers,

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100309/041b02d0/attachment.htm>


More information about the Insight-users mailing list