How to set the center of vtkactor autobiography?

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

Hello, friend,

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



yes! Do you have any suggestions?


Please, take a look at this example: .

take care,


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->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

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

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
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

1 Like