Actor Rotation Operation around itself


You mentioned that you are having a problem with the rotation operation and that you have looked at similar problems on forums but have not been able to find a solution. I am here to help you solve your problem.


You want the actor to rotate around its own axis in a desired way.

Attempted Methods:

  1. Transformation:
  • You have used the RotateX, RotateY, and RotateZ functions with values of 45, 60, and 90 degrees, respectively.
  • When you set the Y, Z, and X values to 0 in sequence, the actor does not return to its original state.
cur_angles = actor.get_rotate_angles()
transform = vtkTransform()
if axis == "x":
    cur_angles[0] = angle
if axis == "y":
    cur_angles[1] = angle
if axis == "z":
    cur_angles[2] = angle

  1. Orientation:
  • In this method, the rotations made in sequence affect each other.
current_orientation = actor.GetOrientation()
if axis == "x":
    actor.SetOrientation(angle, current_orientation[1], current_orientation[2])
if axis == "y":
    actor.SetOrientation(current_orientation[0], angle, current_orientation[2])
if axis == "z":
    actor.SetOrientation(current_orientation[0], current_orientation[1], angle)
  1. Quaternion:
  • Here, I can perform the rotation as desired. However, I can’t revert it back to its original state. When I try to rotate it by 45 degrees, it rotates by around 2-3 degrees instead.
transform = vtkTransform()
quat = vtkQuaterniond()
radian_angle = np.deg2rad(angle)
if axis == "x":
    quat.SetRotationAngleAndAxis(radian_angle, [1, 0, 0])
if axis == "y":
    quat.SetRotationAngleAndAxis(radian_angle, [0, 1, 0])
if axis == "z":
    quat.SetRotationAngleAndAxis(radian_angle, [0, 0, 1])

transform.RotateWXYZ(quat.GetW(), quat.GetX(), quat.GetY(), quat.GetZ())

i want to make this video rotate operation