3
$\begingroup$

Suppose you're given two planes

$ n_1 \cdot r = d_1 $

$ n_2 \cdot r = d_2 $

where $n_1$ and $n_2$ are unit vectors (known). $d_1$ and $d_2$ are known scalars. I want to rotate the first plane into the second plane with the following condition. Points $P_1$ and $Q_1$ are on the first plane, and points $P_2$ and $Q_2$ are on the second plane, such that $\overline{P_1 Q_1} = \overline{P_2 Q_2} $. I want to find the rotation(s) that will rotate the first plane into the second plane while mapping $P_1$ to $P_2$ and $Q_1$ to $Q_2$. How can I do this ? Your help is much appreciated.

My attempt:

We have two vectors in space that we need to relate by a $3D$ rotation matrix. We have

$ n_2 = R \ n_1 $

and

$ u_2 = R \ u_1 $

where the vectors are column vectors (algebraically). $R$ is the $3 \times 3$ rotation matrix, $u_1 = P_1 Q_1$, $u_2 = P_2 Q_2$. I then formed the cross product of the respective pairs of vectors (plane $1$ and plane $2$) and related them by the same rotation matrix. This is possible because it is a fact that

$ R ( \vec{a} \times \vec{b} ) = ( R \vec{a} ) \times ( R \vec{ b} ) $

Hence, we can now write

$ \begin{bmatrix} n_2 && u_2 && n_2 \times u_2 \end{bmatrix} = R \begin{bmatrix} n_1 && u_1 && n_1 \times u_1 \end{bmatrix} $

So that matrix $R$ can be determined easily as follows

$R = \begin{bmatrix} n_2 && u_2 && n_2 \times u_2 \end{bmatrix} \begin{bmatrix} n_1 && u_1 && n_1 \times u_1 \end{bmatrix}^{-1} $

The only thing left is to locate the center of rotation, and this can determined from the fact that

$ P_2 = C + R (P_1 - C) $

This simplifies to,

$ P_2 = R P_1 + (I - R) C $

which is a linear system in the unknown $C$. Now it is a well-known fact that $(I - R)$ is rank deficient, so $C$ will either belong to a line (which is the axis of rotation), or there will be no solution for $C$. This depends on $P_2$.

Edit:

This last equation suggests a different view at the situation. We have the vectors $n_1$, $n_2$, $P_1 Q_1$ and $P_2 Q_2$. These four vectors will generate a specific $R$ (note that $n_2$ or $n_1$ can be replaced with their negative, resulting in a different $R$). The above equation, is

$ P_2 = R P_1 + (I - R) C $

Therefore,

$ P_2 - P_1 = (I - R) (C - P_1) $

Hence, this equation, will have a solution for $C$ if and only if $P_2 - P_1$ is in the column space of $(I- R)$. If the column space is

$ p = t_1 V_1 + t_2 V_2 $

where we can assume that $V_1$ and $V_2$ are unit and orthogonal to each other.

$V_1, V_2$ can be obtained by $QR$ factorization of $(I - R)$.

i.e. $I - R = R_1 G $

where $G_{33} = 0 $

Then $V_1$ and $V_2$ are the first two columns of $R_1$.

Then we must have

$P_2 = P_1 + t_1 V_1 + t_2 V_2 $

we also know that

$ n_2 \cdot P_2 = d_2 $

This restricts $P_2$ to lie on a straight line. If $P_2$ is on this line, then we can solve for $(C - P_1)$ because then

$ R_1 \begin{bmatrix} t_1 \\ t_2 \\ 0 \end{bmatrix} = R_1 G (C - P_1) $

Then

$ \begin{bmatrix} t_1 \\ t_2 \end{bmatrix} = G' (C - P_1) $

where $G'$ is obtained from $G$ by deleting the last row of $G$ which is a row of zeros.

Now, $G'$ has a column rank of $2$, so this $2 \times 3$ system always has a particular solution. And in addition, the homogenous solution is given by the null space of $G'$ (which is one-dimensional).

Therefore, we now have that the center of rotation $C$ lies on a straight line, which is the axis of rotation.

In summary, to obtain the required rotation, I've expressed the rotation matrix in terms of the four vectors $n_1, n_2, P_1 Q_1 , P_2 Q_2 $, then derived the condition for the existence of this rotation, namely that $P_2 - P_1$ lies in the column space of $(I - R)$.

