I have a 3d model (M1) consisted of several points. I know all their coordinates. I also have another model (M2). M2 and M1 are the same, but M2 is a model after rigid transformation. I don't know the axis or the center of transformation. The only thing I know is the type of transformation - translation or rotatation. So my question is - how can I find the center or the axis of rotation, and the the value of angle?
-
The singular verion of "axes" is "axis." – rschwieb Jan 21 '14 at 19:24
-
Or he's taking this math back to medieval times. – John Jan 21 '14 at 19:25
-
@Eugene You have each preimage-afterimage pair, right? If one of your points is $x$ and the transformation is $T$, then you can see both $x$ and $T(x)$, right? – rschwieb Jan 21 '14 at 19:27
-
Are you sure you couldn't be telling us more specifics about the points? This is asking for a pretty broad answer. – rschwieb Jan 21 '14 at 20:06
-
I have a partial answer but am frightened to post partial answers :D – user76568 Jan 21 '14 at 20:16
3 Answers
Translation from the original (unprimed) frame to the new (primed) frame is fairly simple: $\vec{x'} = \vec{x} + \vec{R},$ with $\vec{R}$ being a constant vector of translation.
Rotation is a bit trickier. You might have as many as three angles to deal with: one for each principal axis. These rotations are expressed as a product of rotation matrices. The elements of the product matrices are the direction cosines of the original axes and the new axes.
- 26,319
-
I don't think the data for "only apply translation" is a given in the problem.. – user76568 Jan 21 '14 at 19:41
-
I know that translation is very simple case. About the rotation: I agree that it will be the product of rotation matrices. But each matrix will have the angle of rotation and the coordinates of the vector defining the axis of rotation. And I don't know these parameters. I only know what was before and what is after. – Eugene Jan 21 '14 at 20:16
You can derive the basis transform T which maps M1 to M2 (I explained the process here). Once done, you can then "read out" the basis vectors and use the cosines of the axes to determine the angle.
!IF! you can identify the "same" points on the two models (maybe the same index in the arrays of points), you can actuall "choose" a translation that would fix the point of rotation\s and have them share a common axis:
Calculate the mean point of each of the two models (maybe convex hull to simplify, primed stand for M2):
$$\overline{p}=\frac{1}{n}\sum_{k=1}^np_k, \space \overline{p}^{'}=\frac{1}{n}\sum_{k=1}^np_k^{'}$$
Now, $\vec T=\overline{p}^{'}-\overline{p}$ is the translation vector.
Next, apply $-\vec T$ to $M_2$ so that it also has mean point $\overline{p}$ (Hence it just as if it was rotated around $\overline{p}$) and denote it $M_2^{'}$
Next, Choose two corresponding points from the models ($p_1,p_2 \in M_1, \space p^{'}_1,p^{'}_2 \in M_2^{'}$), and use them to construct two vectors:
$$\vec{x}=p_2-p_1, \space \vec{x}^{'}=p^{'}_2-p^{'}_1.$$
The axis of rotiation can be obtained using the cross product (normalized):
$$\vec {Ro}=\frac{\vec x \times \vec{x}^{'}}{|\vec x|^2}$$
Then, the angle is just:
$$\theta_{Ro}=\arcsin(|\vec {Ro}|)$$
All this correspods to:
1. $M_1$
2. Rotate by $\theta_{Ro}$ about $\overline{p}$ with $\vec {Ro}$ corresponding to the axis of rotation.
3. Translate by $\vec T$
4. $M_2$
- 4,542
-
Due to your solution I'll find the axe, but how can I find its location relative to my model? – Eugene Jan 22 '14 at 08:39