[vtkusers] vtkImageReslice rotation when not about center of image.

David Gobbi david.gobbi at gmail.com
Wed Oct 26 11:51:44 EDT 2016

Hi Rick,

I cannot recommend using SetResliceAxesOrigin() to set the center of
rotation.  Instead, it's best to build the 4x4 matrix that does the
transformation that you need, and call SetResliceAxes(matrix).

For rotation around a point, you need a matrix that translates the
center-of-rotation to (0,0,0), applies a rotation about (0,0,0), and then
translates back again.

 - David

On Tue, Oct 25, 2016 at 10:30 AM, Richard Frank <rickfrank at me.com> wrote:

> Hi
> I'm trying to modify the vtkExample to use vtkImageReslice about a point
> not at the center of the volume.
> A link to my code is below, which is the Cxx folder from the Imaging
> Examples, with modifications to the ImageSlicing sub project.
> https://1drv.ms/f/s!AvWAuQy-GUrmgyOyOKmDWSHhZUPk
> Also, here is a link to my input data, a small mha file which is easy to
> see:
> https://1drv.ms/u/s!AvWAuQy-GUrmg0YOY0ql2vr1StOU
> if you load the file, you will see an axial view. The volume has an origin
> of (0,0,0). I compute the center of the volume, and then position the actor
> on that center point (actors are positioned by the center point).
> This is analogous to what our application under development does - we
> position the slice actor in world coordinates using the DICOM Image
> Position Patient at the top left (depending on orientation) + center offset
> of the volume.
> In my example code, when you load up for the first time and left click,
> and "rotate" with the mouse, I draw an angle widget for your convenience
> whose joint is on the center of rotation. I compute the matrix for the
> rotation, and set that in the reslice matrix, followed by  the origin. This
> works perfectly, and the slice rotates about its center.
> If you right click, you will change the ctr of rotation in world
> coordinates.
> ImageReslice->SetResliceAxesOrigin(rotationCenter[0], rotationCenter[1],
> rotationCenter[2]);
> When you then rotate with left mouse, the angle widget joint is in the
> correct place in the view but  the the image rotates about a point which I
> can't quite determine.
> The new center of rotation that the reslice uses seem to be proportionally
> related to how far away from the center of the image that is right clicked
> on - the closer to the center of the slice clicked, the less the center of
> rotation moves away from the click.
> It seems like there's something I'm missing about how the center of
> rotation works.
> Any help appreciated.
> Thanks
> Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161026/5c6da3f2/attachment.html>

More information about the vtkusers mailing list