Rotating Slice around Axis of Model

Despite compositing matrices is a really simple operation (you just have to get the order of the matrices right and invert them as needed), you may easily spend a couple of days figuring out the correct combination.

We’ve found that a very good way of getting the correct solution quickly is following these steps:

  1. Define each coordinate system: what is the unit (mm, pixel, …), where is the origin, what are the coordinate system axis directions. It also helps if you draw a sketch of the origin position and axis directions relative to physical objects. See an example in Plus toolkit’s user manual.

  2. Name each transformation as a transformation from coordinate system A to B as AToB (you may add Transform or Matrix suffix to make it even more clear that it is a transform). For example, SliceToRAS is a well-defined transformation. newResliceMatrix and registrationMatrix names are not usable because they don’t specify what coordinate systems they are transforming between and in what order.

  3. Create chain of matrices using the following rules:

  • AToC = BToC * AToB
  • AToB = inv(BToA)

Alternatively, in some simple cases when you need to place a slice view to a based on a position and a normal vector, you may also find vtkMRMLSliceNode::SetSliceToRASByNTP method useful. See how it is used for rotating slice views in ValveView module.

For real-time positioning of a slice view using a transform, use VolumeResliceDriver module of SlicerIGT extension.

1 Like