# How to rotate the 3d camera around a center ruler or 3dvector

**URL:** <https://discourse.slicer.org/t/how-to-rotate-the-3d-camera-around-a-center-ruler-or-3dvector/27262>\
**Category:** Development\
**Created:** [January 16, 2023, 1:47pm UTC](https://discourse.slicer.org/t/how-to-rotate-the-3d-camera-around-a-center-ruler-or-3dvector/27262 "2023-01-16T13:47:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay1987](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jay1987/32/16183_2.png) [@jay1987](https://discourse.slicer.org/u/jay1987)\
**Post date:** [January 16, 2023, 1:47pm UTC](https://discourse.slicer.org/t/how-to-rotate-the-3d-camera-around-a-center-ruler-or-3dvector/27262/1 "2023-01-16T13:47:19Z")

</div>

the basic camera action is Yaw,Azimuth,Elevation,is it possible to rotate camera around like vector line [2,1,3]?

---

<div class="post-metadata">

**Author:** ![jay1987](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jay1987/32/16183_2.png) [@jay1987](https://discourse.slicer.org/u/jay1987)\
**Post date:** [January 17, 2023, 1:39am UTC](https://discourse.slicer.org/t/how-to-rotate-the-3d-camera-around-a-center-ruler-or-3dvector/27262/2 "2023-01-17T01:39:00Z")

</div>

use vtkTransform can do it

```auto
    transform_node = self.camera_node.GetParentTransformNode()
    if not transform_node:
      transform_node = util.AddNewNodeByNameByClass("vtkMRMLLinearTransformNode")
      self.camera_node.SetAndObserveTransformNodeID(transform_node.GetID())
      transform_node = self.camera_node.GetParentTransformNode()

    modelToParentTransform = vtk.vtkMatrix4x4()
    handleToWorldMatrix = vtk.vtkTransform()
    handleToWorldMatrix.PostMultiply()
    handleToWorldMatrix.Translate(-self.focus_point[0], -self.focus_point[1], -self.focus_point[2])
    handleToWorldMatrix.RotateWXYZ(val,self.cemera_vector_normalized)
    handleToWorldMatrix.Translate(self.focus_point)
    modelToParentTransform.DeepCopy(handleToWorldMatrix.GetMatrix())
    transform_node.SetMatrixTransformToParent(modelToParentTransform)

```
