[vtkusers] vtkTransform question

David Gobbi dgobbi at atamai.com
Tue Sep 19 14:57:08 EDT 2006


Hi Anja,

When you use vtkTransform with vtk image data, it takes the Spacing and 
Origin of the data into account.

You have to be careful about the PreMultiply(), PostMultiply() state of 
the transform, though.  These are two vtkTransform methods that you use 
to control whether the rotation, translations, etc. that you apply to a 
vtkTransform should occur before, or after the transformation already 
represented by the vtkTransform.

For example: let's say that you have a vtkTransform whose matrix is M.

If you do transform->PostMultiply(), and then perform a rotation R 
(where R is a 4x4 matrix), then the new matrix value M for the transform 
will be given by the following equation:

 M = R M  (the new M is the product of matrices R and the old value of M)

If you do transform->PreMultiply() (or if you do nothing, since 
PreMultiply is the default):

 M = M R (the transforms are applied in the opposite order)


The way to think about this is that in PostMultiply mode, any new 
rotation, translations etc. that you do occur after any rotations, 
translations, etc. that you have already done.


So if you want to translate and then rotate, make sure you are in 
PostMultiply() or you will end up with a vtkTransform that performs the 
rotation first and the translation second...

 - David



Anja Ende wrote:
> Hi everyone,
>
> Another qustion... I am really having a bad day...
>
> Been trying to play with the vtkTransform object and want to do the 
> following operations...
>
> Translate->Rotate->Translate back...
>
> I am getting a bit hairy results... Are the translate parameters 
> expressed in actual physical units... i.e. taking the spacing into 
> account...
>
> For example, I have an image data set that is centered using 
> vtkImageChangeInformation and I want to move to pixel (x, y) on a 
> particular slice (n) and then rotate 30 degrees around the X axes. How 
> does one go about doing these operations?
>
> Any small code/pseudo code would be awesome!
>
> Thanks,
> Anja
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   




More information about the vtkusers mailing list