Search code examples
geometrytriangulation

Invalid result for calculating angles between triangle respective planes


I need to find the angle between two triangles' respective planes. I use triangles from an .stl file of different objects. I have followed the answer from this question. It works with some of the shapes, however, I recently encountered a problem, where the resulting cosine of the angle equals 2, thus it is not correct.

Neither of the two triangles in this case are degenerate, as their points respectively are A, B, C and B, C, D. The common edge is BC. The values: A (50.3473, 2.03038, 50) B (99.072, 10.6219, 50) C (50.3473, 0.3038, 0) D (99.072, 10.6219, 50)

When I calculate the cross products of BC X AB and BC X AD, they both have the same values. After normalizing them and finding the dot product, it results in 2.

Am I doing something wrong? What does this mean?

Any help is appreciated.


Solution

  • Cauchy-Schwarz inequality: the dot product of two normalized vectors cannot be greater than 1.

    The problem must be in the normalisation of the vectors, or in the dot product calculation.