[vtkusers] vtkTransform question

Anja Ende anja.ende at googlemail.com
Tue Sep 19 15:44:53 EDT 2006


Hi David,

Thanks for the explanation. I totally missed the postmultiply order. So
basically, this affects the order in which the transformations are put on
the stack, right?

Also, back to the original question... It should be then enough to provide
the actual pixel values as translation values.

So, if you imagine that I have a volume that has the dimensions: 256 X 256 X
120 and I want to traslate to 100, 100,  50... and then rotate 30 degrees...

I should have:

myTransform->PostMultiply();
myTransform->Translate(100, 100, 50);
myTransform->RotateX(30);
myTransform->Translate(-100, -100, -50);

Cheers and many thanks,
Anja


On 19/09/06, David Gobbi <dgobbi at atamai.com> wrote:
>
> 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
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060919/52188885/attachment.htm>


More information about the vtkusers mailing list