# Rotating around specific point

**URL:** https://discourse.vtk.org/t/rotating-around-specific-point/15433
**Category:** Development
**Created:** [March 26, 2025, 1:36pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433 "2025-03-26T13:36:35Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![sapvi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sapvi/32/9874_2.png) [@sapvi](https://discourse.vtk.org/u/sapvi)
#### Post date: [March 26, 2025, 1:36pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/1 "2025-03-26T13:36:35Z")

</div>

Hi all.

I have `self.picker = vtk.vtkPointPicker()` to select the point in the point cloud. And I would like to be able by double-click on some point, make this point center of the rotation WITHOUT shifting the camera so that the selected point is in the center of the viewport. I have the following function:

```auto
def _on_point_click(self, obj, event):
        click_position = self.interactor.GetEventPosition()
        self.picker.Pick(click_position[0], click_position[1], 0, self.renderer)
        if self.picker.GetPointId() != -1:
            coords = self.picker.GetPickPosition()        
            self.renderer.GetActiveCamera().SetFocalPoint(coords)

```

Of course, that one indeed allows to use the selected point as the rotation BUT at the same time all view is moved so that the new focal point is in the center of the view.

Is there way to avoid this or it is somehow against some basic VTK design?

I have seem this solution → [c++ - How to rotate a vtk scene around a specific point? - Stack Overflow](https://stackoverflow.com/questions/43046798/how-to-rotate-a-vtk-scene-around-a-specific-point)  
But it is 8 years old and, well, honestly looks a bit of an overkill for a relative simple(?) feature.  
Is this indeed the way I should I use, and just translate it to tools I am using (Python & pyside6)? Or there is some way to do it in the VTK itself? Thanks.

---

<div class="post-metadata">

### Author: ![rexthor](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rexthor/32/6481_2.png) [@rexthor](https://discourse.vtk.org/u/rexthor)
#### Post date: [March 28, 2025, 1:05pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/2 "2025-03-28T13:05:58Z")

</div>

The second-ranked answer seems quite reasonable (in your SO link). Just set the focal point on the `vtkCamera` object. I haven’t tried though.

---

<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: [March 28, 2025, 5:56pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/3 "2025-03-28T17:56:35Z")

</div>

Hello,

It seems overkill but to rotate an object about a random position, you need, first to translate the object to the origin, apply the rotation and then translate it back to the former position. This is how computational geometry works.

best,

PC

---

<div class="post-metadata">

### Author: ![sapvi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sapvi/32/9874_2.png) [@sapvi](https://discourse.vtk.org/u/sapvi)
#### Post date: [March 29, 2025, 6:17pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/4 "2025-03-29T18:17:14Z")

</div>

> [@rexthor](#):
>
> The second-ranked answer seems quite reasonable (in your SO link). Just set the focal point on the `vtkCamera` object. I haven’t tried though.

As written in the comments to that answer as well, it also shifts the view so that the chosen point is in the center of the viewport.

---

<div class="post-metadata">

### Author: ![sapvi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sapvi/32/9874_2.png) [@sapvi](https://discourse.vtk.org/u/sapvi)
#### Post date: [March 29, 2025, 6:20pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/5 "2025-03-29T18:20:16Z")

</div>

Mathematically, indeed. But I was hoping for a more built-in support for this functionality since it is pretty common in multiple 3D viewers (CloudCompare, for example). But if there is nothing available in VTK itself, I guess the only way is to implement this workaround indeed.

---

<div class="post-metadata">

### Author: ![metamurk](https://discourse.vtk.org/user_avatar/discourse.vtk.org/metamurk/32/9665_2.png) [@metamurk](https://discourse.vtk.org/u/metamurk)
#### Post date: [March 30, 2025, 12:16pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/6 "2025-03-30T12:16:46Z")

</div>

You have to implement it by yourselfin your camera model. I post my java code doing this as an example:

```auto

 /**
     * Rotates the camera by mouse move delta values.
     * 
     * @param x the delta
     * @param y the delta
     * @param speedFactor
     */
    public void rotateCameraByDelta( int x, int y, float speedFactor ) {

        double scale = Norm( cam.GetPosition() );
        if ( scale <= 0.0 ) {
            scale = Norm( cam.GetFocalPoint() );
            if ( scale <= 0.0 ) {
                scale = 1.0;
            }
        }

        double[] temp = cam.GetFocalPoint();
        double[] fp = cam.GetFocalPoint();
        cam.SetFocalPoint( temp[0] / scale, temp[1] / scale, temp[2] / scale );
        temp = cam.GetPosition();
        cam.SetPosition( temp[0] / scale, temp[1] / scale, temp[2] / scale );

        // translate to center
        rotTransform.Identity();
        rotTransform.Translate( COR.x / scale, COR.y / scale, COR.z / scale );

        // azimuth
        cam.OrthogonalizeViewUp();
        double[] viewUp = cam.GetViewUp();
        int[] size = renderer.GetSize();
        Vector3d up = new Vector3d( viewUp[0], viewUp[1], viewUp[2] );
        rotTransform.RotateWXYZ( 360.0 * x * speedFactor / size[0], up.x, up.y, up.z );

        // elevation
        Vector3d v2 = new Vector3d();
        Vector3d projDir = new Vector3d( cam.GetDirectionOfProjection()[0], cam.GetDirectionOfProjection()[1], cam.GetDirectionOfProjection()[2] );

        v2.cross( projDir, up );
        rotTransform.RotateWXYZ( -360.0 * y * speedFactor / size[1], v2.x, v2.y, v2.z );

        // translate back
        rotTransform.Translate( -COR.x / scale, -COR.y / scale, -COR.z / scale );

        applyTransform( rotTransform );
        cam.OrthogonalizeViewUp();

        // For rescale back.
        temp = cam.GetFocalPoint();
        cam.SetFocalPoint( temp[0] * scale, temp[1] * scale, temp[2] * scale );
        temp = cam.GetPosition();
        cam.SetPosition( temp[0] * scale, temp[1] * scale, temp[2] * scale );

        double[] pos = new double[3];
        pos[0] = temp[0] * scale;
        pos[1] = temp[1] * scale;
        pos[2] = temp[2] * scale;

        viewportVTK.resetCameraClippingRange();
        if ( !isCam )
            Engine.INSTANCE.getViewportManager().updateCamera( pos, fp );
    }

```

applyTransfrom applies everything on the camera.

---

<div class="post-metadata">

### Author: ![sapvi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sapvi/32/9874_2.png) [@sapvi](https://discourse.vtk.org/u/sapvi)
#### Post date: [March 31, 2025, 1:06pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/7 "2025-03-31T13:06:09Z")

</div>

> [@metamurk](#):
>
> You have to implement it by yourselfin your camera model.

Thank you!

I just always try to check if something already exist hidden somewhere in the package, before I start implementing myself.

---

<div class="post-metadata">

### Author: ![sophia](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@sophia](https://discourse.vtk.org/u/sophia)
#### Post date: [October 29, 2025, 3:52am UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/8 "2025-10-29T03:52:01Z")

</div>

hello,

thank you for your sharing, i want to develop the function “rotating around specfic point” , i have a question about the code you share, in this line “rotTransform.Translate( COR.x / scale, COR.y / scale, COR.z / scale );“ the word “COR“ is what? how should i get?

look forward your reply, thank you~

best,

sophia.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 29, 2025, 8:52am UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/9 "2025-10-29T08:52:58Z")

</div>

FYI ParaView has a [https://www.paraview.org/paraview-docs/v5.12.0/cxx/classvtkPVRotateAroundOriginTransform.html](https://www.paraview.org/paraview-docs/v5.12.0/cxx/classvtkPVRotateAroundOriginTransform.html)

---

<div class="post-metadata">

### Author: ![metamurk](https://discourse.vtk.org/user_avatar/discourse.vtk.org/metamurk/32/9665_2.png) [@metamurk](https://discourse.vtk.org/u/metamurk)
#### Post date: [November 3, 2025, 4:58pm UTC](https://discourse.vtk.org/t/rotating-around-specific-point/15433/10 "2025-11-03T16:58:56Z")

</div>

COR is Center of Rotation. The point as vector3 you want to rotate on…
