# Rotating Slice around Axis of Model

**URL:** https://discourse.slicer.org/t/rotating-slice-around-axis-of-model/916
**Category:** Development
**Tags:** registration
**Created:** [August 21, 2017, 9:18pm UTC](https://discourse.slicer.org/t/rotating-slice-around-axis-of-model/916 "2017-08-21T21:18:06Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [August 22, 2017, 2:12am UTC](https://discourse.slicer.org/t/rotating-slice-around-axis-of-model/916/2 "2017-08-22T02:12:28Z")

</div>

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](http://perk-software.cs.queensu.ca/plus/doc/nightly/user/CommonCoordinateSystems.html).

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](http://apidocs.slicer.org/master/classvtkMRMLSliceNode.html#a0e8251eb55cfb40e316c2e22894b140c) method useful. See how it is used for [rotating slice views in ValveView module](https://github.com/SlicerHeart/SlicerHeart/blob/master/ValveView/ValveView.py).

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

---

_[View the full topic](https://discourse.slicer.org/t/rotating-slice-around-axis-of-model/916)._
