How to get RPY(Roll, Pitch, Yaw) from directional cosines from a 3D vector?

391 Views Asked by At

I'm trying to find the pose of an 3D vector in terms of RPY(Roll, Pitch, Yaw). Let's say the two end points of the vector is $P_0(x_0, y_0, z_0)$ and $P_1(x_1, y_1, z_1)$. So the centered vector I get is $V(V_x, V_y, V_z) = P_1 - P_0 = (x_1 - x_0, y_1 - y_0, z_1 - z_0)$

Then $cos(\alpha) = \frac{V_x}{|V|}\\ cos(\beta) = \frac{V_y}{|V|}\\ cos(\gamma) = \frac{V_z}{|V|}$

Thus, $\alpha = cos^{-1}(\frac{V_x}{|V|})\\ \beta = cos^{-1}(\frac{V_y}{|V|})\\ \gamma = cos^{-1}(\frac{V_z}{|V|})$

Here, I'm assuming $\alpha = roll,\ \beta = pitch,\ and \ \gamma = yaw$

Is it the correct way to do this?