# SetOrigin do not work for actor with trackball interactor style

**URL:** https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476
**Category:** Support
**Created:** [January 17, 2023, 3:09am UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476 "2023-01-17T03:09:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [January 17, 2023, 3:09am UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/1 "2023-01-17T03:09:30Z")

</div>

I am using `vtkInteractorStyleTrackballActor` with `Spin` method.

For `Spin` method, the actor would rotate along the actor center.

How can I change the rotation center? Does `actor.SetOrigin` work? The explanation of `SetOrigin` is:

```auto
Set/Get the origin of the Prop3D. This is the point about which all rotations take place.

```

However, when I use `actor.SetOrigin`, the `Spin` still rotate along the actor center.

The demo code is:

```auto

import vtkmodules.all as vtk

cylinder = vtk.vtkCylinderSource()
cylinder.Update()

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(cylinder.GetOutput())

actor = vtk.vtkActor()
actor.SetMapper(mapper)

bounds = actor.GetBounds()
xmin, xmax, ymin, ymax, zmin, zmax = bounds
actor.SetOrigin(xmin, ymin, zmin) ############################# change the origin
render = vtk.vtkRenderer()
render.AddActor(actor)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
renWin.Render()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballActor())
iren.Initialize()
iren.Start()

```

Use `ctrl+left mouse press and move` to trigger `Spin` method.

Any suggestion is appreciated~~~

---

<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, 2023, 5:28pm UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/2 "2023-01-17T17:28:52Z")

</div>

Hello,

What happens if you do `actor.SetOrigin(1000, 1000, 1000)`?

best,

Paulo

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [January 20, 2023, 3:38pm UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/3 "2023-01-20T15:38:18Z")

</div>

> [@Paulo\_Carvalho](#):
>
> What happens if you do `actor.SetOrigin(1000, 1000, 1000)`?

It still rotate along the actor center even using `actor.SetOrigin(1000, 1000, 1000)` when spin.

---

<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 20, 2023, 9:54pm UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/4 "2023-01-20T21:54:20Z")

</div>

Ok. Please, add a 2nd actor with origin at (100, 100, 100), perform a rotation and report the result here.

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [January 21, 2023, 8:30am UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/5 "2023-01-21T08:30:08Z")

</div>

The 2nd actor is:

```auto
cone = vtk.vtkConeSource()
cone.SetCenter(3, 3, 3)

```

After `coneActor.SetOrigin(100, 100, 100)`, the `coneActor` and `cylinderActor` always rotate along each actor center when `spin` happen.

---

<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 21, 2023, 7:44pm UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/6 "2023-01-21T19:44:26Z")

</div>

Then I believe you need to use `SetCenter()` to achieve the effect you want.

---

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhang-qiang-github/32/2519_2.png) [@zhang-qiang-github](https://discourse.vtk.org/u/zhang-qiang-github)
#### Post date: [January 22, 2023, 1:37am UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/7 "2023-01-22T01:37:22Z")

</div>

But `vtkActor` do not have `SetCenter` method.

---

<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: [February 3, 2023, 9:21pm UTC](https://discourse.vtk.org/t/setorigin-do-not-work-for-actor-with-trackball-interactor-style/10476/8 "2023-02-03T21:21:51Z")

</div>

Hello,

> [@zhang-qiang-github](#):
>
> But `vtkActor` do not have `SetCenter` method.

I meant this:

> [@zhang-qiang-github](#):
>
> `cone.SetCenter(3, 3, 3)`

Right?

best,

Paulo
