Rotate vector around center, python

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Rotate vector around center, python

johnnyjo
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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers