How to use vtkMRMLCameraNode RotateAround and RotateTo?

I´ve been trying to manage camera rotation around a focal point but I can´t find the right parameter to send.

RotateAround needs RASAxis and bool or angle. I have test without succes

camera = slicer.mrmlScene.GetNodeByID(‘vtkMRMLCameraNode1’)
camera.RotateAround(‘R’,20)

and

camera = slicer.mrmlScene.GetNodeByID(‘vtkMRMLCameraNode1’)
camera.RotateAround(0,20)

TypeError: ambiguous call, multiple overloaded methods match the arguments

Same problem as with “RotateTo”

I´ve found enums for parameters but I don´t know how to use them:

image image

Thanks on advance!

Camera always rotates around the camera’s focal point. If you want to rotate around a different point then probably the easiest is to compute the new camera position, focal point, and ViewUp vector and set them in the camera.

I’m looking for exactly this camera behavior by I can’t make it work from those methods. I’m sure I’m doing something wrong with syntaxis…

Which behavior you are referring to? What would you like to achieve?

VTK’s built-in camera rotation methods can only rotate around the focal point, which is the position the camera looks at (in the center of the field of view).

I want to look at something (fiducial point for example) from any position and rotate camera 180º in all axes to see it from de opposite side.

Something like:

def LookAtFiducial(self, currentFid):
position = [0,0,0]
self.fiducial = self.fiducialNode()
self.fiducial.GetNthFiducialPosition(currentFid,position)
camera = slicer.mrmlScene.GetNodeByID(‘vtkMRMLCameraNode1’)
camera.SetFocalPoint(*position)
camera.SetPosition(position[0]+100,position[1]-200,position[2]+50)

def RotateOpposite(self)
camera = slicer.mrmlScene.GetNodeByID(‘vtkMRMLCameraNode1’)
camera.RotateAround(‘R’,180) / camera.RotateTo(position[0]-100,position[1]+200,position[2]-50)

To look at a point from the other side, mirror the camera position on the focal point position (cp_new = cp_old + 2 * (fp-cp_old)).

1 Like