Rotation angle of Z-axis


I have an itk::Transform (specifically an itk::AffineTransform). I would like to know how much this transform rotates the Z-axis - i.e. the angle between (0,0,1) and the result of applying the transform to (0,0,1).

What is the most straight forward way to calculate this? Apply the transform and then calculate the dot product of the result with (0,0,1)? I feel like I am missing a more obvious way.

Applying the transform is the easiest way, and it works for all the transform types.

1 Like

Hello @spinicist,

As you are interested in the effect of the transform on the vector [0,0,1], all you need to do is grab the third column of the matrix returned from GetMatrix(), A_3. The cosine of the angle is A_3[3]/norm(A_3) , using 1 based indexing here.

1 Like

Thanks both @dzenanz and @zivy, I think I have something working now here: