# [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)
transform.RotateX(degrees)
transform.RotateY(degrees)
transform.Translate(-centerOfRotation, -centerOfRotation,
-centerOfRotation)

newPos = *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
```