<div>ahhhhhhhhh great!<br><br>I had misunderstood it. I thought that
the vtkTransformation somehow would take the spacing into account...of
course it cannot as it knows nothing about the input data...<br><br>Thanks again. cannot wait to try it tomorrow.
<br><br>Best wishes,<br></div><div><span class="sg"><br>Anja</span></div><br><br><div><span class="gmail_quote">On 19/09/06, <b class="gmail_sendername">David Gobbi</b> <<a href="mailto:dgobbi@atamai.com">dgobbi@atamai.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Anja Ende wrote:<br>> Hi David,<br>><br>> Thanks for the explanation. I totally missed the postmultiply order.
<br>> So basically, this affects the order in which the transformations are<br>> put on the stack, right?<br><br>Basically yes, if you are thinking about the way glMultMatrix() works.<br>But vtk transforms don't use a stack the same way that OpenGL does, so
<br>"stack" isn't quite the right word.<br><br>> Also, back to the original question... It should be then enough to<br>> provide the actual pixel values as translation values.<br><br>No, that is the opposite of what I meant in my previous email. The
<br>transformation must take the pixel spacing into account. So if your<br>pixel spacing is measured in millimeters, then you must give a<br>translation in millimeters.<br><br>> So, if you imagine that I have a volume that has the dimensions: 256 X
<br>> 256 X 120 and I want to traslate to 100, 100, 50... and then rotate<br>> 30 degrees...<br>><br>> I should have:<br>><br>> myTransform->PostMultiply();<br>> myTransform->Translate(100, 100, 50);
<br>> myTransform->RotateX(30);<br>> myTransform->Translate(-100, -100, -50);<br><br>First you have to translate the image so that voxel (100, 100, 50) ends<br>up at the origin, which means that the translation must be in the
<br>negative direction. Taking the Origin and Spacing of the image into<br>account, you need this transformation if you want to rotate by 30<br>degrees around that voxel:<br><br>myTransform->postMultiply();<br>myTransform->Translate(-(Origin[0] + Spacing[0]*100), -(Origin[1] +
<br>Spacing[1]*100), -(Origin[2] + Spacing[2]*50));<br>myTransform->RotateX(30);<br> etcetera<br><br>In VTK, transformations work in terms of physical coordinates, not in<br>terms of voxels.<br><br> - David<br><br><br>
<br>><br>> Cheers and many thanks,<br>> Anja<br>><br>><br>> On 19/09/06, * David Gobbi* <<a href="mailto:dgobbi@atamai.com">dgobbi@atamai.com</a><br>> <mailto:<a href="mailto:dgobbi@atamai.com">
dgobbi@atamai.com</a>>> wrote:<br>><br>> Hi Anja,<br>><br>> When you use vtkTransform with vtk image data, it takes the<br>> Spacing and<br>> Origin of the data into account.<br>>
<br>> You have to be careful about the PreMultiply(), PostMultiply()<br>> state of<br>> the transform, though. These are two vtkTransform methods that<br>> you use<br>> to control whether the rotation, translations, etc. that you apply
<br>> to a<br>> vtkTransform should occur before, or after the transformation already<br>> represented by the vtkTransform.<br>><br>> For example: let's say that you have a vtkTransform whose matrix
<br>> is M.<br>><br>> If you do transform->PostMultiply(), and then perform a rotation R<br>> (where R is a 4x4 matrix), then the new matrix value M for the<br>> transform<br>> will be given by the following equation:
<br>><br>> M = R M (the new M is the product of matrices R and the old value<br>> of M)<br>><br>> If you do transform->PreMultiply() (or if you do nothing, since<br>> PreMultiply is the default):
<br>><br>> M = M R (the transforms are applied in the opposite order)<br>><br>><br>> The way to think about this is that in PostMultiply mode, any new<br>> rotation, translations etc. that you do occur after any rotations,
<br>> translations, etc. that you have already done.<br>><br>><br>> So if you want to translate and then rotate, make sure you are in<br>> PostMultiply() or you will end up with a vtkTransform that
<br>> performs the<br>> rotation first and the translation second...<br>><br>> - David<br>><br>><br>><br>> Anja Ende wrote:<br>> > Hi everyone,<br>> ><br>> > Another qustion... I am really having a bad day...
<br>> ><br>> > Been trying to play with the vtkTransform object and want to do the<br>> > following operations...<br>> ><br>> > Translate->Rotate->Translate back...<br>
> ><br>> > I am getting a bit hairy results... Are the translate parameters<br>> > expressed in actual physical units... i.e . taking the spacing into<br>> > account...<br>> >
<br>> > For example, I have an image data set that is centered using<br>> > vtkImageChangeInformation and I want to move to pixel (x, y) on a<br>> > particular slice (n) and then rotate 30 degrees around the X
<br>> axes. How<br>> > does one go about doing these operations?<br>> ><br>> > Any small code/pseudo code would be awesome!<br>> ><br>> > Thanks,<br>> > Anja
<br>> ><br>> ------------------------------------------------------------------------<br>><br>> ><br>> > _______________________________________________<br>> > This is the private VTK discussion list.
<br>> > Please keep messages on-topic. Check the FAQ at:<br>> <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a> <<a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ
</a>><br>> > Follow this link to subscribe/unsubscribe:<br>> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>> ><br>><br>>
<br><br></blockquote></div><br>