$\endgroup$
9
  • $\begingroup$ Are you allowing for translations? How would you deal for example with $n_1=n_2=(0,0,1)$ and $d_1\ne d_2$? $\endgroup$
    – Andrei
    Commented Jun 3 at 20:14
  • $\begingroup$ No, translations are not allowed, just pure rotation. $\endgroup$
    – disgraced
    Commented Jun 3 at 20:28
  • $\begingroup$ Does "pure rotation" mean "around the origin" (as in, it's a linear transform), or can the rotation axis be arbitrarily chosen (in particular, so that it doesn't go through the origin)? $\endgroup$ Commented Jun 3 at 20:51
  • 2
    $\begingroup$ If it's OK to compose several affine transforms, I guess an algorithmic procedure would go something like this: (1) rotate the first plane around the intersection (or an equidistant parallel axis) until it overlaps the second plane, (2) if the planes are oriented (if there's a distinction between sides), rotate 180 deg around an in-plane axis if required, (3) rotate around a perpendicular axis so that the center of $P_1Q_1$ overlaps with the center of $P_2Q_2$, and (4) rotate around a perp. axis through the center point until the corresponding endpoints overlap. $\endgroup$ Commented Jun 3 at 21:17
  • 1
    $\begingroup$ Ah, at first I thought this might be the case (as it is for linear transforms), but it seems it's only true if there is a point in space that remains untransformed (mapped to itself) by all the individual rotations that are being composed (see Euler's rotation theorem). $\endgroup$ Commented Jun 3 at 22:04

2 Answers 2

1
$\begingroup$

I'm not 100% sure that I understood what the question is, but I'm sharing my thoughts anyway. As fas as I can tell you are on the right track, but I think there are snakes in your paradise. More about that later.


The transformation you seek has to be an affine transformation $T:\Bbb{R}^3\to\Bbb{R}^3$ of the form $$ T(\vec{x})=A\vec{x}+\vec{u},\qquad(*) $$ where $\vec{x}$ is an arbitrary (column) vector from $\Bbb{R}^3$, $A$ is a $3\times3$ matrix, and $\vec{u}$ is some fixed vector (determined by $\vec{u}=T(\vec{0})$). We see that this is a pure translation if and only if $A=I_3$. Furthermore, any composition of transformations of this type is another.

