[Insight-users] Quaternions and Euler rotations

Blezek, Daniel J (GE, Research) blezek at crd.ge.com
Fri Aug 24 08:37:10 EDT 2007


Hi Nic,
 
Here is some example code, it uses the vnl package included with Inisght.  RMat contians the 3x3 rotation matrix, while RR contains the initialized Quaternion.
 
      // Rotate!
      double RotX, RotY, RotZ;
      RotX = InitialRotation[0] * vnl_math::pi / 180.0;
      RotY = InitialRotation[1] * vnl_math::pi / 180.0;
      RotZ = InitialRotation[2] * 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();

-dan


________________________________

	From: insight-users-bounces+blezek=crd.ge.com at itk.org [mailto:insight-users-bounces+blezek=crd.ge.com at itk.org] On Behalf Of Nic
	Sent: Friday, August 24, 2007 7:12 AM
	To: Insight Users
	Subject: [Insight-users] Quaternions and Euler rotations
	
	
	Hello,
	    doing a 3D registration of two stacks as in example 8.6.1 and using itkVersorRigid3DTransform, I would like to calculate the 3 axis components and the angle of the Versor resulting from:
	    - a rotation of a certain angle around z-axis
	    - a 180°rotation around y-axis
	    - no rotation around x-axis
	
	This is because I would like to initialize my transform before launching.
	Does anyone have an idea how to calculate it ? Seems that I have to calculate Quaternions; trying to do it actually but I not really used with..
	Thx, nic
	 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070824/23f2c3ad/attachment.htm


More information about the Insight-users mailing list