What works for us every time for solving such problems, without any trial and error, is the following process:
- Define all coordinate systems in your application: a short unique name, origin, axes unit, and axes directions. You can describe these in a table and it usually helps if you draw a sketch. See an example here. Your coordinate systems will be something like: InputVolumeIJK, InputVolumeLPS, AlignedVolumeLPS, SliceView.
- Name all your transforms consistently, as transforms between two coordinate systems (e.g., AtoBTransform). Just by looking at your coordinate system definitions, it should be always simple to determine transformation matrix between two coordinates systems. These pair of transforms will connect all your transforms in a graph.
- You can get transforms between any two coordinate systems by multiplying the transformation matrices that get you from one coordinate system to the other (this is where the sketch that you draw in the first step is particularly useful).