<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> &lt;<a href="mailto:dgobbi@atamai.com">dgobbi@atamai.com
</a>&gt; 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>&gt; Hi David,<br>&gt;<br>&gt; Thanks for the explanation. I totally missed the postmultiply order.
<br>&gt; So basically, this affects the order in which the transformations are<br>&gt; 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>&quot;stack&quot; isn't quite the right word.<br><br>&gt; Also, back to the original question... It should be then enough to<br>&gt; provide the actual pixel values as translation values.<br><br>No, that is the opposite of what I meant in my previous email.&nbsp;&nbsp;The
<br>transformation must take the pixel spacing into account.&nbsp;&nbsp;So if your<br>pixel spacing is measured in millimeters, then you must give a<br>translation in millimeters.<br><br>&gt; So, if you imagine that I have a volume that has the dimensions: 256 X
<br>&gt; 256 X 120 and I want to traslate to 100, 100,&nbsp;&nbsp;50... and then rotate<br>&gt; 30 degrees...<br>&gt;<br>&gt; I should have:<br>&gt;<br>&gt; myTransform-&gt;PostMultiply();<br>&gt; myTransform-&gt;Translate(100, 100, 50);
<br>&gt; myTransform-&gt;RotateX(30);<br>&gt; myTransform-&gt;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.&nbsp;&nbsp;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-&gt;postMultiply();<br>myTransform-&gt;Translate(-(Origin[0] + Spacing[0]*100), -(Origin[1] +
<br>Spacing[1]*100), -(Origin[2] + Spacing[2]*50));<br>myTransform-&gt;RotateX(30);<br>&nbsp;&nbsp;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>&gt;<br>&gt; Cheers and many thanks,<br>&gt; Anja<br>&gt;<br>&gt;<br>&gt; On 19/09/06, * David Gobbi* &lt;<a href="mailto:dgobbi@atamai.com">dgobbi@atamai.com</a><br>&gt; &lt;mailto:<a href="mailto:dgobbi@atamai.com">
dgobbi@atamai.com</a>&gt;&gt; wrote:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Hi Anja,<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; When you use vtkTransform with vtk image data, it takes the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Spacing and<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Origin of the data into account.<br>&gt;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; You have to be careful about the PreMultiply(), PostMultiply()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; state of<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; the transform, though.&nbsp;&nbsp;These are two vtkTransform methods that<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; you use<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; to control whether the rotation, translations, etc. that you apply
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; to a<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; vtkTransform should occur before, or after the transformation already<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; represented by the vtkTransform.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; For example: let's say that you have a vtkTransform whose matrix
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; is M.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; If you do transform-&gt;PostMultiply(), and then perform a rotation R<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; (where R is a 4x4 matrix), then the new matrix value M for the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; transform<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; will be given by the following equation:
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; M = R M&nbsp;&nbsp;(the new M is the product of matrices R and the old value<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; of M)<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; If you do transform-&gt;PreMultiply() (or if you do nothing, since<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; PreMultiply is the default):
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; M = M R (the transforms are applied in the opposite order)<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; The way to think about this is that in PostMultiply mode, any new<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; rotation, translations etc. that you do occur after any rotations,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; translations, etc. that you have already done.<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; So if you want to translate and then rotate, make sure you are in<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; PostMultiply() or you will end up with a vtkTransform that
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; performs the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; rotation first and the translation second...<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; - David<br>&gt;<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Anja Ende wrote:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Hi everyone,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Another qustion... I am really having a bad day...
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Been trying to play with the vtkTransform object and want to do the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; following operations...<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Translate-&gt;Rotate-&gt;Translate back...<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; I am getting a bit hairy results... Are the translate parameters<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; expressed in actual physical units... i.e . taking the spacing into<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; account...<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; For example, I have an image data set that is centered using<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; vtkImageChangeInformation and I want to move to pixel (x, y) on a<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; particular slice (n) and then rotate 30 degrees around the X
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; axes. How<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; does one go about doing these operations?<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Any small code/pseudo code would be awesome!<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Thanks,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Anja
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; ------------------------------------------------------------------------<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; _______________________________________________<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; This is the private VTK discussion list.
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Please keep messages on-topic. Check the FAQ at:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a> &lt;<a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ
</a>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Follow this link to subscribe/unsubscribe:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;<br>&gt;
<br><br></blockquote></div><br>