Calculating the angle between two polygons For my application, I want to render models as polygonal surfaces in 3D space and have edges that are bent "outwards" to have a solid line and those who are bent "inwards" to have a dotted line. So if I look from the top of the edge if they "bend towards me" they are bending inwards, if they bend away from me, they bend outwards.

For this, I need to calculate the angle between two connected triangles.
How can I calculate this angle? How can I define if it is bent outwards or inwards (looking from the top it would always bend downwards if the angle is >180 and inwards (so up) if the angle is &lt;180, but how can I calculate this?
I suggest computing the normal vector for each polygon and compute the angle between the normal vector of one triangle and the normal vector of a plane perpendicular to the other surface that passes through the common edge.

See the following illustration, where the red arrows are the normal vectors of the red polygons. The blue vector is the plane perpendicular to the left polygon that passes through the edge common to both polygons.



If your polygons are planar, then you can compute the normal for any polygon ABC by computing the cross product AB x AC.

To obtain the blue vector, take the cross product of the normal of the left polygon and the vector that is the common edge.

The angle you're looking for is formed between this blue vector and the normal to the other polygon (the red vector on the right in the diagram).

You then compute the cosine of the angle between two vectors u and v by taking their dot product, then dividing by their magnitudes.



Image taken from here.