Comments (3)
Looking at your set of values this is most likely a result of lack of floating
point precision.
This is because of your data range. If you translate and scale your point
values to be in the range -1 and 1 you should be fine I think.
Just translating to be in centered around 0 should be enough but the epsilon
used in the lib is tuned for values in the range 0 and 1. So scaling helps with
precision tests to.
Original comment by [email protected]
on 6 Mar 2014 at 6:03
from poly2tri.
So if you have your points in an array[] you should try this:
Sometime you might also have to round values to 12 decimals since poly2tri uses
en epsilon of 1.0e-12 for some tests.
double d;
double[] range = new double[] { Double.MAX_VALUE,
Double.MIN_VALUE,Double.MAX_VALUE, Double.MIN_VALUE };
double[] center = new double[2];
for( int i=0; i<array.length; i += 2 )
{
range[0] = Math.min( array[i], range[0] );
range[1] = Math.max( array[i], range[1] );
range[2] = Math.min( array[i+1], range[2] );
range[3] = Math.max( array[i+1], range[3] );
}
center[0] = (range[0] + range[1])/2;
center[1] = (range[2] + range[3])/2;
if( (range[1]-range[0]) > (range[3]-range[2]) )
{
d = 2/(range[1] - range[0]);
}
else
{
d = 2/(range[3] - range[2]);
}
for( int i=0; i<array.length; i += 2 )
{
array[i] = d*(array[i] - center[0]);
array[i+1] = d*(array[i+1] - center[1]);
}
Original comment by [email protected]
on 6 Mar 2014 at 6:24
from poly2tri.
This was a precision issue in input data
Original comment by [email protected]
on 2 Apr 2014 at 9:47
- Changed state: WontFix
from poly2tri.
Related Issues (20)
- CMake build script
- Inconsistent behavior with holes that share a point HOT 17
- add typedef for "double"
- add typedef for std::vector<Point*>, std::vector<Triangle*> and other containers
- java version compile error HOT 3
- Polygon.getHoles() missing HOT 5
- poly2tri crashes on a very simple geometry HOT 1
- crash with attached polygon HOT 2
- Crash when triangulating a polygon HOT 1
- crash with square polygon HOT 1
- Java source unbuildable in 1.7+
- Build failed when compliling with -we4715
- Java findbugs - nullcheck of value previously dereferenced HOT 1
- [java] Tessellation with hole error HOT 4
- Polygon with hole HOT 10
- [java] Missing triangle in non-constrained delaunay HOT 3
- Problem building library
- the EPSILON value is not exported in the python/cython version HOT 1
- Compilation fails with MSVC
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poly2tri.