# Align poly data to direction vector

**URL:** https://discourse.vtk.org/t/align-poly-data-to-direction-vector/5927
**Category:** Support
**Created:** [June 3, 2021, 3:57pm UTC](https://discourse.vtk.org/t/align-poly-data-to-direction-vector/5927 "2021-06-03T15:57:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![csad6517](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/49beb7/32.png) [@csad6517](https://discourse.vtk.org/u/csad6517)
#### Post date: [June 3, 2021, 3:57pm UTC](https://discourse.vtk.org/t/align-poly-data-to-direction-vector/5927/1 "2021-06-03T15:57:11Z")

</div>

I represent a vtk poly data object that I read with `vtkPlyReader` and want to align it to given normalized direction vector, so that its orientation matches with that vector.

```auto
directionVector = np.array([-0.1134, -0.0695, 0.9911])

plyReader = vtk.vtkPLYReader()
plyReader.SetFileName(filePath)

transform = vtk.vtkTransform()
transform.RotateWXYZ(-90, 0, 0, 1) #initial rotation  
transformFilter = vtk.vtkTransformPolyDataFilter()
transformFilter.SetTransform(transform)
transformFilter.SetInputConnection(plyReader.GetOutputPort())
transformFilter.Update()

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(transformFilter.GetOutputPort())
mapper.ScalarVisibilityOn()
mapper.Update()

actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.Modified()

renderer.AddActor(actor) 

```

I know that I should use the `Rotate()` function from `vtkTransform` but don’t know how to align it.

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [June 3, 2021, 4:13pm UTC](https://discourse.vtk.org/t/align-poly-data-to-direction-vector/5927/2 "2021-06-03T16:13:34Z")

</div>

You might also try this: use vtkGlyph3D. It’s first input is simply a point you want to position the polydata from the ply reader. This first input would also contain a direction vector (contained in the point’s point attribute data) along which to align the glyph. The glyph of course is the polydata from the ply reader (the second input to the filter, the source).

Admittedly this is a hack 🙂 You could also study the code in vtkGlyph3D and see how it uses a vector to orient a glyph.

---

<div class="post-metadata">

### Author: ![csad6517](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/49beb7/32.png) [@csad6517](https://discourse.vtk.org/u/csad6517)
#### Post date: [June 3, 2021, 6:46pm UTC](https://discourse.vtk.org/t/align-poly-data-to-direction-vector/5927/3 "2021-06-03T18:46:57Z")

</div>

Hi.  
There are some examples that combines the glyph3D and e.g. an arrow source, which contains some vector information, but the whole poly data is then represented as arrow, which I do not look for.

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [June 3, 2021, 6:52pm UTC](https://discourse.vtk.org/t/align-poly-data-to-direction-vector/5927/4 "2021-06-03T18:52:11Z")

</div>

The ply polydata would be the single, oriented glyph placed at a point. This has nothing to do with an arrow etc.
