[Insight-users] Quaternions and Euler rotations

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


Hi Nic,
 
  Here's a good quaternion tutorial: http://www.itk.org/CourseWare/Training/QuaternionsI.pdf  I think you might want to read this first.  Versors are unit quaternions, i.e., they can't represent scaling.  You can set a itk::Versor using a vnl_quaternion -- http://www.itk.org/Doxygen/html/classitk_1_1Versor.html for documentation.
 
  From a quaternion, you can get the axis and angle as:
 
  RR.axis()
 
  RR.angle()
 
http://www.lems.brown.edu/vision/vxl_doc/html/core/vnl/html/classvnl__quaternion.html


________________________________

	From: Nic [mailto:itk at fete.ch] 
	Sent: Friday, August 24, 2007 10:26 AM
	To: Blezek, Daniel J (GE, Research)
	Subject: Re: [Insight-users] Quaternions and Euler rotations
	
	
	Ok, thx ! :)
	So, if I understand well, in my example:
	- RotX would be 0
	- RotY would be Pi
	- and RotZ an angle in radians
	
	But what about the angle of the versor I have to set for the rotation ? How do I compute it ?
	
	In my code now :
	
	axis[0] = RR[0];
	axis[1] = RR[1];
	axis[2] = RR[2];
	
	
	rotation.Set( axis, angleVersor);
	transform->SetRotation( rotation );
	registration->SetInitialTransformParameters( transform->GetParameters() );
	
	By the way, what is the rule you employ for setting your quaternion like this ? Or do you have a ressource on the web where it is explained how it works ?
	I never heard before about Quaternion, thus it's a bit new for me :)
	 
	 
	 
	 
	
	----- Original Message ----- 
	From: Blezek, Daniel J (GE, Research) 
	To: Nic ; ITK 
	Sent: Friday, August 24, 2007 2:37 PM
	Subject: RE: [Insight-users] Quaternions and Euler rotations
	
	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/11b08358/attachment.htm


More information about the Insight-users mailing list