Rotate a line about the origin so that a point in space belongs on the line

457 Views Asked by At

There are 3 points in space, B and C that define a line and a third point D that is not on the line. How to find the angles by which to rotate the line on each of the axis so that point D belongs on the line? I've managed to solve this in 2 dimensions but I'm having trouble translating that to 3D.

With coordinates Alpha Problem in 3D

The equation I've found is: $$\alpha=-\beta+180°-\gamma-\arcsin\left(\frac{h\cdot\sin\gamma}{i}\right)$$

Where $\alpha$ is the angle of rotation, $\beta$ is the angle DOB, $\gamma$ is the angle OBC, h is the length of the segment OB and i is the length of the segment OD.

My attempt at making this work in 3D was to project the points B and C onto the XY plane and calculate the Z angle, then rotate the points around the Z axis by the angle I found, project the rotated points onto the XZ plane and find the Y angle and repeat for the X angle.

This doesn't seem to work however. Is there a better way of going about this?

3

There are 3 best solutions below

1
On BEST ANSWER

Suppose instead of rotating the line passing through $B$ and $C$ so that point $D$ lies on the rotated line, we'll go the other way around, and rotate point $D$ about an axis passing through the origin, so that $D$'s image lies on the line $BC$. After we find this rotation, we'll just invert the rotation and apply it to line $BC$, to make it contain point $D$.

Since the rotation of point $D$ about any axis passing through the origin, will be another point that lies on the sphere centered at the origin, and with a radius equal to $OD$, then all we have to do to find the image of point $D$, is intersect the sphere with line $BC$. There can be no intersections, one intersection, or two intersections at most. If there are no intersections, then it is not possible to perform this rotation to satisfy the given condition. Otherwise, pick an intersection, call it $D'$ as the image of $D$. Now we want to rotate $OD$ into $OD'$, and this can be done in an infinite number of ways, as the axis of rotation is not unique, but instead lies in the plane whose normal vector is $DD'$ and passing through the midpoint of $DD'$.

However, there is a rotation that uses the minimum possible rotation angle, and that rotation has an axis given by $OD \times OD'$, and the rotation angle $\theta$ is given by

$ \theta = \text{atan2}\bigg( \dfrac{OD \cdot OD'}{ \| OD \|^2 } ,\dfrac{ \| OD \times OD' \| } { \| OD \|^2 } \bigg) = \text{atan2} ( OD \cdot OD' , \| OD \times OD' \| ) $

Where $\text{atan2}(x, y) = \phi$, with $\cos \phi = \dfrac{x}{\sqrt{x^2 + y^2}}, \sin \phi = \dfrac{y}{\sqrt{x^2+ y^2} } $

Having found the axis and the angle that sends $D$ to $D'$, in order to answer your question, we just apply the reverse rotation to line $BC$ to rotate it into $B'C'$ and by our construction, point $D$ will lie on it.

If rotation about an arbitrary axis was allowed, then we'll have to use the Rodrigues' rotation matrix formula which states that the rotation matrix is given by

$ R(\theta) = {a a}^T + (I - {aa}^T) \cos \theta + S_a \sin \theta $

where $a$ is the unit vector along the axis of rotation, $\theta$ is the angle of rotation counter-clockwise with the axis pointing towards you, and $S_a$ is given by

$ S_a = \begin{bmatrix} 0 && - a_z && a_y \\ a_z && 0 && -a_x \\ -a_y && a_x && 0 \end{bmatrix} $

However, the question asks for a rotation that is a composition of rotations about the $x$, $y$ , and $z$ axes.

To perform the rotation from $D$ to $D'$ using rotations about the $x$, $y$ and $z$ axes, let

$ D = ( d_x , d_y, d_z ) $

$ D' = (d'_x, d'_y, d'_z ) $

If $ |d_z| \ge |d'_z|$, then by rotating $D$ about the $x$ axis by an angle $\phi$ we obtain

$ D_1 = ( d_x , \cos \phi d_y - \sin \phi d_z, \sin \phi d_y + \cos \phi d_z ) $

We can select $\phi$ such that

$ \sin \phi d_y + \cos \phi d_z = d'_z $

Now, we have

$ D_1 = ( d_x , \cos \phi d_y - \sin \phi d_z , d'_z ) = (d_x, d_{1y}, d'_z) $

