[Math] Components of a 3d vector given specific angles

3dvectors

I'm looking for 3 formulae for the x, y, and z components of a 3d vector given 2 angles (and a magnitude). I essentially need to convert from spherical to cartesian coordinates in 3 dimensions. The issue is, the angles which I am given are rather difficult to work with.

I am fully aware of this page, but it, as well as every other resource I've been able to find, assumes I am working with a polar angle (theta as shown) and azimuthal angle (phi as shown).

The two angles I am given are:

  • on the XZ plane rising from the X axis
  • on the YZ plane rising from the Y axis

as these axes are normally defined in 3d space.

I have attempted to convert from a polar and azimuthal angle as shown on wikipedia to my own, with the goal of plugging my converted angles into the formulae listed here (x,y,z =), but am at a loss for how to move the polar angle from what appears to be 3d space onto a 2d plane (which would be required to accomplish this goal).

I also tried to rotate the angles over a multitude of different axes with the same goal in mind, but ran into a similar problem with the polar angle.

If anybody knows knows or can derive the formulae for the individual components of a vector in 3d space given these particular angles, please share.

Best Answer

If you are given the angle ($\alpha$) of the projection of the vector on the XZ plane, taken from X, then it means that the projection lies on the line $z=\tan \alpha \, x$, i.e that the vector lies on the plane $$ \pi _{\,x\,z} :\quad x\sin \alpha - z\cos \alpha = 0 $$

Similarly for the angle $\beta$ rising from Y on the YZ plane we get $$ \pi _{\,y\,z} :\quad y\sin \beta - z\cos \beta = 0 $$

Visually this is rendered by the following sketch

Vect_ang_1

That means that the vector is normal to both the normals of the planes, which gives $$ \bbox[lightyellow] { \eqalign{ & {\bf r} = \pm \left| {\bf r} \right|\;{{{\bf n}_{\,{\bf \alpha }} \times {\bf n}_{\,{\bf \beta }} } \over {\left| {{\bf n}_{\,{\bf \alpha }} \times {\bf n}_{\,{\bf \beta }} } \right|}} = \cr & \; = \pm \left| {\bf r} \right|\;\left[ {\left( {\matrix{ {\sin \alpha } \cr 0 \cr { - \cos \alpha } \cr } } \right) \times \left( {\matrix{ 0 \cr {\sin \beta } \cr { - \cos \beta } \cr } } \right)} \right]_{\,norm} = \cr & = {{ \pm \left| {\bf r} \right|} \over {\sqrt {\cos ^{\,2} \beta \sin ^{\,2} \alpha + \sin ^{\,2} \beta } }}\; \left( {\matrix{ {\cos \alpha \sin \beta } \cr {\cos \beta \sin \alpha } \cr {\sin \alpha \sin \beta } \cr } } \right) = \cr & = {{ \pm \left| {\bf r} \right|\;2\sqrt 2 } \over {\sqrt {6 - \cos \left( {2\left( {\alpha + \beta } \right)} \right) - \cos \left( {2\left( {\alpha - \beta } \right)} \right) - \cos \left( {2\alpha } \right) - \cos \left( {2\beta } \right)} }}\; \cdot \cr & \cdot \left( {\matrix{ {\cos \alpha \sin \beta } \cr {\cos \beta \sin \alpha } \cr {\sin \alpha \sin \beta } \cr } } \right) \cr} } \tag{1}$$

where the sign is to be taken appropriately: it will be plus if the direction of the vector is chosen according to the "right hand rule".

Note that the expression for the vector is fully compatible wrt the exchange of $\alpha, \beta$ as it should be.

Also note that $$ \bbox[lightyellow] { {{r_{\,z} } \over {r_{\,x} }} = \tan \alpha \quad {{r_{\,z} } \over {r_{\,y} }} = \tan \beta } $$ as required.

And finally note that the expression above is fully defined for $0 < |\alpha|,\, |\beta| < pi$, as well as for $ |\alpha| =0, \, \pi$ if $\beta \ne 0$ $$ {{\bf r} \over {\left| {\bf r} \right|}} = \left\{ {\matrix{ {\left( {1,0,0} \right)^T } & {\left| {\,\alpha = 0,\beta \ne 0} \right.} \cr {\left( {0,\cos \beta ,\sin \beta } \right)^T } & {\left| {\,\alpha = \pi /2,\forall \beta } \right.} \cr {\left( { - \sqrt 2 \sin \beta \,\mathop /\limits_{} \sqrt {1 - \cos \left( {2\beta } \right)} ,0,0} \right)^T } & {\left| {\,\alpha = \pi ,\;\beta \ne 0} \right.} \cr } } \right. $$

--- Conclusion ---

In reply to your comment, consider that the formula (1) above simply translates into
$$ \bbox[lightyellow] { \left\{ \matrix{ x = r{{\cos \alpha \sin \beta } \over {\sqrt {\cos ^{\,2} \beta \sin ^{\,2} \alpha + \sin ^{\,2} \beta } }}\; \hfill \cr y = r{{\cos \beta \sin \alpha } \over {\sqrt {\cos ^{\,2} \beta \sin ^{\,2} \alpha + \sin ^{\,2} \beta } }} \hfill \cr z = r{{\sin \alpha \sin \beta } \over {\sqrt {\cos ^{\,2} \beta \sin ^{\,2} \alpha + \sin ^{\,2} \beta } }} \hfill \cr} \right.\quad \Leftrightarrow \quad \left\{ \matrix{ r = \sqrt {x^{\,2} + y^{\,2} + z^{\,2} } \; \hfill \cr {z \over x} = \tan \alpha \hfill \cr {z \over y} = \tan \beta \hfill \cr} \right. }\tag{1.a}$$

Related Question