<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3157" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff background="">
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2>Hi Nic,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2> Here's a good quaternion tutorial: <A
href="http://www.itk.org/CourseWare/Training/QuaternionsI.pdf">http://www.itk.org/CourseWare/Training/QuaternionsI.pdf</A>
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 -- <A
href="http://www.itk.org/Doxygen/html/classitk_1_1Versor.html">http://www.itk.org/Doxygen/html/classitk_1_1Versor.html</A> for
documentation.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2> From a quaternion, you can get the axis and angle
as:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2> RR.axis()</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2> RR.angle()</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=140595014-24082007><FONT face=Arial
color=#0000ff size=2><A
href="http://www.lems.brown.edu/vision/vxl_doc/html/core/vnl/html/classvnl__quaternion.html">http://www.lems.brown.edu/vision/vxl_doc/html/core/vnl/html/classvnl__quaternion.html</A></FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Nic [mailto:itk@fete.ch]
<BR><B>Sent:</B> Friday, August 24, 2007 10:26 AM<BR><B>To:</B> Blezek, Daniel
J (GE, Research)<BR><B>Subject:</B> Re: [Insight-users] Quaternions and Euler
rotations<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>Ok, thx ! :)<BR>So, if I understand well, in my
example:</FONT></DIV>
<DIV><FONT face=Arial size=2>- RotX would be 0</FONT></DIV>
<DIV><FONT face=Arial size=2>- RotY would be Pi</FONT></DIV>
<DIV><FONT face=Arial size=2>- and RotZ an angle in radians</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT
face=Arial size=2></FONT><BR><FONT face=Arial size=2>But what about the <FONT
color=#ff0000><STRONG>angle of the versor</STRONG></FONT> I have to set for
the rotation ? How do I compute it ?<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>In my code now :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT
face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR><FONT face=Arial
color=#008000 size=2><STRONG>axis[0] = RR[0];<BR>axis[1] = RR[1];<BR>axis[2] =
RR[2];</STRONG></FONT></DIV><FONT face=Arial size=2></FONT><FONT face=Arial
size=2></FONT>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR><FONT
face=Arial size=2>rotation.Set( <FONT
color=#008000><STRONG>axis</STRONG></FONT>, <FONT
color=#ff0000><STRONG>angleVersor</STRONG></FONT>);<BR>transform->SetRotation(
rotation );<BR>registration->SetInitialTransformParameters(
transform->GetParameters() );<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>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 ?</FONT></DIV>
<DIV><FONT face=Arial><FONT size=2>I never heard before about Quaternion, thus
it's a bit new for me :)</FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT size=2><FONT
size=+0> </DIV></FONT></FONT></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT><BR><FONT face=Arial size=2>----- Original
Message ----- <BR>From: Blezek, Daniel J (GE, Research) <BR>To: Nic ; ITK
<BR>Sent: Friday, August 24, 2007 2:37 PM<BR>Subject: RE: [Insight-users]
Quaternions and Euler rotations<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Hi Nic,<BR><BR>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.<BR><BR> //
Rotate!<BR> double RotX, RotY,
RotZ;<BR> RotX = InitialRotation[0] *
vnl_math::pi / 180.0;<BR> RotY =
InitialRotation[1] * vnl_math::pi / 180.0;<BR>
RotZ = InitialRotation[2] * vnl_math::pi /
180.0;<BR> vnl_quaternion<double>
Rx(vcl_sin(RotX/2.0), 0, 0,
vcl_cos(RotX/2.0));<BR>
vnl_quaternion<double> Ry(0, vcl_sin(RotY/2.0), 0,
vcl_cos(RotY/2.0));<BR>
vnl_quaternion<double> Rz(0, 0, vcl_sin(RotZ/2.0),
vcl_cos(RotZ/2.0));<BR><BR>
vnl_quaternion<double> RR = Rx * Ry *
Rz;<BR> vnl_matrix_fixed<double,3,3> RMat
= RR.rotation_matrix_transpose();<BR><BR>-dan<BR><BR><BR><BR>From:
insight-users-bounces+blezek=crd.ge.com@itk.org
[mailto:insight-users-bounces+blezek=crd.ge.com@itk.org] On Behalf Of
Nic<BR>Sent: Friday, August 24, 2007 7:12 AM<BR>To: Insight Users<BR>Subject:
[Insight-users] Quaternions and Euler
rotations<BR><BR><BR>Hello,<BR> 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:<BR> - a rotation of a certain angle around
z-axis<BR> - a 180°rotation around
y-axis<BR> - no rotation around x-axis<BR>This is because I
would like to initialize my transform before launching.<BR>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..<BR>Thx,
nic</FONT></DIV></BLOCKQUOTE></BODY></HTML>