How to find the main axis normal of a vtkCylinderSource?

Hello,

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

Any help is really appreciated.

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.

@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

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 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.

From the documentation of vtkCylinderSource:

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?

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