#### Archived

This topic is now archived and is closed to further replies.

# detecting if 2 triangles are concave or convex.

This topic is 5866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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

##### Share on other sites
Is there such a thing as a "concave" triangle? It only has 3 sides.

"I thought Genius lived in bottles..." - Patrick Star

##### Share on other sites
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.

##### Share on other sites
I haven''t thought this all the way through, but what about the angle between the normals?

##### Share on other sites
Easy. If N1 . N2 < π then the triangles are concave. If not, they''re convex or parallel. Assuming your normals are normalised, of course.

##### Share on other sites
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]              |

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 24
• 9
• 57
• ### Forum Statistics

• Total Topics
632640
• Total Posts
3007615
• ### Who's Online (See full list)

There are no registered users currently online

×