# Distance between two points in two different planes given the dihedral angle

We have four points: $$p_1, p_2, p_3$$ and $$p_4$$. The goal is to compute the distance between $$p_1$$ and $$p_4$$.

What we know:

• The distances between $$p1$$ and $$p2$$ ($$a$$) , $$p2$$ and $$p3$$ ($$b$$), $$p3$$ and $$p4$$ ($$c$$)
• The angles $$\alpha$$ and $$\beta$$ between ($$p1$$,$$p2$$,$$p3$$) and ($$p2$$,$$p3$$,$$p4$$) respectively
• The dihedral (torsion) angle $$\phi$$ between the two planes of $$p1$$ and $$p4$$

We do not have any coordinates of any of these points.

How do we use this information to compute the distance between $$p1$$ and $$p4$$? I tried doing something like projecting $$p1$$ onto the plane of $$p4$$, but I ended up needing information that I do not have access to. In order to take into account a certain symmetry of this issue, let us consider the intersection line of the planes as the $$x$$ axis with origin at the midpoint of $$p_2p_3$$, and the bissector plane as the reference horizontal plane.

Imagine the particular case $$\varphi=0$$ meaning that the figure is a flat figure in this bissector plane , i.e., all $$p_k$$ coplanar in the $$xy$$ plane. From this case, generate the general case by rotating vector $$\vec{p_1p_2}$$ around the $$x$$ axis with a $$\psi:=\varphi/2$$ angle in one direction whereas vector $$\vec{p_3p_4}$$ is rotated in the other direction i.e., with a $$-\psi$$ angle.

This will give, using rotation matrices,

$$p_1=\begin{pmatrix}1&0&0\\0&\cos \psi&-\sin \psi\\0&\sin \psi&\ \ \ \ \cos \psi\end{pmatrix}\begin{pmatrix}-a \cos \alpha\\ \color{red}{+}a \sin \alpha\\0 \end{pmatrix}-\begin{pmatrix}b/2\\0\\0\end{pmatrix}$$

$$p_4=\begin{pmatrix}1&0&0\\0&\ \ \ \cos \psi& \sin \psi\\0&-\sin \psi&\cos \psi\end{pmatrix}\begin{pmatrix}-c \cos \beta\\ \color{red}{+}c \sin \beta\\0 \end{pmatrix}+\begin{pmatrix}b/2\\0\\0\end{pmatrix}$$

It remains to expand the previous expressions and then use the distance formula:

$$\delta=\sqrt{(x_1-x_4)^2+(y_1-y_4)^2+(z_1-z_4)^2}$$

• Any comment ?... Jun 18, 2021 at 18:09
• Thank you for your answer! I think it makes sense. However, I implemented it in Java, to use for my project, and it seems it is not giving me the right values in practice. One example from practice: $a = 1.229, b = 1.522, c = 1.449, \alpha = 120.4, \beta = 110.1$ and finally $\phi = 0$. Solving the matrix operations and computing the distance gives me $\sigma = 1.43$ (I also did the matrix operations by hand, and I also got $1.43$). However, if I solve the instance by hand in another way (since $\phi = 0$, all I have to do is solve a quadrilateral), I find that $\sigma$ should be $2.665$. Jun 21, 2021 at 12:32
• I think the error might be in the matrices describing the positions of $p1$ and $p4$ when $\phi = 0$. Shouldn't we use $+ a \cos \alpha$, $+ a \sin \alpha$, $c \cos \beta$ and $-c \sin \beta$? If $\alpha > 90$, the x-coordinate of $p1$ should be lower, if $\alpha < 90$, the x-coordinate of $p1$ should be larger. Jun 22, 2021 at 12:04
• @Simon H see the two sign rectifications I have brought (in red). Jun 23, 2021 at 18:53

Take projection of A on foldline as origin. If supplements of $$\alpha, \beta \text{ are }\alpha', \beta'\text{ then }$$ after projecting in three mutually perpendicular Cartesian planes directly by 3d Pythagoras $$A:( a \sin \alpha' \cos \phi, 0,a \sin \alpha' \sin \phi)$$ $$B:(c \ sin \beta', a \cos \alpha'+b + c \cos \beta',0)$$ $$L=\sqrt{ (x_B-x_A)^2+ (y_B-y_A)^2+ (z_B-z_A)^2}.$$

• Thanks for your answer. What if $\alpha$ or $\beta < 90$ degrees? I implemented this answer in Java aswell, and comparing to the implementation of the answer of Jean Marie the results are the same except for when $\alpha$ or $\beta < 90$ degrees. Jun 24, 2021 at 8:35
• The formula is general for directions you have shown. Did you take supplementary angles and proper trig signs? Jun 24, 2021 at 12:06
• I am not sure what you mean by proper trig signs. I did take supplementary angles. Actually, I do not think the problem is the $\alpha$ or $\beta$. The formula seems to work for $\phi = 0$ and $\phi = 180$. However, tried some values in between, and sometimes for two angles $\phi_1, \phi_2, \phi_1 < \phi_2$, it seems that the resulting distance $L_1 > L_2$. However, if $\phi_1 < \phi_2$ I think that $L_2$ should always be larger than $L_1$. Jun 24, 2021 at 12:26
• Apologies, a typo I noticed and corrected just now. Ok now? Jun 24, 2021 at 13:24
• Yes, now it works perfectly. I was already a bit confused about the z-coordinates always being 0. Now it gives exactly the same solutions as the other answer! Thank you! Jun 24, 2021 at 13:53