[vtkusers] Rotate vector around center, python

johnnyjo j.j.lahnstein at t-online.de
Thu Mar 14 09:50:25 EDT 2019


I am using VTK and Python for a project related to my studies.

I am given the following point centerOfRotation and the orientation degrees,
as well as the vector [1, 0, 0]. Now I want to rotate the vector so it
"points" in the direction specified by degrres and then translate it to the
point p.

centerOfRotation = [314.848717879, 283.085686693, 423.900139245]
degrees = [-7.93947167694, -0, 171.098864823]
vector = [1, 0, 0]

transform = vtk.vtkTransform()
transform.Identity()

transform.PreMultiply()
transform.Translate(centerOfRotation)
transform.RotateZ(degrees[2])
transform.RotateX(degrees[0])
transform.RotateY(degrees[1])
transform.Translate(-centerOfRotation[0], -centerOfRotation[1],
-centerOfRotation[2])

newPos = [0]*3
transform.TransformPoint(vector, newPos)
The centerOfRotation and degrees are extracted from another program, in the
other program the second point(newPos) should be beneath the first
point(centerOfRotation). But with the code given above, the second point is
located above the center of rotation. I hope someone can point me in the
right direction. Thanks a lot !

BTW: I am given another information by the other program: YSymmetry=1. I am
not really sure what that means though.

Note: I am neither a math nor computer student and my math skills are
somewhat rusty. Right now I dont have the time to study the math, so if you
could point me in the right "coding" direction I would appreciate it :D



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list