Comments (4)
Hi @frastlin
Of cause polygon in this library supports holes.
In order to be displayed as a hole, face should be simply placed inside another face - "island".
But if you want to distinguish between islands and holes in algorithms, like area measurement, inclusion check or boolean operations, islands and holes should have opposite orientations: for instance, if islands are oriented clockwise (Flatten.ORIENTATION.CW
), holes have to be oriented counter clockwise (Flatten.ORIENTATION.CCW
).
If you are not sure which orientation the face has, use this code to detect and, if need, revert orientation:
let face = polygon.addFace(points.map(([x, y]) => new Point(x, y)));
if (face.orientation() !== Flatten.ORIENTATION.CCW) {
face.reverse();
}
Note, that when orientation calculated, axe Y is considered to direction from down up, like in math.
Best regards,
Alex Bol
from flatten-js.
OK, I can't seem to make this work with the contains(point) or distanceTo algorithm. if I do a distanceTo algorithm in the middle of a hole, it should give me the distance to the nearest points, and if I do a check in the hole, I would expect it not to say I'm in a polygon.
from flatten-js.
Can you send me your data?
from flatten-js.
I figured it out, my points were not correct. If you do the counterclockwise for the hole and clockwise for everything else, that works perfectly.
from flatten-js.
Related Issues (20)
- Bad performance with boolean operations HOT 2
- Typings exported incorrectly HOT 1
- Intersect ray with ray or line HOT 1
- Support stroke-dasharray HOT 4
- Cannot figure out a workaround for INFINITE LOOP while unifying polygons HOT 4
- Add method to easy check equal polygons HOT 9
- Incorrect return type on `Relations.relate`
- Infinite Loop when intersecting Polygons (v1.3.4) HOT 7
- fillOpacity is not being used when applying svg() on Box type ( translated to Rect ) HOT 1
- IntervalTree search is a bottleneck HOT 14
- feature request: construct Arc from the parameters used in SVG HOT 3
- v1.4 Relations.intersect() doesn't allow Polygon argument HOT 3
- ray and segment intersect HOT 5
- HELP - What is the best way to create parallel segments ? HOT 3
- Adding Point to Vector HOT 3
- Errors export HOT 2
- Cannot cut polygon with MultiLine HOT 3
- Can I merge duplicated edges and merge faces in Polygon? HOT 3
- Segment Wrong points after rotate? HOT 4
- Exported type not found HOT 1
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 flatten-js.