# Rotation in a strict axis

**URL:** https://discourse.vtk.org/t/rotation-in-a-strict-axis/13081
**Category:** Support
**Created:** [January 16, 2024, 3:40pm UTC](https://discourse.vtk.org/t/rotation-in-a-strict-axis/13081 "2024-01-16T15:40:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![abrahamezzeddine](https://discourse.vtk.org/user_avatar/discourse.vtk.org/abrahamezzeddine/32/8263_2.png) [@abrahamezzeddine](https://discourse.vtk.org/u/abrahamezzeddine)
#### Post date: [January 16, 2024, 3:40pm UTC](https://discourse.vtk.org/t/rotation-in-a-strict-axis/13081/1 "2024-01-16T15:40:10Z")

</div>

Hello

I am wondering if there exists some kind of method with vtk to limit the rotation on an object, say point cloud to strictly to one axis when for example dragging left to right and up to down?

The problem is that when I am rotating, is that after a short rotation, the whole object has rotated in both x and y which is undesirable.

If I am dragging to the left, then I only want to rotate the x axis around itself, and the same thing for Y. But with current vtk implementation, both rotates at the same time so I have to correct the rotation with the ctrl+mouse drag every time.

Or do I have to create my own functions for this and read the mouse movements to where I am dragging?

Thank you.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 17, 2024, 3:54pm UTC](https://discourse.vtk.org/t/rotation-in-a-strict-axis/13081/2 "2024-01-17T15:54:23Z")

</div>

Hello,

One way to do it is by overriding`[vtkInteractorStyleTrackballCamera](https://vtk.org/doc/nightly/html/classvtkInteractorStyleTrackballCamera.html)’s callback methods to implement the behavior you want. Here is an example on how to derive it: [gammaray/viewer3d/v3dmouseinteractor.h at master · PauloCarvalhoRJ/gammaray · GitHub](https://github.com/PauloCarvalhoRJ/gammaray/blob/master/viewer3d/v3dmouseinteractor.h) and [gammaray/viewer3d/v3dmouseinteractor.cpp at master · PauloCarvalhoRJ/gammaray · GitHub](https://github.com/PauloCarvalhoRJ/gammaray/blob/master/viewer3d/v3dmouseinteractor.cpp). Here is the source code of said methods: [VTK/Interaction/Style/vtkInteractorStyleTrackballCamera.cxx at master · Kitware/VTK · GitHub](https://github.com/Kitware/VTK/blob/master/Interaction/Style/vtkInteractorStyleTrackballCamera.cxx) . Maybe copy, paste and modify the ones you need in your derived class to suit your objectives.

regards,

PC
