Translate, rotate and scale a meshgrid between two points in 3D space

3dcoordinate systemsrotationstrigonometry

I am trying to translate, rotate and scale a meshgrid between two points in 3D space, however, I cannot seem to get it right. I need my meshgrid to follow the points in order to make an animated 3D figure.

I have attached an illustration of my problem (A) and what I would like to achieve (B) here.

So what I would like is to:

  1. Translate the meshgrid (D,C,A,B,E) so D overlap point F.
  2. Rotate the mesh grid so vector DE is matching vector FG.
  3. Scale the meshgrid to match the length of vector FG

I tried to rotate the grid using the following trigonometry, but it doesn't look right:

v = pointG- pointF
theta = np.arctan2(v[1], v[0])
phi = np.arctan2(np.linalg.norm(v[:2]), v[2])

Can you help me? And sorry if my question is badly formulated. I am not home in mathematics.

Best Answer

1) Translate everything to bring $F$ to the origin (i.e. subtract $\vec {OF}$):
the points become $A',B', \cdots$

2) Translate the object bringing $D' \to F'=O$:
points are $A'', B'', \cdots$

3) Now you have three point $E'', G''$ and the $O=F'$. They define a plane in which they lie.

4)In that plane you have to make a dilation (length $|OE''| = |OG''|$) and a rotation to finally bring $E''$ to $G''$

5) revert the first translation

Related Question