Calculate 3D Vector out of two angles and vector length

18.2k Views Asked by At

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

1

There are 1 best solutions below

1
On BEST ANSWER

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}$.