# Rotate a vtkMRMLModelNode() in a specific direction

**URL:** <https://discourse.slicer.org/t/rotate-a-vtkmrmlmodelnode-in-a-specific-direction/24512>\
**Category:** Development\
**Created:** [July 27, 2022, 2:03am UTC](https://discourse.slicer.org/t/rotate-a-vtkmrmlmodelnode-in-a-specific-direction/24512 "2022-07-27T02:03:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mosenco](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mosenco/32/16037_2.png) [@mosenco](https://discourse.slicer.org/u/mosenco)\
**Post date:** [July 27, 2022, 2:03am UTC](https://discourse.slicer.org/t/rotate-a-vtkmrmlmodelnode-in-a-specific-direction/24512/1 "2022-07-27T02:03:46Z")

</div>

I have created a `cylinderSource = vtk.vtkCylinderSource()`  
and then a `cylindermodel = slicer.vtkMRMLModelNode()` and “linked together” with `cylindermodel.SetAndObservePolyData(cylinderSource.GetOutput())`

then i created a `cylindermodelDisplay = slicer.vtkMRMLModelDisplayNode()` set all the colors and so on and “linked together” with  
`slicer.mrmlScene.AddNode(cylindermodelDisplay) cylindermodel.SetAndObserveDisplayNodeID(cylindermodelDisplay.GetID())`

all nice.

Now i have 2 points in space and between them multiple points (which i have their position) and i wanted to put all those nice cylinder in that direction between the 2 points and rotated accordingly, so it looks like a long rod.

i created a `cylinderTS = slicer.vtkMRMLTransformNode()` so my `cylindermodel` can associate with it later.  
I created a `cylinderTransform = vtk.vtkTransform()` so i can rotate my `cylinderTS` and i associated them with `cylinderTS.SetAndObserveMatrixTransformToParent(cylinderTransform.GetMatrix())`

But i don’t know how to rotate in the same direciton of the “line” between the two points. I tried to use `cylinderTransform.RotateWXYZ()` but i don’t know the axis of rotation.

I had an idea.  
I just create a vtkline, i can associate a `slicer.vtkMRMLModelNode()` and then i can get the angle, the local axis… but i noticed that from a `slicer.vtkMRMLModelNode()` i can’t retrieve a `slicer.vtkMRMLTransformNode()` and neither a matrix4x4…

Someone can suggest me any ideas?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [July 27, 2022, 10:59am UTC](https://discourse.slicer.org/t/rotate-a-vtkmrmlmodelnode-in-a-specific-direction/24512/2 "2022-07-27T10:59:05Z")

</div>

I suggest using the line markup because it gives you a cylinder between two points.

Otherwise, this is a VTK / math question.
