I have a tetrahedron defined as:
- "base" vertices $P$, $Q$, $R$ are given.
- length of "remain" edges $L_P$, $L_Q$, and $L_R$ are also given.
I need to find the 4th vertex coordinates $(x, y, z)$. The image below describes my problem:
I understand that there are two symmetric solutions, one where the vertex is up and another when the vertex is below the plane defined by $(P, Q, R)$.
I tried to solve this problem by considering 3 spheres $S_P$, $S_Q$, $S_R$ with center on $P$, $Q$, $R$ and radius $L_P$, $L_Q$, and $L_R$, respectively. I'm wondering if there is an easier straighforward way to solve this.







Finding $(x, y, z)$ as the intersection of three spheres of radius $L_P$, $L_Q$, and $L_R$, centered at $P = (P_x, P_y, P_z)$, $Q = (Q_x, Q_y, Q_z)$, and $R = (R_x, R_y, R_z)$, respectively, is the solution.
However, if you rotate and translate the coordinate system, you can simplify the math a lot. (This is nothing special; it's just that when most of the coordinates are zeroes, the expressions simplify a lot.)
Rotate and translate the coordinate system (we'll use $(u, v, w)$ for the rotated and translated coordinates for clarity; note that distances are unchanged), $P$ is at origin $(0, 0, 0)$, $Q$ is at $(U_Q, 0, 0)$, and $R$ at $(U_R, V_R, 0)$. Then, the fourth vertex is at $$\begin{aligned} u &= \frac{L_P^2 - L_Q^2 + U_Q^2}{2 U_Q} \\ v &= \frac{L_P^2 - L_R^2 + U_R^2 + V_R^2 - 2 U_R u}{2 V_R} \\ w &= \pm\sqrt{L_P^2 - u^2 - v^2} \\ \end{aligned}$$
Rotating and translating the coordinate system is not difficult, either: $$\begin{aligned} U_Q &= \left\lVert Q - P \right\rVert \\ \hat{u} &= \frac{Q - P}{U_Q} \\ \vec{t} &= (R - P) - \hat{u}\bigr(\hat{u} \cdot (R - P)\bigr) \\ \hat{v} &= \frac{\vec{t}}{\left\lVert \vec{t} \right\rVert} \\ \hat{w} &= \hat{u} \times \hat{v} \\ U_R &= (R - P) \cdot \hat{u} \\ V_R &= (R - P) \cdot \hat{v} \\ \end{aligned}$$ Conversion back to original coordinates is similarly trivial: $$\vec{p} = P + u \hat{u} + v \hat{v} + w \hat{w}$$
Here is a Python 3 implementation:
where
a.perp(b)is $\vec{a} - \vec{b}(\vec{a}\cdot\vec{b})$,a | bis $\vec{a} \cdot \vec{b}$ anda ^ bis $\vec{a} \times \vec{b}$.When run, it generates a test tetrahedron, and displays the results when
find_fourth_vertexis given three of the vertices and their distances to the fourth.The helper Vector class is implemented by
vector.py:that you can just put in the same directory as the example Python file. Run
pydoc3 vectorin that directory to see the API description for it.Note that
vector.pydefines a generic 3D Euclidean vector class with basic vector algebra operations, and is in no way specific to this particular problem.