# Building a tetrahedron from two defined vectors?

I am currently writing a program that computes specific molecular bond angles for one of my research projects but am running into some trouble.

Suppose I want a tetrahedron with vertices A, B, C, D.

I know three ${x,y,z}$ coordinates: one coordinate corresponding to the center of the tetrahedron, and two additional coordinates corresponding to vertices A and B.

The angle $\Theta$ between A and B is roughly 109.5 degrees.

My current approach to this issue has been to compute two cross products, between A and B, one pointing above the plane ($v_1$) and one below the plane ($v_2$). The output vectors are then rotated by $\pi$/2 to lie parallel to the plane ($v_3$, $v_4$).

From ($v_3$, $v_4$) I am computing the vectors C and D.

This approach is poor and eats up a processing time (I have 120000 data sets to process).

I am curious whether there exists some transformation matrices that vectors A and B can be multiplied by to yield C and D?

Thanks!

## 2 Answers

Here's how I might go about it ...

Let $A$, $B$ be the given vertices, and $P$ the center, of the (presumably-regular) tetrahedron. Let $M$ be the midpoint of $\overline{AB}$: $$M:= \frac12(A+B)$$ Then $N$, the midpoint of $\overline{CD}$, is on the other side of $P$ from $M$: $$N := M + 2(P-M) = 2P-M$$ $\overrightarrow{NC}$ and $\overrightarrow{ND}$ are orthogonal to both $\overrightarrow{MA}$ and $\overrightarrow{MP}$, while having length equal to that of $\overrightarrow{MA}$. Since $\overline{MA}$ and $\overline{MP}$ are themselves orthogonal, we can simply take their cross product and divide-through by the length of $\overrightarrow{MP}$; in a regular tetrahedron, $|\overrightarrow{MP}|$ is actually $|\overrightarrow{AB}|/(2\sqrt{2})$. So, we can write: $$C, D \quad=\quad N \;\pm\; \frac{\overrightarrow{MA}\times\overrightarrow{MP}}{|\overrightarrow{MP}|} \quad=\quad N \;\pm\;2\sqrt{2}\;\frac{\overrightarrow{MA}\times\overrightarrow{MP}}{|\overrightarrow{AB}|}$$ That is, expressing everything in terms of $A$, $B$, $P$ ... $$C, D \quad=\quad P +\frac12\left(\;(P-A)+(P-B) \;\pm\;\sqrt{2}\;\frac{(A-B)\times((P-A)+(P-B))}{\sqrt{(A-B)\cdot(A-B)}}\;\right)$$ This simplifies if we translate $P$ to the origin. In other words, defining $X^\prime := X - P$, we have $$C^\prime, D^\prime \quad=\quad \frac12\left(\;- A^\prime - B^\prime \;\mp\; \sqrt{2}\;\frac{(A^\prime-B^\prime)\times(A^\prime+B^\prime)}{\sqrt{(A^\prime-B^\prime)\cdot(A^\prime-B^\prime)}}\;\right)$$ Even better, the cross product simplifies, and we have

$$C^\prime, D^\prime \quad=\quad \frac12\left(\;- A^\prime - B^\prime \;\mp\; 2\sqrt{2}\;\frac{A^\prime\times B^\prime}{\sqrt{(A^\prime-B^\prime)\cdot(A^\prime-B^\prime)}}\;\right)$$

(where you can change the "$\mp$" to "$\pm$" if you don't care how $C^\prime$ and $D^\prime$ correspond to $C$ and $D$).

• +1 for the formula. 80% of the work I do on a daily basis is programming such algorithms. As most programmers would agree, simplified formulas beat complex algorithms :) Commented Jul 5, 2018 at 4:40

Two years later, this problem came back to haunt me and I solved it. We have the vertices $A$, $B$ and the origin of the tetrahedron $O$.

Step 1. Map to origin: $$\vec{A} = A - O\\ \vec{B} = B - O$$

Step 2. Reverse the direction of $\vec{A}$ and $\vec{B}$:

$$(-1)(\vec{A})\\ (-1)(\vec{B})$$

Step 3. We know a regular tetrahedron is of $C_{2v}$ symmetry - any two of four vertices lie on a plane orthogonal to any other two vertices. Therefore we must rotate -$\vec{A}$ and -$\vec{B}$ by $\pi/2$ radians about a general axis $\hat{k}$. Let's first find $k$:

$$k = \frac{1}{2}(-\vec{A} + (-\vec{B}))$$

Step 4. From $k$ we can find $\hat{k}$. Let's now generate the cross product matrix $K$ from $\hat{k}$: $$K = \begin{bmatrix} 0 & -k_z & k_y\\ k_z & 0 & -k_x\\ -k_y & k_x & 0 \end{bmatrix}$$

Step 5. We can now use Rodrigues formula to rotate -$\vec{A}$ and -$\vec{B}$ by $\pi/2$ radians. Let's generate the rotation matrix $R$:

$$R = I + sin(\pi/2)K + (1 - cos(\pi/2)K^2$$

Step 6. The remaining vertices $C$, $D$ are simply the rotated vectors -$\vec{A}$ and -$\vec{B}$:

$$\vec{C} = (R)(-\vec{A})\\ \vec{D} = (R)(-\vec{B})$$

Math!