I am struggling with a problem in the $3D$ coordinate system. I have a point given by its coordinates (I also know the distance from the origin, so I don't have to bother with counting that) and I need to make a line segment from the origin to this point by rotating the line segment. How can I get angles to rotate it?
I suppose I need only two angles. I was trying to use some arctangent formula, but I am not able to finish it.
The best I could do was
$angle_1 = \arctan(\frac{x}{diag_{xy}})$; $angle_2 = \arctan(\frac{y}{x})$
but that doesn't work.
I was given this advice (originally from: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#rotate):
$length = $norm$([x,y,z])$; // radial distance
$b = \arccos(\frac{z}{length})$; // inclination angle
$c = atan2(y,x)$; // azimuthal angle
the b and c is actually the angles I was looking for.
x,y,z are coordinates of given point.
where norm() is euclidian norm of vector https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Mathematical_Functions#norm.
And atan2 is the arctangent function with two arguments https://en.wikipedia.org/wiki/Atan2.