sunjianhua / poly2tri

Automatically exported from code.google.com/p/poly2tri
Other
0 stars 0 forks source link

New vertex with strange position #59

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is the input polygon:

8.51 5.4999999999999805,
8.500000000000007 5.499999999999969,
8.65 5.65,
8.65 5.800000000000001,
8.61 5.799999999999992,
8.56 5.65

These are the output unique vertices

8.51 5.4999999999999805,
8.65 5.65,
8.500000000000007 5.499999999999969,
8.694999999999999 5.409999999999959,
8.409999999999998 5.409999999999959,
8.65 5.800000000000001 

Note the vertex with 8.69 x coordinate. This is in JS version.

Original issue reported on code.google.com by dusan.ma...@gmail.com on 8 Oct 2012 at 10:59

GoogleCodeExporter commented 9 years ago
If possible try to round your input to a precision that you can live with and 
not have individual points just differentiate in the 16th decimal. You will be 
bound to run into some floating point issues.

poly2tri should under no circumstances alter the values of any points. 

poly2tri do add 2 points to the pointset it tries to triangulate so it can 
start of with a triangle. These are removed when finished tho. 

A longshot guess is that the triangulation fails due to some precision issue 
and that you might be looking at some defect result. Still can't understand why 
two points are missing. 

Original comment by thahlen@gmail.com on 8 Oct 2012 at 4:12

GoogleCodeExporter commented 9 years ago
I tried upscaling the input with no effect.

Original comment by dusan.ma...@gmail.com on 8 Oct 2012 at 5:04

GoogleCodeExporter commented 9 years ago
On closer inspection that point set will not work on any on the poly2tri 
version since it's not a simple polygon.

It has crossing edges and the shape is more like an 8. Swap the first two 
points and you get a simple polygon and the triangulation should work.

poly2tri has no input validation and assumes you feed it simple polygons.

Original comment by thahlen@gmail.com on 9 Oct 2012 at 12:06