Detecting Degenerate Triangles?

Community Forums/General Help/Detecting Degenerate Triangles?

Gabriel(Posted 2010) [#1]
Is there a recognized way of detecting degenerate (where all three vertices are colinear) triangles? I'm thinking along the lines of using the dot product between the edges, and if they're all either 1 or -1 (with a small epsilon value) then the triangle would presumably be degenerate. Just wanted to make sure that there are no holes in this theory and to make sure there's not a better (faster) way.


Warpy(Posted 2010) [#2]
vertices at (x1,y1), (x2,y2), (x3,y3).

dx1=x2-x1
dy1=y2-y1

dx2=x3-x1
dy2=y3-y1

colinear if dx2/dx1 = dy2/dy1 (or dx1=dx2=0 or dy1=dy2=0)


Floyd(Posted 2010) [#3]
This is likely a 3D question, (x1,y1,z1) etc.

For numerical reasons it is probably better to detect "close to zero". This suggests using the cross product instead of the dot product.

The magnitude of the cross product depends on the lengths of the vectors and the sine of the angle between them. Sine will be near zero when the angle is near 0 or 180.

The tricky part is the practical choice of epsilon. How close to zero is close enough?


Difference(Posted 2010) [#4]
I calculate the triangle area. If it's close to zero, I consider the triangle degenerated.


Floyd(Posted 2010) [#5]
That's another vote for cross product.

The length of the cross product is twice the area of the triangle.