Find the angle between the faces from the normals of the face

I have some face normals, and I need to calculate the angle between the faces to which they belong. The problem I am facing is finding the angles between the faces when the angle is greater than 180 - I cannot figure out how to determine the difference between the angle 45 and the angle 315.

edit2: I have access to the obj file that defines the model, what information will I need to distinguish between 45 and 315? In addition, I create (low poly) models, so I can guarantee that there are no intersecting faces, etc.

edit:

ang = math.acos(dotproduct(v1, v2) / (length(v1) * length(v2))) ang = math.degrees(ang) ang = 360 - (ang + 180) 
+4
source share
1 answer

Make sure your normals are unit lengths (if necessary, divide them by length). Then find the point product.

  dp = n1.x * n2.x + n1.y * n2.y + n1.z * n2.z 

This will give a value in [-1 to 1].
If dp is negative, the angle is greater than 90 degrees.

To find the angle, use the arc cosine.

  θ = acos (dp); 

This will give you a value in radians. To convert to degrees, multiply by 180 / pi.


Edit: Suppose faces are defined as polygons. If the faces are not coplanar, in each definition of the polygons of the face there must be one point that is not coplanar with another polygon. Consider two triangles: if one edge is connected, they separate two vertices, but each of them has one common part. I will call these v1 and v2 related respectively to the normals n1 and n2 . Find a vector from v1 to v2 :

 m = v2-v1 

If the angle between m and n1 is greater than 90 [ dotP (m, n1) <0 ], then the polygons collide from each other. If the angle is less than 90, the polygons face each other. If the angle is 90 degrees, then I think that the polygons are coplanar (either one of the points you selected is on the planar intersection line or I missed the case in my thinking).

+6
source

Source: https://habr.com/ru/post/1344303/


All Articles