[Insight-users] to understand quaternion versor and matrix in VersorRigid3DTransform

Luis Ibanez luis.ibanez at kitware.com
Fri Mar 20 15:03:29 EDT 2009


Hi Serena,


Thanks for your detailed question.


1) The Versor is a unit Quaternion.

    The reason why we can represent it with only three numbers
    (instead of the four in the quaternion) is that the fourth number
    is already determined by the requirement of the Versor norm
    to be == 1.0.

    This means that if you have a Versor of components x,y,z,
    the fourth component w is fully defined by:

             w^2 = 1.0 - x^2 - y^2 -  z^2

     It is therefore, perfectly normal to find that

                        x^2 + y^2 +  z^2  < 1.0

     what should never happen is:

                        x^2 + y^2 +  z^2  > 1.0


3) How to interpret a Versor ?

     Here is a practical way to do it:

        a) compute K = sqrt( x^2 + y^2 +  z^2  )

            K is equal to:  sin( theta / 2.0 )

           where theta is the angle of rotation.
           in other words:

                theta = 2.0 * asin( K )

      b) take the x,y,z components and divide
          them by K. That will  give you the unit
          vector parallel  to the rotation axis.

               Axis = (  x/K, y/K, z/K )

     In your particular case,

>  versor X      = -0.00431463
>  versor Y      = -0.00118787
>  versor Z      = 0.00404881
>

     K = 6.0349e-03

    therefore

      theta =  2.0 * math.asin( 6.0349e-03 ) [radians]

      theta = 0.01206 radians = 0.69 degrees


      Your Versor is not rotating around the Z axis.
      such rotation will have the x and y components
      equal to zero.

      Your axis of rotation has components:

              Ax =  -0.00431463  / K
              Ay = -0.00118787 / K
              Az =  0.00404881 / K


 3) The correct rotation matrix is the one in the PDF
     document of the Quaternions tutorial.

     You are correct in that *IF* your versor were
     rotating around the Z axis, then the rotation matrix
    will have the form:

             C   -S   0
             S    C   0
             0     0   1

      but, helas,... your versor is not rotating around Z.


So, I guess the background question is: Why lead you
to think that the versor was rotating around Z ?

or is this a requirement of the registration problem
that you are trying to solve ?


       Please let us know,

            Thanks


                  Luis



-----------------------------------------------------
On Fri, Mar 20, 2009 at 2:45 PM, Serena Fabbri <fabbri at u.washington.edu> wrote:
> Hi All,
>
> I have some questions about VersorRigid3DTransform, in particular about the
> versor and the matrix in the output.
> I am registering T2 and T1 image.
>
> FIX IMAGE: T2 size=(392, 512, 160)
> spacing=(0.5, 0.5, 1)mm
>
> MOVING IMAGE: T1
> size=(176, 256, 160)
> spacing=(1, 1, 1)mm
>
> I use
> VersorRigid3DTransform
> itkMattesMutualInformationImageToImageMetric
> itkVersorRigid3DTransformOptimizer
>
>
>
> I find this output:
>
>
> Result =
>  versor X      = -0.00431463
>  versor Y      = -0.00118787
>  versor Z      = 0.00404881
>
>  Translation X = -9.59506
>  Translation Y = -14.2873
>  Translation Z = 1.52361
>
>  Iterations    = 81
>  Metric value  = -0.204678
>
>
> Matrix = 0.999964 -0.00808722 -0.00241064
> 0.00810772 0.99993 0.00861949
> 0.00234077 -0.00863873 0.99996
>
> Offset = [-8.36679, -15.7562, 2.40158]
>
>
> The versor is a three first component of Quaternion.
>
> In http://en.wikipedia.org/wiki/Versor
> quaternion is:
> q = cos(T/2) + u sin(T/2)
>
> where u is a unit vector.
>
> I have calculated the norm of my versor and it is ||versor||= 6.0349e-03
> so it is not 1 !!!
>
> 1) so...what is the correct interpretation of versor in ITK?
>
> 2) In the Luis Ibanez email (Apr 7 2007) , he writes that the quaternion is:
>
>       q0 = Ax * sin( T / 2 )
>       q1 = Ay * sin( T / 2 )
>       q2 = Az * sin( T / 2 )
>       q3 =      cos( T / 2 )
>
> where (Ax,Ay,Az) are the components of the axis
> of rotation and T is the angle of rotation.
> Versors are composed of only the components
>
>          q0,q1,q2
>
>
> I am rotating around z axes so my A components are 0 0 1 and I get
> q2 = sinT/2 and I guess q2 = versorZ so my final rotation angle is 0.464
>  degrees Is this the rotation angle?
>
> 3)Is the rotation matrix  the matrix in slide n. 61 of
>  http://www.itk.org/CourseWare/Training/QuaternionsI.pdf   ?
>
> or it is the follow matrix:
> (to be cleare I am rotating around z axes)
>
> M=  cosT  sinT 0
>   -sinT  cosT 0
>      0     0  1
>
> because If you read the ITKSoftwareGuide pag.372, to calculate the final
> rotation angle, it is sufficiently to do arcsin(sinT).
>
>
> Thanks a lot for all explanation.
>
>
> Serena Fabbri
>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list