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

**URL:** <https://discourse.slicer.org/t/how-to-rotate-a-plane-around-an-axis-by-an-angle/10890>\
**Category:** Development\
**Created:** [March 28, 2020, 6:19pm UTC](https://discourse.slicer.org/t/how-to-rotate-a-plane-around-an-axis-by-an-angle/10890 "2020-03-28T18:19:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![siaeleni](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@siaeleni](https://discourse.slicer.org/u/siaeleni)\
**Post date:** [March 28, 2020, 6:19pm UTC](https://discourse.slicer.org/t/how-to-rotate-a-plane-around-an-axis-by-an-angle/10890/1 "2020-03-28T18:19:18Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [March 28, 2020, 7:45pm UTC](https://discourse.slicer.org/t/how-to-rotate-a-plane-around-an-axis-by-an-angle/10890/2 "2020-03-28T19:45:33Z")

</div>

Hi @siaeleni -

You’ll find the formulas for this in computer graphics textbooks and presentations ([this one](https://www.engr.uvic.ca/~mech410/lectures/4_2_RotateArbi.pdf) 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

---

<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:** [March 28, 2020, 9:49pm UTC](https://discourse.slicer.org/t/how-to-rotate-a-plane-around-an-axis-by-an-angle/10890/3 "2020-03-28T21:49:41Z")

</div>

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](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Rotate_a_node_around_a_specified_line)

---

<div class="post-metadata">

**Author:** ![siaeleni](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@siaeleni](https://discourse.slicer.org/u/siaeleni)\
**Post date:** [March 31, 2020, 12:05am UTC](https://discourse.slicer.org/t/how-to-rotate-a-plane-around-an-axis-by-an-angle/10890/4 "2020-03-31T00:05:01Z")

</div>

Thanks a lot for your help!
