# Compute roll, pitch and yaw from 3D vector

Hi !

I'm trying to build SDF tree models from a description file. The branches are modeled by cylinders. For each cylinder, I have : x, y, z : coords of the cylinder, vx, vy, vz : vector supporting the cylinder.

Since the `<pose>`

takes roll, pitch and yaw angles to build a cylinder, I have to compute them from the direction vector (vx, vy, vz).

Here's how I do it, using `numpy`

:

`roll = np.arctan2(vz, vy)`

`pitch = np.arctan2(vx, vz)`

`yaw = np.arctan2(vy, vx)`

I'm not getting the results I want, some of the branches are clearly misplaced. I noticed that Gazebo places a cylinder along the z axis if you provide yaw, pitch, roll = 0, so I tried to rotate by 90° on the x axis like so :

`roll = np.arctan2(vz, vy) + 1.5708`

without success.

If you have any advice on how to get these Euler angles right, feel free to share !

Have a nice day.