[Math] calculating the dihedral angle of two planes

geometry

I have an ordered pair of planes, meeting at a hinge at their intersection line. The planes and the line are oriented. I want a formula for the dihedral angle $\theta$, calculated as follows:

Orient everything so that the hinge is oriented along the positive $z$ axis. The two planes are now lines in the $xy$ plane. Measure the angle between them, starting at the first plane and rotating in the direction of the first plane's orientation until you hit the second plane.

There is the obvious formula $n_1\cdot n_2 = \cos \theta$, where $n_1$ and $n_2$ are the plane normals, but to determine the correct angle in $[0,2\pi]$ I then need to also look at $\sin \theta$. Is it possible to write down a single formula for $\theta$ in terms of the positions and orientations of the planes/line, differentiable whenever the angle lies in $(0,2\pi)$?

Best Answer

Here's a cross section of the situation, with two oriented planes. If you're rotating the red/green plane in the direction of its green side, does that mean clockwise or counterclockwise?

diagram with a red/green and a blue/orange plane

So I don't think you can use the orientation of the planes to fix an interpretation of the angle. However, you write that you have a preferred orientation of the line of intersection, and that sounds more promising.

Namely, you can decide to turn the first plane counterclockwise when looking in the preferred direction along the intersection line.

Somewhat tedious formula-churning implementation of this: Fix some point on the intersection line and consider the plane that is normal to it at that point. Equip that plane with an orthonormal coordinate system that creates a right-handed system together with the preferred direction of the intersection. The orthonormal coordinates create a parametric representation of the normal plane; compose that with the equations for the two original planes; that gives 2D equations within the normal plane for its intersection with the original plane. Now find the angle in the normal plane using standard 2D techniques (e.g as the difference of atan2 values).

Computationally slicker: You can find $|\cos\theta|$ by the dot product or normals in 3D without needing to project into a specific cross section; the only remaining information you need is whether to use $\theta_0$, $\pi-\theta_0$, $\theta_0-\pi$ or $-\theta_0$, where $\theta_0$ is the arccosine of the dot product. But you can actually distinguish between those four cases simply by the combination of (a) the sign of the dot product and (b) whether the cross product of the normals is parallel or antiparallel to the chosen direction of the intersection line. I'd probably make some embarassing mistake if I tried to work our exactly what the connection should be, but there are only 4! possible ways to do it anyway, so just figure it out with trial and error...