# How to rotate a plane around an axis by an angle

Hello,
I have a plane and I want to rotate that plane around an arbitrary axis by a specific angle.For my axis, I do have two points where I can define my axis A and B, and doesn’t start from the (0,0,0).
I try to generate my Rotation matrix I user https://en.wikipedia.org/wiki/Rotation_matrix#Axis_and_angle formula and a translation, but unfortunately, it is not working. Do you have any reccomendation?

Thanks

Hi @siaeleni -

You’ll find the formulas for this in computer graphics textbooks and presentations (this one for example looks right). The basic idea is to make a vtkMatrix4x4 for a linear transform node that is the concatenation of several operations. First translates one point of the line to the origin, then rotate the line to so it is on one of the main axes, then rotate around that axis and then apply the inverse rotations and translation. This should just be a series of matrix multiplies.

-Steve

1 Like

In the Slicer script repository there is a complete example of how to rotate a node around a line: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Rotate_a_node_around_a_specified_line

1 Like

Thanks a lot for your help!