detecting if 2 triangles are concave or convex.

Started by
8 comments, last by wolfman8k 21 years, 7 months ago
Let''s say I have 2 triangles in 3d space that share an edge. I have each ones normal. How can I tell if they are concave or convex?
  
side view:

    ___|___     \
   /             \/
 \/               \
 /                 \___|___
/

  [concave]       [convex]
  
What if they share only a vertex? Thanks you, wolfman8k
Advertisement
Couldn''t you just check the angles between the two edges.

That picture looks like some 2D trigonometry, so thats why I suggest an angle checking method as a possible solution
Is there such a thing as a "concave" triangle? It only has 3 sides.




"I thought Genius lived in bottles..." - Patrick Star
"I thought Genius lived in bottles..." - Patrick Star
quote:Original post by Hybrid
Couldn''t you just check the angles between the two edges.

That picture looks like some 2D trigonometry, so thats why I suggest an angle checking method as a possible solution


Ok, but first of all, how do I check the angle between the two edges? Second, even if I could, how would I explicitly check the angle on the correct side of the edges(the one where the normals are pointing)?

Thank you.
I haven''t thought this all the way through, but what about the angle between the normals?
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Easy. If N1 . N2 < π then the triangles are concave. If not, they''re convex or parallel. Assuming your normals are normalised, of course.
Just testing the angle between the normals isn''t enough. For example, just by moving the triangles from the examples above without changing there normals:

  side view:              |       B      |    ___|___   |  \  AA  /          |   \/ \/           |    \    B /            |     \___|___/             |              |  [concave]   |   [convex]              |      |       |      |     \|/      |     \|/              |              |    B       A  /   | ___|___        \/    |        \  A   B    /     |         \/___|___/      |          \              |           \  [convex]    |   [concave]              | 
Eep! I just realised what a very silly post I made. There are so many faults that I don''t know where to begin. Apologies.
I presume A and B are supposed to indicate the surface normals? I''ll ut the non-orthogonality of the pictures down to the limitations of ascii art!

There may indeed be an easier method, but here is one answer to your problem. First, impose an ordering of traversal along the edge. Call A the first triangle edge and B the second triangle edge.

1) Compute the tangent vector (T) to B, so that T.NB = 0. Additionally, choose the positive direction for the tangent vector to be away from A (i.e., in the positive traversal direction)

2) Compute the components of the normal NA in the directions of T and NB, so that NA = a1T + a2NB

A is concave if a1 < 0 and convex if a1 > 0.

As I said though, there may be an easier way... I just cannot think of it at this time.

Cheers,

Timkin
Using the below image as a guide:



Take the cross-product of N1 with the line AB, call this vector V. Choose V s.t. V dot BC is < 0 (if it > 0, simply negate it). Take the dot-product of this vector with N2. If that''s < 0 then the triangles are concave.

Actually this looks similar to Timkin''s method, but mine had pictures

If I had my way, I''d have all of you shot!

codeka.com - Just click it.

This topic is closed to new replies.

Advertisement