1
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ Try googling "spherical coordinates". Those are usually given as one angle from the $xz$-plane, add the angle from the $z$-axis. $\endgroup$ – Arthur Dec 23 '16 at 16:13
  • $\begingroup$ Let A be the given point. You don't say if you want to rotate segment OA around one of the axes , e.g., the $z$ axis, or around another axis OB ? $\endgroup$ – Jean Marie Dec 23 '16 at 16:21
  • $\begingroup$ I need all the rotations around the three basic axis. $\endgroup$ – TGar Dec 23 '16 at 16:26
  • 1
    $\begingroup$ When you answer to somebody that is not either the OP, or somebody who has provided an answer, please begin by arobas followed by its pseudo. Otherwise, no alert will reach him/her. $\endgroup$ – Jean Marie Dec 23 '16 at 16:35
2
$\begingroup$

Let $(x_0,y_0,z_0)$ be the coordinates of point $A.$

Using a +45° rotation around $x$ axis gives point A_1 with the following coordinates:

$$\begin{cases}x_1&=&x_0\\y_1&=&y_0 \cos(45°) - z_0 \sin(45°)\\z_1&=&y_0 \sin(45°) + z_0 \cos(45°)\end{cases}$$

then the +45° rotation around $z$ axis of point $A_1$ gives point $A_2$:

$$\begin{cases}x_2&=&x_1 \cos(45°) - y_1 \sin(45°)\\y_2&=&x_1 \sin(45°) + y_1 \cos(45°)\\z_2&=&z_1\end{cases}.$$

Remark: $\cos(45°)=\sin(45°)=\dfrac{\sqrt{2}}{2}$.

$\endgroup$
  • $\begingroup$ Sorry I do not understand that. Where can I find the angles I need? Or maybe, how does this join works? $\endgroup$ – TGar Dec 23 '16 at 16:50
  • 1
    $\begingroup$ There is a misunderstanding between us. Do you mean that you have an initial position $A$ and that you have a final position $B$, (imperatively with $OA=OB$) that you want to reach B starting from $A$ by three consecutive rotations around axes $x$, $y$ and then $z$ ? $\endgroup$ – Jean Marie Dec 23 '16 at 16:56
  • $\begingroup$ I am not sure now. I have a point A and line segment (at the beginning it is pointing to direction 1,0,0) and I need to rotate it so it become as you say OA. But i need angles due to the axis. $\endgroup$ – TGar Dec 23 '16 at 17:12
  • $\begingroup$ Can this movement be described on a (fictitious) sphere centered in $O$ with radius $OA$ ? $\endgroup$ – Jean Marie Dec 23 '16 at 17:18
  • $\begingroup$ If i correctly understand then yes. $\endgroup$ – TGar Dec 23 '16 at 17:21
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.