# How to find the main axis normal of a vtkCylinderSource?

**URL:** https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722
**Category:** Support
**Created:** [April 9, 2019, 5:36pm UTC](https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722 "2019-04-09T17:36:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![siaeleni](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@siaeleni](https://discourse.vtk.org/u/siaeleni)
#### Post date: [April 9, 2019, 5:36pm UTC](https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722/1 "2019-04-09T17:36:54Z")

</div>

Hello,

I was wondering how can I get the main axis as a vector of the vtkCylinderSource?

Any help is really appreciated.

---

<div class="post-metadata">

### Author: ![dan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dan/32/289_2.png) [@dan](https://discourse.vtk.org/u/dan)
#### Post date: [April 10, 2019, 2:15am UTC](https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722/2 "2019-04-10T02:15:02Z")

</div>

I haven’t used the cylinder source specifically, but the actor will have an orientation. You can get the orientation of the cylinder’s axis from those 3 rotation vectors.

I explain how the transformations work in [my VTK tutorial](http://compilatrix.com/article/vtk-1#_transformations).

---

<div class="post-metadata">

### Author: ![siaeleni](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@siaeleni](https://discourse.vtk.org/u/siaeleni)
#### Post date: [April 11, 2019, 3:16pm UTC](https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722/3 "2019-04-11T15:16:42Z")

</div>

@dan Thanks for the answer.  
I tried to use the GetOrientation as you have mentioned, but doesn’t give me the long axis.

Here is the piece of code

```
import vtk
source = vtk.vtkCylinderSource()
t = vtk.vtkTransform()
t.GetOrientation()
(0.0, -0.0, 0.0)
filter = vtk.vtkTransformPolyDataFilter()
filter.SetInputData(source.GetOutput())
filter.SetTransform(t)

```

Could you please provide any hint?  
Thanks in advance

---

<div class="post-metadata">

### Author: ![dan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dan/32/289_2.png) [@dan](https://discourse.vtk.org/u/dan)
#### Post date: [April 12, 2019, 12:03am UTC](https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722/4 "2019-04-12T00:03:22Z")

</div>

If you transform your input data it doesn’t change the actor’s orientation. What I meant was to point out that if you rotate an actor, then use `.GetOrientation()`, those three angles will let you rotate any new object to point the same way as the current actor. I don’t think you want to transform the actual polygon information of the cylinder.

However, although awkward, [this](https://github.com/daniel-s/vtk_examples/blob/master/cylinder_axis.py) may be what you need. You can use `vtkPolyDataNormals` to give you the normal of every cell in a polygon mesh. You just need to find the cell that is at the top of the cylinder, then check its normal after the transformation.

---

<div class="post-metadata">

### Author: ![dlrdave](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlrdave/32/111_2.png) [@dlrdave](https://discourse.vtk.org/u/dlrdave)
#### Post date: [April 13, 2019, 10:40am UTC](https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722/5 "2019-04-13T10:40:51Z")

</div>

From the documentation of vtkCylinderSource:

[https://vtk.org/doc/nightly/html/classvtkCylinderSource.html#details](https://vtk.org/doc/nightly/html/classvtkCylinderSource.html#details)

“The axis of the cylinder is aligned along the global y-axis.”

Is that what you’re looking for?

---

<div class="post-metadata">

### Author: ![pettaa123](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pettaa123/32/218_2.png) [@pettaa123](https://discourse.vtk.org/u/pettaa123)
#### Post date: [April 15, 2019, 6:59am UTC](https://discourse.vtk.org/t/how-to-find-the-main-axis-normal-of-a-vtkcylindersource/722/6 "2019-04-15T06:59:54Z")

</div>

Its better to add the orientation of your cylinder after creating the points representing the geometry. If you dont have the possibility to, try Principal Component Analysis or the mentioned normal analysation. I dont see a different solution with my limited knowledge
