[Insight-users] set rotation for VersorRigid3DTransform along each axis

soosho esteghamat at fastmail.fm
Sat Oct 20 06:59:30 EDT 2007


Hi Dear Soosho

You can convert "euler angles" to "quaternion" which described below:

http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

you can use the following code too:

------------------------------------------------------------
typedef VersorType::VectorType     VectorType;
VersorType     rotation;
double quaternion[4];

quaternion[0] = cos(xRot/2.0)*cos(yRot/2.0)*cos(zRot/2.0) + 
                      sin(xRot/2)*sin(yRot/2)*sin(zRot/2); 
quaternion[1] = sin(xRot/2.0)*cos(yRot/2.0)*cos(zRot/2.0) - 
                      cos(xRot/2)*sin(yRot/2)*sin(zRot/2);
quaternion[2] = cos(xRot/2.0)*sin(yRot/2)*cos(zRot/2.0) + 
                       sin(xRot/2)*cos(yRot/2)*sin(zRot/2);
quaternion[3] = cos(xRot/2.0)*cos(yRot/2)*sin(zRot/2.0) - 
                      sin(xRot/2)*sin(yRot/2)*cos(zRot/2); 

rotation.Set( quaternion[0], quaternion[1], quaternion[2], quaternion[3]
);
transform->SetRotation( rotation );
-----------------------------------------------------------

Regards,
Soosho



You should first convert 
On Fri, 19 Oct 2007 23:52:16 -0700, "soosho" <esteghamat at fastmail.fm>
said:
> Hi All
> 
> Thanks a lot for your helps.
> 
> I am trying to initialized rotation parameters of a
> 'VersorRigid3DTransform' via 'SetRotation'. I want to set 3 non-zero
> rotation around each axis. But as it seemed to me there exist just three
> method which is listed below.
> 
>   SetRotation (const AxisType &axis, AngleType angle)
>   SetRotation (const VersorType &versor)
>   SetRotationMatrix (const MatrixType &matrix)
> 
> Also as I found the first two methods just can represent rotation along
> just one axis, so the alternative would be the third one. I am not
> familiar with quaternion matrixes. How can I exert these rotations?
> 
> Thanks,
> Soosho
> -- 
>   soosho
>   esteghamat at fastmail.fm
> 
> -- 
> http://www.fastmail.fm - Same, same, but different

> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
-- 
  soosho
  esteghamat at fastmail.fm

-- 
http://www.fastmail.fm - The way an email service should be



More information about the Insight-users mailing list