So that $D_1$ and $D'$ have the same $z$-coordinate. Therefore, now we can simply rotate $D_1$ about the $z$ axis into the vector $D_2$, by an angle $\psi$, such that $D_2$ and $D'$ have the same coordinates.

$D_2 = ( \cos \psi d_x - \sin \psi d_{1y} , - \sin \psi d_x + \cos \psi d_{1y} , d'_z ) $

i.e. we have to find $\psi $ such that

$ \cos \psi d_x - \sin \psi d_{1y} = d'_x $ , and

$ \sin \psi d_x + \cos \psi d_{1y} = d'_y $

which is a linear system in $\cos \psi$ and $\sin \psi$ and can be readily solved.

Similar set up can be used if $ |d_x| \ge |d'_x| $ where we rotate $D$ first with respect to $z$ axis, which brings the $x$ coordinates to be the same, then we apply a rotation about $x$ axis to make all coordinates the same. And finally, if both $ |d_x| \lt |d'_x| $ and $|d_z| \lt |d'_z| $ then it must be the case that $ |d_y| \gt |d'_y|$, so we rotate about the $x$ axis to bring the $y$ coordinates to be equal, then we rotate about the $y$ axis to make all coordinates equal.

0
On

In 2D the solution is "almost unique": there are at most two orientations of the line (rotating it around the origin) that will cause the line to pass through $D,$ and all rotations come down to one of those two angles plus some multiple of $2\pi.$

The solution is not at all unique in 3D; there are infinitely many ways the line could pass through $D.$ But we can narrow down the solutions by choosing only two axes for the rotation.

Here's an outline of one method. There are some details you would have to fill in.

First, determine whether the problem is solvable. Measure the distance $d$ from the (infinite) line $BC$ to the origin. If $d > OD,$ then all points on the line are farther from the origin than $D$ is and it is impossible to rotate the line onto $D$ by any rotation that leaves the origin fixed.

If the problem is solvable, choose a point $E$ on the line $BC$ at a distance $OD$ from the origin. If $d = OD$ there is only one such point, the point closest to the origin; if $d > OD$ there are two such points.

Next, rotate around the $x$ axis to that the point $E$ is rotated to a point $F$ with the same $z$-coordinate as $D.$ There are two choices for $F$ except in the case where the distance from $E$ to the $x$ axis is exactly equal to the $z$-coordinate of $D.$

Finally, rotate around the $z$ axis so that $F$ is rotated to $D.$

This assumes that the $z$ axis doesn't move when you do the $x$ rotation. If the $x$ rotation moves the $z$ axis, determine the rotation angles you would use if the $z$ axis didn't move, and then apply the rotations in the reverse order ($z$ first, then $x$).

Notice that there is zero rotation around the $y$ axis in this method. That's because all this method is attempting to do is to get the rotated line to pass through $D,$ and to do this we just need to make sure that the point $E$ on the line $BC$ is rotated onto $D$ somehow. The orientation of the rotated line through $D$ is not considered.

If you don't like the direction in which the rotated line passes through $D$, you could use the $y$ axis together with the other two to rotate the line differently so that it passes through $D$ in a different direction. There are infinitely many choices of direction. But that is a more complicated problem.

3
On

The way it is drawn, the angle $\alpha$ is the angle between the vectors $\vec{BC}$ and $\vec{BD}$

$$ \alpha = {\rm acos}\left( \frac{ \vec{BC} \cdot \vec{BD} }{ \| \vec{BC} \| \| \vec{BD} \| } \right) $$

The axis of rotation is defined by the cross product (normalized to a unit vector)

$$ \vec{n} = \frac{ \vec{BC} \times \vec{BC} }{ \| \vec{BC} \times \vec{BC} \|}$$

From the angle and axis, use the Rodrigues rotation formula to get a 3×3 general rotation matrix

$$ {\bf R} = {\bf 1} + (\sin \alpha) {\bf N} + (1-\cos \alpha) {\bf N}\, {\bf N} $$

where ${\bf 1}$ is the identity matrix, and ${\bf N}$ is the 3×3 skew symmetric matrix cross product matrix of $\vec{n}$

The last part would be to extract the 3 Euler angles of ${\bf R}$ in order to decompose it as three rotations about the three axes. Lookup "get Euler angles from rotation matrix" to find how to do this.