# Calculate 3D Vector out of two angles and vector length

What is the easiest way to calculate vector coordinates in 3D given 2 angles vector length?

Input:

1. Angle between X and Y axis: $$\alpha \in [0, 360).$$
2. Angle between Y and Z axis: $$\beta\in [0, 360).$$
3. Scalar length.

Expected output:

X, Y, Z coordinates of the vector

• Angels? I think you meant to say angles. :) – wltrup Aug 5 '15 at 8:45

You have presented a point in spherical coordinate system, which needs to be converted to Cartesian. The line joining the origin to the point will be the vector. Let the scalar length be $r$. If the $\beta$ angle is measured from $Y$ axis towards $Z$ axis and $\alpha$ from $X$ axis towards $Y$:
$$x = r \cos \beta sin \alpha$$ $$y = r \cos \beta cos \alpha$$ $$z = r \sin \beta$$
The vector is: $x \hat{i} + y\hat{j} + z\hat{k}$.