Difference between revisions of "Transformation matrix"

From MIPAV
Jump to: navigation, search
m (created the page)
 
m
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page is stub.
+
This page is a stub.
 +
 
 +
For more information, refer to:
 +
 
 +
* [http://mipav.cit.nih.gov/documentation/api/gov/nih/mipav/model/structures/TransMatrix.html|MIPAV API - Transformation matrix]
 +
 
 +
* [http://mipav.cit.nih.gov/documentation/HTML%20Algorithms/Transform.html| MIPAV Transform]
 +
 
 +
* [[Transform]]
 +
 
 +
== Background ==
 +
 
 +
Transformation matrix class is an affine homogeneous class that can be used to rotate objects like images and VOIs. It can constructed as a 2D(3x3) or 3D(4x4) homogeneous matrix for transform (rotation, translation, skew and zoom) images/VOIs. Skew is not commonly used.
 +
 
 +
The MIPAV 3D model for 4 X 4 transformations is:
 +
 
 +
        [ m00 m01 m02 m03 ]  [ x ]  [ x' ]
 +
        [ m10 m11 m12 m13 ] . [ y ] = [ y' ]
 +
        [ m20 m21 m22 m23 ]  [ z ]  [ z' ]
 +
        [ m30 m31 m32 m33 ]  [ w ]  [ w' ]
 +
 +
        x' = m00*x + m01*y + m02*z + m03*w
 +
        y' = m10*x + m11*y + m12*z + m13*w
 +
        z' = m20*x + m21*y + m22*z + m23*w
 +
        w' = m30*x + m31*y + m32*z + m33*w
 +
 +
 
 +
However, because the transform type is limited, we can always set the third row to [ 0 0 0 1] and write instead:
 +
 
 +
        [ m00 m01 m02 ]  [ x ]  [ t0 ]  [ x' ]
 +
        [ m10 m11 m12 ] . [ y ] + [ t1 ] = [ y' ]
 +
        [ m20 m21 m22 ]  [ z ]  [ t2 ]  [ z' ]
 +
 +
        x' = m00*x + m01*y + m02*z + t0
 +
        y' = m10*x + m11*y + m12*z + t1
 +
        z' = m20*x + m21*y + m22*z + t2
 +
 +
 
 +
We still represent 4x4 m with a WildMagic Matrix4f, because of the existing implementations that assume a 4x4 matrix, and the use of the upper 3x3 matrix as a 2D transform.
 +
 
 +
We considered representing m with a WildMagic Matrix3f, and t with a Vector3f, as encapsulated in the WildMagic Transformation class, but it does not match typical Mipav usage.
 +
 
 +
ORDER OF TRANSFORMATIONS = TRANSLATE, ROTATE, ZOOM or TRANSLATE, ROTATE, SKEW, ZOOM
 +
Row, Col format - right hand rule
 +
2D Example
 +
 
 +
          zoom_x    theta    tx
 +
          theta    zoom_y  ty
 +
          0        0        1
 +
represented in 3D by leaving Z the identity transform:
 +
          zoom_x    theta    0    tx
 +
          theta    zoom_y  0    ty
 +
          0        0        1    0
 +
          0        0        0    1
 +
 
 +
 +
 
 +
Note that for 2D, the tx and ty components are stored in M02 and M12, and not in M03 and M13, as might be guessed by the use of a Matrix4f to store both 2D and 3D transforms.
 +
 
 +
Note for 3D - ref. Foley, Van Dam p. 214
 +
 
 +
          Axis of rotation            Direction of positive rotation is
 +
              x                              y to z
 +
              y                              z to x
 +
              z                              x to y
 +
 +
 
 +
          Order of rotation is important (i.e. not commutative)
 +
          Rx Ry Ry != Ry Rx Rz
 +
 +
 +
 +
 
  
 
[[Category:Help]]
 
[[Category:Help]]
 
[[Category:Help:Stub]]
 
[[Category:Help:Stub]]

Latest revision as of 12:35, 24 October 2012

This page is a stub.

For more information, refer to:

Background

Transformation matrix class is an affine homogeneous class that can be used to rotate objects like images and VOIs. It can constructed as a 2D(3x3) or 3D(4x4) homogeneous matrix for transform (rotation, translation, skew and zoom) images/VOIs. Skew is not commonly used.

The MIPAV 3D model for 4 X 4 transformations is:

        [ m00 m01 m02 m03 ]   [ x ]   [ x' ]
        [ m10 m11 m12 m13 ] . [ y ] = [ y' ]
        [ m20 m21 m22 m23 ]   [ z ]   [ z' ]
        [ m30 m31 m32 m33 ]   [ w ]   [ w' ]

        x' = m00*x + m01*y + m02*z + m03*w
        y' = m10*x + m11*y + m12*z + m13*w
        z' = m20*x + m21*y + m22*z + m23*w
        w' = m30*x + m31*y + m32*z + m33*w

However, because the transform type is limited, we can always set the third row to [ 0 0 0 1] and write instead:

        [ m00 m01 m02 ]   [ x ]   [ t0 ]   [ x' ]
        [ m10 m11 m12 ] . [ y ] + [ t1 ] = [ y' ]
        [ m20 m21 m22 ]   [ z ]   [ t2 ]   [ z' ]

        x' = m00*x + m01*y + m02*z + t0
        y' = m10*x + m11*y + m12*z + t1
        z' = m20*x + m21*y + m22*z + t2

We still represent 4x4 m with a WildMagic Matrix4f, because of the existing implementations that assume a 4x4 matrix, and the use of the upper 3x3 matrix as a 2D transform.

We considered representing m with a WildMagic Matrix3f, and t with a Vector3f, as encapsulated in the WildMagic Transformation class, but it does not match typical Mipav usage.

ORDER OF TRANSFORMATIONS = TRANSLATE, ROTATE, ZOOM or TRANSLATE, ROTATE, SKEW, ZOOM Row, Col format - right hand rule 2D Example

         zoom_x    theta    tx
         theta     zoom_y   ty
         0         0         1
represented in 3D by leaving Z the identity transform:
         zoom_x    theta    0    tx
         theta     zoom_y   0    ty
         0         0        1    0
         0         0        0    1


Note that for 2D, the tx and ty components are stored in M02 and M12, and not in M03 and M13, as might be guessed by the use of a Matrix4f to store both 2D and 3D transforms.

Note for 3D - ref. Foley, Van Dam p. 214

         Axis of rotation            Direction of positive rotation is
             x                               y to z
             y                               z to x
             z                               x to y

         Order of rotation is important (i.e. not commutative)
         Rx Ry Ry != Ry Rx Rz