4 points -> 1 triangle ?? (c#)

92 views
Skip to the first unread message

erg

unread,
09 Mar 2014, 11:15:572014/03/09
to poly...@googlegroups.com
Forgive me if I'm dramatically misunderstanding something, but:


            List<TriangulationPoint> pts = new List< TriangulationPoint >();
            pts.Add( new TriangulationPoint(266, 68) );
            pts.Add( new TriangulationPoint(335, 189));
            pts.Add( new TriangulationPoint(394, 259));
            pts.Add( new TriangulationPoint(401, 230));
            var ps = new PointSet( pts );
            P2T.Triangulate( ps );
            Console.WriteLine( ps.Triangles.Count );


only produces a single triangle... I tried changing the ordering, perturbing the points, etc. Is this to be expected?

obi

unread,
09 Mar 2014, 13:29:522014/03/09
to poly...@googlegroups.com
I suggest you triangulate it like a Polygon instead of PointSet.

So replace new PointSet( pts ) with new Polygon( pts );

erg

unread,
09 Mar 2014, 17:04:512014/03/09
to poly...@googlegroups.com
Yeah, I saw that it properly triangulates that data if passed in as poly.

The problem is that I'm not generally triangulating polygons, I'm triangulating point clouds of arbitrary (4+) length.

Is there some explanation for this behavior? (Perhaps I am misunderstanding something basic?)

I am capable of pre-processing the data, I just need to know the constraints / conditions to watch for.

obi

unread,
13 Mar 2014, 03:43:112014/03/13
to poly...@googlegroups.com
I have confirmed this issue. This is an issue in the Java and C# version since they are the only ones that support PointSet and ConstrainedPointsets triangulations.

The result we want when triangulating a point set is a delaunay triangulation bounded by the convex hull of the point set. The issue is that now the same algorithm is used as for triangulating polygons, e.g. two additional point are added before triangulation that are outside the rectangular bound of the point set and after the triangulation they are removed with any connected triangle. This works perfectly in the case of polygons but with point sets the added point actually alter the DT somewhat so we can lose triangles that should be part of the convex hull of the original point set. 
The reason poly2tri add two points is that in supplied point set the three first point can be collinear, adding two starting points solve this problem.

See added picture for visual explanation of the issue: What you see is that the added points used for triangulation alter the delaunay graph. The blue edge is what we want to get for the valid convex hull, but the added corner point gives another triangulation. When removing these points and connected triangles we will actually lose one triangle.

The problem poly2tri needs to solve working with a point set is actually both get a triangulation and a convex hull of the points.

If you want an immediate solution can you compute the convex hull of the point set and use that as a polygon and add the rest of the points as steiner points?
This way you will get your triangulation of points by using the existing and working polygon triangulation.

Sorry for this oversight in the point set triangulator didn't consider this issue when adding the functionality. I am a bit busy with other projects right now but will take a look at this at some point.
poly2tri_convex_hull.png
Reply all
Reply to author
Forward
0 new messages