polygon triangulation

Started by
20 comments, last by FugueInCPP 19 years, 9 months ago
I read about ear-clipping from the following paper::

www.magic-software.com/Documentation/ TriangulationByEarClipping.pdf

i don't see it discussing about handling holes. Could u send me the link of the paper that shows info. about handling holes with examples.

Also, I don't see in the code about how it handles holes.

~ Matt
Advertisement
Here's a post by David Eberly (Magic Software guy) that discusses triangulation with holes:

Triangulation of Polygon with Holes
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Quote:Original post by quasar3d
That bsp tree method is just overkill imho, and it will result in much more triangles than necessary.


but the Delaunay triangulation usually creates extra triangles
too. The BSP method is the fastest method since you no longer need to think about the algorithms + you don't need to worry about ear clipping.

Anyway, I've thought of another possible procedure:
1. take each point of each hole and connect an edge to
the nearest point not on the hole.
2. create polygons from the remaining 2D subspaces and ear
clip them.

Please let me know if there is a flaw in this algorithm somewhere.
I think I am probably mistaking what you mean with a polygon with holes. I thought you just ment a concave polygon, as the C example you gave is a concave polygon. But in the link ghrodes posted, they mention both concave polygons and polygons with holes, so I guess they are something different then. So what's exactly the difference between a concave polygon and a polygon with wholes? Probably an O shape or so?
Could you help me out understanding the below piece of code from ear-clipping algo.::

What does this line check?

if ( EPSILON > (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) ) return (0);

Ax,Ay,Bx,By,Cx,Cy being the three vertices of a triangle that is formed out of the polygon.

thanks,

Matt

That line looks as though it is checking if the point C is on the "right" of the infinite line formed by AB. So essentially if the angle formed by ABC is < 180 degrees (within tolerance).

Check out this page for an explanation of the 2d vector cross product (which is what is being used here).
thank you for your reply. Thatz an awesome site!! but where do I find a similar explanation for 3D especially

a) find the area of a polygon in 3D;
b) clockwise test for polygons in 3D;
c) convex/concave test ......

Appreciate your input on this.

~ Matt
if ( EPSILON > (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) ) return (0);

Ax,Ay,Bx,By,Cx,Cy being the three vertices of a triangle that is formed out of the polygon.

"That line looks as though it is checking if the point C is on the "right" of the infinite line formed by AB. So essentially if the angle formed by ABC is < 180 degrees (within tolerance)."

Inorder to continue this explanation to 3D, I guess I could check for EPSILON > |cross-product of vectors formed by adjacent sides of the polygon in 3D|.

Because, if the vectors are parallel, their length of cross-product would be 0 as it would be a zero vector.

clarify this!!

~ Matt
Quote:Original post by taurean
thank you for your reply. Thatz an awesome site!! but where do I find a similar explanation for 3D especially

a) find the area of a polygon in 3D;
b) clockwise test for polygons in 3D;
c) convex/concave test ......

Appreciate your input on this.

~ Matt


a) See response to your other post on this subject.

b) You just project into a 2D plane and do the 3D->2D projection thing, since in 3D you might be looking at the polygon from either side----in 3D it is both clockwise *and* counterclockwise!

c) Did the ear-clipping articles not discuss this? Well any, a polygon is concave (in the 2D sense) if any interior angle is > 180 degrees.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Quote:Original post by grhodes_at_work

1) Choose one vertex of the polygon to be the local origin, O = (O.x, O.y, O.z).

2) Create a unit vector from O to the next vertex along an edge connected to O. Call the unit vector X = (X.x, X.y, X.z). This will be the direction of the X axis in the 2D plane in which you will be doing the triangulation

3) Find a unit normal vector to the polygon by taking X and any other edge that is not parallel to X and doing a cross product. (See articles here at gamedev or do a forum search to learn how to do a cross product). Call the normal Z = (Z.x, Z.y, Z.z).

4) Do another cross product, Y = Z cross X, and normalize it for good measure. (We need to make sure it has length 1.0).

5) Now, X and Y are the two directions that define the plane in which you will do the triangulation.

6) Form a 3 x 3 rotation matrix:

    [X.x X.y X.z]R = |Y.x Y.y Y.z|    [Z.x Z.y Z.z]


This is the so-called "world to object" rotation matrix, which maps vectors in world space into the coordinate system of interest, e.g., it converts vectors in world space into the coordinate system given by X, Y, and Z. The transpose of R is the object to world rotation matrix, which takes vectors in the object's space and maps them to the world. (The tranpose rules is only true if R contains no scaling factors...this one does not, since we made sure X, Y, and Z all had length 1.0).

7) Now, map all your polygon vertices:

V_mapped = R * (V_world_space - O)

8) Now that all your vertices are mapped, your V_mapped vectors *are* the 2D vertices you need! Just drop the Z coordinate!



Well, I understood the above concept of shifting each 3D vertices to 2D vertices. How does this differ from finding the normal of the polygon by taking cross - product of 2 vectors of adjacent sides of polygon; and then with the absolute coefficients of N.x, N.y, N.z; strip the one coefficient from 3d vertices that is greater than the other two to make the 2d set of vertices. (This doesn't involve any rotation or matrix either !! )

??

~ Matt

This topic is closed to new replies.

Advertisement