Angle between two "directed" triangles in 3D between 0 an 2 pi I have two triangles in a 3D space, each one defined by three vectors. The two trianlges share an edge.
Beside that I have a normalized vector for each triangle (perpendicular on it) defining a "direction" (="outside" in the use-case) for the triangle.
Unfortunately I am not able to find a way to calculate the angle between these two triangles in the interval of $[0, 2\pi)$ with the given information. $\arctan$ and $\arccos$ will give the smaller angle between those two only, ignoring the "direction".
 A: Let $\vec{n}_1$ and $\vec{n}_2$ be the triangle normal vectors, pointing "outwards"; and $\vec{e}_{12}$ be a vector representing the shared edge, from one vertex to the other on the shared edge.
Because the shared edge is on the plane of both triangles, the edge vector is perpendicular to both normals, $\vec{e}_{12} \perp \vec{n_1}$ and $\vec{e}_{12} \perp \vec{n}_2$.  (This also means $\vec{e}_{12}$ is parallel to the cross product of of the two normals, $\vec{n}_1 \times \vec{n}_2$.) The direction of this edge vector defines the sign in the angle between the two normal vectors.
Define $\hat{n}_1$, $\hat{n}_2$, and $\hat{e}_{12}$ as their unit vector counterparts:
$$\hat{n}_1 = \frac{\vec{n}_1}{\lVert\vec{n}_1\rVert}, \quad
\hat{n}_2 = \frac{\vec{n}_2}{\lVert\vec{n}_2\rVert}, \quad
\hat{e}_{12} = \frac{\vec{e}_{12}}{\lVert\vec{e}_{12}\rVert}$$
Then, using $\theta$ for the signed angle between the normals,
$$\begin{aligned}
\cos \theta &= \hat{n}_1 \cdot \hat{n}_2 \\
\sin \theta &= \hat{e}_{12} \cdot \bigl( \hat{n}_1 \times \hat{n}_2 \bigr) \\
\end{aligned} \tag{1} \label{1}$$
When $\theta = 0$, the two triangles are coplanar.  When viewing along the edge vector, if the first plane is counterclockwise from the second plane, the angle is positive; otherwise the angle is negative.
The angle $\varphi$ formed by the planes at the shared edge is $\varphi = 180° + \theta = \pi + \theta$, assuming you choose the direction of the shared edge vector so that positive signed angles between the normals refers to a convex edge, and negative signed angles a concave edge.

Consider the case where the shared edge is between $(0, -1, 0)$ and $(0, +1, 0)$, with the third vertices being at $(0, 0, 2)$ and $(2, 0, 0)$.
In this case, we have $\hat{e}_{12} = (0, 1, 0)$, $\hat{n}_1 = (1, 0, 0)$, and $\hat{n}_2 = (0, 0, 1)$.
$$\left\lbrace \begin{aligned}
\cos \theta &= \hat{n}_1 \cdot \hat{n}_2 = 0 \\
\sin \theta &= \hat{e}_{12} \cdot \bigl( \hat{n}_1 \times \hat{n}_2 \bigr) = -1 \\
\end{aligned} \right . \quad \iff \quad \theta = -90°$$
Note how the direction of $\hat{e}_{12}$ affects the result.  If we chose the opposite direction, we'd have $\hat{e}_12 = (0, -1, 0)$, and $\sin\theta = 1$, and therefore $\theta = +90°$.
This definition, using the direction of the shared edge to define positive and negative angles, is consistent regardless of rotation and translation of the entire system.  In a very real sense, the choice of the direction of the shared edge is the choice of "handedness" for the two triangles, giving us the full range of signed angles between the two normal vectors, $-180° \lt \theta \lt 180°$.  (The case where the two triangles are coplanar but normals opposite corresponds to $\theta = \pm 180°$, where both signs are equally valid.)
