# How to set the center of vtkactor autobiography？

**URL:** https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071
**Category:** Support
**Tags:** proposal
**Created:** [June 25, 2021, 7:34am UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071 "2021-06-25T07:34:18Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [June 25, 2021, 7:34am UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/1 "2021-06-25T07:34:19Z")

</div>

How to set the center of vtkActor autobiography when I moved the translate the actor？

---

<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: [June 25, 2021, 8:39pm UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/2 "2021-06-25T20:39:32Z")

</div>

Hello, friend,

Do you mean to set the center of vtkActor automatically when you move (translate) the actor with the mouse?

cheers,

Paulo

---

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [June 28, 2021, 12:53am UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/3 "2021-06-28T00:53:53Z")

</div>

yes! Do you have any suggestions?

---

<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: [June 29, 2021, 12:36pm UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/4 "2021-06-29T12:36:28Z")

</div>

Hi,

Please, take a look at this example: [https://kitware.github.io/vtk-examples/site/Cxx/Visualization/MoveActor](https://kitware.github.io/vtk-examples/site/Cxx/Visualization/MoveActor) .

take care,

Paulo

---

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [June 30, 2021, 7:52am UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/5 "2021-06-30T07:52:54Z")

</div>

I have read this code,and run it.But it is not what i want. I want to rotate the actor around a specify 3D point.  
And I have tried the SetOrigin() of vtkActor which say:"  
/\*\*

- Set/Get the origin of the Prop3D. This is the point about which all
- rotations take place.  
\*/  
"

the code like this:  
virtual void SetOrigin(double x, double y, double z)  
{  
vtkDebugMacro(\<\< this-\>GetClassName() \<\< " (" \<\< this \<\<  
“): setting Origin to (” \<\< x \<\< “,” \<\< y \<\< “,” \<\<  
z \<\< “)”);  
if ((this-\>Origin[0] != x)||  
(this-\>Origin[1] != y)||  
(this-\>Origin[2] != z))  
{  
this-\>Origin[0] = x;  
this-\>Origin[1] = y;  
this-\>Origin[2] = z;  
this-\>Modified();  
this-\>IsIdentity = 0;  
}  
};

But it is not the result! Someone say it must be:

1. Move prop to the origin;

2. Zoom;

3. Rotate around the y-axis;

4. Rotate around the x-axis;

5. Rotate around Z axis;

6. Move back to the original position from the origin;

7. Translation

---

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [June 30, 2021, 11:47am UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/6 "2021-06-30T11:47:17Z")

</div>

Sorry！ I forgot to say it is a stl file.

---

<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: [July 11, 2021, 12:10pm UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/7 "2021-07-11T12:10:12Z")

</div>

Hello, friend,

Sorry for the late response. What you’ve been told is somewhat correct since setting its origin is not enough, but it less complicated than that.

The sequence of operations is:

- Translate object to origin;
- Apply rotation;
- Reverse the translation;

Any complex linear transform can be expressed a multiplication of matrices. The sequence of operations is expressed in reverse order:  
Y = T-1RT  
Where:  
Y: the final rotation around a point matrix that you want.  
T and T-1: the translation matrix and its inverse.  
R: the rotation around the origin matrix.

Then, to rotate your object around a point, simply do X\* = YX, where X is the vector of input coordinates (a matrix with a single column with the x, y, z values) and X\* is the transformed coordinates.

Now to some code. VTK does all that math for you. After setting its center, you can rotate an actor about one of the main axes with `actor->RotateX(45);` for example to rotate about the local X axis by 45º.

If you want to rotate an actor in world coordinates, you can do `actor->RotateWXYZ(45, 1, 0, 0)` to rotate the actor by 45º about the global X axis.

I hope this helps,

Paulo

---

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [July 14, 2021, 11:27am UTC](https://discourse.vtk.org/t/how-to-set-the-center-of-vtkactor-autobiography/6071/8 "2021-07-14T11:27:18Z")

</div>

> [@Paulo\_Carvalho](#):
>
> mplex linear transform can be expressed a multiplication of matrices. The sequence of operations is expressed in reverse order:  
> Y = T-1RT  
> Where:  
> Y: the final rotation around a point matrix that you want.  
> T and T-1: the translation matrix and its inverse.  
> R: the rotation around the origin matrix.
> 
> Then, to rotate your object around a point, simply do X\* = YX, where X is the vector of input coordinates (a matrix with a single column with the x, y, z values) and X\* is the transformed coordinates.
> 
> Now to some code. VTK does all that math for you. After setting its center, you can rotate an actor about one of the main axes with `actor->RotateX(45);` for example to rotate about the local X axis by 45º.
> 
> If you want to rotate an actor in world coordinates, you can do `actor->RotateWXYZ(45, 1, 0, 0)` to rotate the actor by 45º about the global X axis.
> 
> I hope this helps,

thank you very much!,it is ok
