I have a practical problem that boils down to this geometric problem: I have a three-sided irregular pyramid where everything about the base triangle is known: all $3$ side-lengths $(a, b, c) $ and the angles $(\angle ab,\angle cb, \angle ac)$. I also do know the $3$ angles at the tip of the pyramid $(α, β, γ)$. What I want to calculate is the length of the remaining edges $e, f,$ and $g$ (that are connecting the base triangle with the tip).

sketch of the pyramid

With the law of cosine, I get this as a starting point: $$a^2 = e^2 + f^2 - (2ef\cos(\alpha))$$ $$b^2 = f^2 + g^2 - (2fg\cos(\beta))$$ $$c^2 = g^2 + e^2 - (2ge\cos(\gamma))$$

When I try to solve this system of equations (using substitution and $pq$-formula) I had to give up at a point where I had a really long equation to the power of $4$. Is there a practical way in solving this?

Thanks :-)

UPDATE: As mentioned in a comment by Paul Sinclare another approach to solve this problem would be the use of the law of sine:

$$\frac{e}{sin(θ)}=\frac{a}{sin(\alpha)}=\frac{f}{sin(\alpha+θ)}$$ $$\frac{g}{sin(Φ)}=\frac{c}{sin(\gamma)}=\frac{e}{sin(\gamma+Φ)}$$ $$\frac{g}{sin(Ω)}=\frac{b}{sin(\beta)}=\frac{f}{sin(\beta+Ω)}$$

θ = angle between a and f

Φ = angle between e and c

Ω = angle between b and f

Trying to solve these equations for one angle also results in a huge equation I'm not able to solve by hand anymore. Any advice on how I should proceed?

  • 1
    $\begingroup$ FYI - a "three-sided pyramid" is called a "tetrahedron". $\endgroup$ Commented Sep 6, 2023 at 19:37
  • 1
    $\begingroup$ Instead of using the law of cosines, you might try setting the angle at $B$ on side $ABD$ to be some value $\theta$. This then drives the angle at $A$, and by the law of sines fixes the lengths $e, f$, and thus the first triangle. Now it can rotate about $\overline{AB}$, so this is not yet enough to set $g$. Call an angle on another side $\phi$, and you can give two equations for each of $e, f, g$ in terms of $\theta, \phi$, giving three equations in $\theta, \phi$. Solving them may be easier than the law of cosine equations. $\endgroup$ Commented Sep 6, 2023 at 20:00
  • $\begingroup$ Thanks for your suggestion Paul. I've updated my original post with the equations for law of sine. After substituting everything into a single equation, it again get's so complicated that I was not able to solve the equation anymore. Am I doing something wrong? $\endgroup$ Commented Sep 7, 2023 at 9:15
  • 1
    $\begingroup$ First, $\sin (\pi - \alpha - \theta) = \sin(\alpha + \theta) \ne \sin(\alpha - \theta)$. Second, I said "might try" and "may be easier" exactly because I hadn't tried it myself and was merely suggesting an alternate path to be explored. Thirdly, you want to eliminate $e, f,g, \Omega$ from your equations, so that only $\theta, \phi$ are your unknowns (and you may want to treat $u=\sin \theta, v = \sin \phi$ as the unknowns instead). Fourthly, complicated expressions involving only known values do not need to be treated in-tact. It is allowable to give them a simple label, and continue solving. $\endgroup$ Commented Sep 7, 2023 at 11:43
  • $\begingroup$ Thanks for your continuing support Paul. Thanks for the hint regarding the wrong signs in my equations, I've fixed them. I was following your advice but I unfortunately never came to something solve-able. I later noticed that this problem is also known as the P3P-problem (perspective 3-point problem) and it seems to be only solve able by the use of numeric solvers. Anyway, you helped me learn a lot so thanks for all your responses :-) $\endgroup$ Commented Sep 8, 2023 at 16:46

1 Answer 1


The practical way to solve the system of equations that you obtained is by using the Newton-Raphson multivariate method. Define the vector function $\mathbf{f}$ as follows:

$ \mathbf{f} = \begin{bmatrix} f_1 \\ f_2 \\ f_3 \end{bmatrix} = \begin{bmatrix} x_1^2 + x_2^2 - 2 x_1 x_2 \cos(\alpha) - a^2 \\ x_2 ^2 + x_3^2 - 2 x_2 x_3 \cos (\beta) - b^2 \\ x_3^2 + x_1^2 - 2 x_3 x_1 \cos(\gamma) - c^2 \end{bmatrix} $

where $ x_1 = e, x_2 = f , x_3 = g $

The Jacobian of $\mathbf{f}$ is given by

$ J = \begin{bmatrix} \dfrac{\partial f_1}{\partial x_1} && \dfrac{\partial f_1}{\partial x_2} && \dfrac{\partial f_1}{\partial x_3} \\ \dfrac{\partial f_2}{\partial x_1} && \dfrac{\partial f_2}{\partial x_2} && \dfrac{\partial f_2}{\partial x_3} \\ \dfrac{\partial f_3}{\partial x_1} && \dfrac{\partial f_3}{\partial x_2} && \dfrac{\partial f_3}{\partial x_3} \end{bmatrix} = \begin{bmatrix} 2 x_1 - 2 x_2 \cos(\alpha) && 2 x_2 - 2 x_1 \cos(\alpha) && 0 \\ 0 && 2 x_2 - 2 x_3 \cos(\beta) && 2 x_3 - 2 x_2\cos(\beta) \\ 2 x_1 - 2 x_3 \cos(\gamma) && 0 && 2 x_3 - 2 x_1 \cos(\gamma) \end{bmatrix}$

Start with an initial guess $\mathbf{x}_0 = [ x_{10}, x_{20} , x_{30} ]^T $ then update the solution using the following Newton-Raphson formula,

$ \mathbf{x}_{k+1} = \mathbf{x}_k - J^{-1} \ \mathbf{f}_k $

After a few iterations, the vector $\mathbf{x}_k$ will converge to the solution $\mathbf{x}^*$ where $\mathbf{f}^* \approx \mathbf{0} $. Note that the matrix $J$ is not constant and varies as $\mathbf{x}_k$ varies. Its inverse has to be computed at each iteration.

  • $\begingroup$ Thank you very much. I was successful using this method :-) $\endgroup$ Commented Sep 8, 2023 at 16:47
  • $\begingroup$ You're welcome. Glad I could help. $\endgroup$ Commented Sep 8, 2023 at 17:07

You must log in to answer this question.

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