For $T$ to be a rotation about some axis (not necessarily through the origin), it needs to be distance preserving: $d(\vec{x},\vec{y})=d(T(\vec{x}),T(\vec{y}))$ for all $\vec{x},\vec{y}$. The translational part $\vec{u}$ is immaterial for the purposes of preserving distances, so the linear transformation $L(\vec{x})=A\vec{x}$ must also preserve distances. After all, $$ T(\vec{x})-T(\vec{y})=L(\vec{x})-L(\vec{y}), $$ so $d(T(\vec{x}),T(\vec{y})=d(L(\vec{x}),L(\vec{y})).$ From linear algebra we know this to be the case if and only if $AA^T=I_3$.

For $T$ to be a rotation, it also needs to preserve handedness (locally, i.e. ignoring the translation again), which happens when $\det A=1$. It is easy to show that $AA^T=1$ and $\det A=1$ together imply that $\lambda=1$ is an eigenvalue of $A$. In other words, $L$ is a rotation about the axis $\ell$ (though the origin) specified by an eigenvector $\vec{z}$ such that $A\vec{z}=\vec{z}$.

If $T$ is a rotation about a line of the form $\ell+\vec{b}$ not through the origin (so here $\vec{b}$ takes the role of the origin as some fixed point on the axis of rotation), then $T$ is a composition of three affine transformations: translation by $-\vec{b}$, rotation about the axis $\ell$ (by the same angle), and a translation by $+\vec{b}$. It follows that the composition is of the form $(*)$, where $A^TA=I_3, \det A=1$, i.e. $A\in SO(3)$.

The following is a summary of what I think is going on:

  • It is always possible to find an affine transformation of form $(*)$ with $A\in SO(3)$ meeting your requirements.
  • Every rotation about any axis is of the form $(*)$ (we just saw this).
  • But even if $A\in SO(3)$, the transformation $T$ is not necessarily a rotation about some axis. This is clear when $A=I_3$, $\vec{u}\neq\vec{0}$, but may happen otherwise also.

The catch is, as you observed, that the transformation $T$ need not have any fixed points (= points on the axis). I think this also implies that the rotation you seek does not always exist. Consider the special case $\vec{u}_1=\vec{u}_2$. In this case it follows, that the axis of rotation must be a line parallel to $vec{u}_j, j=1,2$. But if the orthogonal projections of $P_1$ and $P_2$ on one such line $\ell$ are not equal, then a rotation $T$ about $\ell$ will never map $P_1$ to $P_2$, because the vector from $P_1$ to $T(P_1)$ is orthogonal to $\ell$, ditto for $P_2$. Using any other line $\ell'$ parallel to $\ell$ won't change this. I think that in the case $\vec{u}_1=\vec{u}_2$ you need $P_1P_2$ to be perpendicular to $\vec{u}_1$ for such a rotation to exist.

Nevertheless, when such a rotation can be found, I think your algorithm will succeed. You need the linear part $L$ to map $\vec{u}_1\mapsto\vec{u}_2$ and $\vec{n}_1\mapsto\pm\vec{n}_2$ (changing the sign may or may not help?), and then the cross product to the corresponding cross product. This will specify the matrix $A$, and you can then find $\vec{u}$ simply from the equation $T(P_1)=P_2$. The catch is that the resulting affine transformation need not be a rotation.


I need to think about this more to say something definite about when $(*)$ with $A\in SO(3)$ has fixed points, i.e. an axis of rotation. Posting this for now.

$\endgroup$
1
  • 1
    $\begingroup$ You're right, it is always possible to find an affine transformation that maps the first plane into the second while mapping $P_1$ to $P_2$ and $Q_1$ to $Q_2$. However, if we restrict this affine transformation to be be a pure rotation, then that's not always possible. $\endgroup$
    – disgraced
    Commented Jun 23 at 9:34
1
$\begingroup$

I think I misunderstood your method when first reading it. Looking more carefully at it, it now seems to me that you use the rotation matrix $R$, which (nominally) specifies a rotation around an axis through the origin, to describe the necessary "change in orientation" in order to map the vectors $n_1$ and $u_1$ onto $n_2$ and $u_2$. Then you look for the axis such that when the same "change in orientation" is performed while every point on that axis is held fixed, $P_1$ is mapped to $P_2.$

This specifies the rotation almost uniquely. The missing detail is that two points do not define the orientation of a plane. So it is not necessary to map $n_1$ and $u_1$ onto $n_2$ and $u_2$. It is necessary to map $u_1$ to $u_2$, but $n_1$ can be mapped to either $n_2$ or to $-n_2$.

The trick of mapping $n_1 \times u_1$ to $n_2 \times u_2$ when you map $n_1$ to $n_2$ will ensure that your matrix is orthogonal and its determinant is $1$ (so that you get a rotation rather than something else, such as a reflection). For the same reason, you should map $n_1 \times u_1$ to $-n_2 \times u_2$ when you map $n_1$ to $-n_2$.

In many cases this should allow you to find two rotations that you can choose from, although it may be that there are conditions of your problem that restrict the answers (such as that you are calculating the motion of a vehicle and the change in orientation from state $1$ to state $2$ must not be too large, so you choose the normals so that $n_1 \cdot n_2$ is close to $1$ and you really do want $n_1$ to go to $n_2$, not $-n_2$).

The problematic case is when the two planes are parallel but distinct. It is possible then that each of the two isometries is a translation or a screw motion. When that happens there will be no fixed points.


An alternative method is to use your matrix $R$ as the upper left block of a $4\times4$ matrix,

$$ T = \begin{pmatrix} R & u \\ 0 & 1 \end{pmatrix}, $$

where $u = P_2 - RP_1$ and the bottom row of the matrix is zero except for the very last position. This is the full affine transformation matrix; you use it by appending a $1$ at the end of each point's coordinates. That is, given the coordinates $(x,y,z)$ of a point before transformation, you find the transformed point $(x',y',z')$ as follows:

$$ \begin{pmatrix} x' \\ y' \\ z' \\ 1 \end{pmatrix} = T \begin{pmatrix} x \\ y \\ z \\ 1 \end{pmatrix} $$

That's a specification of the rotation if there is a rotation. If the transformation has a fixed point, it's a rotation; otherwise it is not. If neither $n_1 \mapsto n_2$ nor $n_1 \mapsto -n_2$ results in a transformation matrix $T$ that is a rotation, there is no solution.

$\endgroup$

You must log in to answer this question.

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