# Rotation around y axe

**URL:** <https://discourse.slicer.org/t/rotation-around-y-axe/9062>\
**Category:** Support\
**Tags:** virtual-reality\
**Created:** [November 7, 2019, 3:02pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062 "2019-11-07T15:02:45Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://discourse.slicer.org/u/alexk)\
**Post date:** [November 7, 2019, 3:02pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/1 "2019-11-07T15:02:45Z")

</div>

Hi, I’m using SlicerVirtualReality with HTC Vive Pro.  
I wish to rotate my scene and an object around its axis “y” to have a circular view of my object.  
I can not do it using the controllers.  
Is it possible ? Can you help me ?  
Alex

---

<div class="post-metadata">

**Author:** ![aiden.zhu](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aiden.zhu/32/67145_2.png) [@aiden.zhu](https://discourse.slicer.org/u/aiden.zhu)\
**Post date:** [November 7, 2019, 3:35pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/2 "2019-11-07T15:35:55Z")

</div>

Hi Alex,  
If you play with python code, it’s easy to do it.

```
  slicer.util.setSliceViewerLayers(background = imgNode)
  transform = []
  rot_angle = 45
  transform = vtk.vtkTransform()
  transform.RotateWXYZ(0, rot_angle, 0, 1)  
  transformNode = slicer.mrmlScene.AddNode(slicer.vtkMRMLTransformNode())
  transformNode.ApplyTransform(transform)
  imgNode.SetAndObserveTransformNodeID(transformNode.GetID())

```

Hope it helps.

---

<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:** [November 7, 2019, 4:03pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/3 "2019-11-07T16:03:45Z")

</div>

> [@alexk](#):
>
> I can not do it using the controllers

Do you mean it is inconvenient to rotate the scene around using [two-handed gestures](https://github.com/KitwareMedical/SlicerVirtualReality#how-to-use-controllers), or you don’t know how to rotate the scene?

---

<div class="post-metadata">

**Author:** ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://discourse.slicer.org/u/alexk)\
**Post date:** [November 7, 2019, 4:33pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/4 "2019-11-07T16:33:36Z")

</div>

Yes, it is inconvenient using two handed gestures.

I tried to make several movements with controllers but I can only rotate around the Z axis (the object turns as needles).

I would like to rotate it around the y axis (horizontal movement)

---

<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:** [November 7, 2019, 5:32pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/5 "2019-11-07T17:32:01Z")

</div>

Have you tried both these methods?

- rotating the scene (using two-handed gestures; making the object non-selectable in Data module to ensure that you don’t accidentally grab the object)
- rotating the object (grab the object by reaching inside with one hand, rotating it, then taking over to the other hand to rotate it further)

You can also rotate the object to a view that you would like to see in virtual reality and click “Set virtual reality view to match reference view” button on the toolbar.

---

<div class="post-metadata">

**Author:** ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://discourse.slicer.org/u/alexk)\
**Post date:** [November 8, 2019, 9:36am UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/6 "2019-11-08T09:36:59Z")

</div>

Thanks for your answer.

Yes, i have already tried these methods.

I wish to be able to see my scene of face then rotation to see it in right profile but also to be able to see it from below. The goal is to have a rotation in traveling.  
The actual manipulation that I make only allows me to turn the scene like clockwise.

---

<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:** [November 8, 2019, 12:53pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/7 "2019-11-08T12:53:19Z")

</div>

Sorry, for me it is still not clear what would you like to achieve. Can you send a video of your virtual reality view so that we can see what you do now, and annotate a few still frames so that we can understand what would you like to do differently?

---

<div class="post-metadata">

**Author:** ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://discourse.slicer.org/u/alexk)\
**Post date:** [November 10, 2019, 12:03pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/8 "2019-11-10T12:03:34Z")

</div>

Hello, I just want to do a horizontal or vertical rotation like this in Slicer Virtual Reality using the controllers.

Alex

Le ven. 8 nov. 2019 à 14:03, Andras Lasso via 3D Slicer Community [slicer@discoursemail.com](mailto:slicer@discoursemail.com) a écrit :

(Attachment Rotation.mov is missing)

---

<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:** [November 10, 2019, 12:48pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/9 "2019-11-10T12:48:15Z")

</div>

The attachment did not come through. Please try to upload via the web interface of discourse.

In virtual reality view, you can rotate the object or rotate the world (move around the object). Rotating the object around its own center is easier to implement: you can [apply a linear transform](https://www.slicer.org/wiki/Documentation/Nightly/Modules/Transforms#Examples) and set the desired rotation matrix in it.

---

<div class="post-metadata">

**Author:** ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://discourse.slicer.org/u/alexk)\
**Post date:** [November 12, 2019, 9:27pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/10 "2019-11-12T21:27:15Z")

</div>

Thank you very much. I tried to make a rotation of object but it is not around its axis but of the center of the rest of the skull.

Here is a video of what I get and what I want for virtual reality : [https://filedn.com/lMEY7FuuJRLkh9f4Jtgk5ez/Test%20zygomatic%20bone.mov](https://filedn.com/lMEY7FuuJRLkh9f4Jtgk5ez/Test%20zygomatic%20bone.mov).

How to do ?

Alex

Le dim. 10 nov. 2019 à 13:58, Andras Lasso via 3D Slicer Community [slicer@discoursemail.com](mailto:slicer@discoursemail.com) a écrit :

---

<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:** [November 14, 2019, 2:45pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/11 "2019-11-14T14:45:48Z")

</div>

You can construct a transformation matrix that rotates around an arbitrary point by multiplying 3 transforms: translate center of rotation to origin, rotate, translate origin to center of rotation.

---

<div class="post-metadata">

**Author:** ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://discourse.slicer.org/u/alexk)\
**Post date:** [November 19, 2019, 1:52pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/12 "2019-11-19T13:52:11Z")

</div>

Thanks for your answer. I do not know how to create an arbitrary point of rotation and then do the 3 proposed transformations. Is there a tutorial to do this type of transformation?

Alex

Le jeu. 14 nov. 2019 à 15:55, Andras Lasso via 3D Slicer Community [slicer@discoursemail.com](mailto:slicer@discoursemail.com) a écrit :

---

<div class="post-metadata">

**Author:** ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://discourse.slicer.org/u/alexk)\
**Post date:** [November 27, 2019, 10:58pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/13 "2019-11-27T22:58:49Z")

</div>

Hello mr Lasso, I have not managed to find a solution to change the point of rotation in arbitrary position and make the transformations. Can you tell if there is a tutorial available.

I thank you in advance

---

<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:** [November 27, 2019, 11:23pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/14 "2019-11-27T23:23:57Z")

</div>

See for example these pages:

- [https://www.euclideanspace.com/maths/geometry/affine/aroundPoint/](https://www.euclideanspace.com/maths/geometry/affine/aroundPoint/)
- [https://math.stackexchange.com/questions/2093314/rotation-matrix-of-rotation-around-a-point-other-than-the-origin](https://math.stackexchange.com/questions/2093314/rotation-matrix-of-rotation-around-a-point-other-than-the-origin)

---

<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:** [December 5, 2019, 3:09pm UTC](https://discourse.slicer.org/t/rotation-around-y-axe/9062/15 "2019-12-05T15:09:13Z")

</div>

I’ve now added an example script in the script repository for rotating about arbitrary centerpoint - see details here: [Transform and rotation](https://discourse.slicer.org/t/transform-and-rotation/9398/3)
