6
$\begingroup$

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

$\endgroup$
0

1 Answer 1

6
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thank you very much! It works! I just tested it with OpenJSCAD work perfectly for all angles. $\endgroup$
    – mrh
    Aug 5, 2015 at 10:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .