ivvaan / balaban-segments-intersections Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/balaban-segments-intersections
Automatically exported from code.google.com/p/balaban-segments-intersections
I've tried the following snippet
TLineSegment1 segment;
segment.org = TPlaneVect{0, 0};
segment.shift = TPlaneVect{1, 1};
TLineSegment1 segs[] = {segment, segment};
auto seg_type = line1;
int4 alg = optimal;
int4 n = 2;
SimpleCounter reg;
reg.counter = 0;
CLine1SegmentCollection<SimpleCounter> coll;
coll.Init(n, segs);
coll.SetRegistrator(®);
COptimalIntFinder fi;
fi.prepare_ends(&coll);
fi.find_intersections(&coll);
and reg.counter
is 0
, which is odd, I've expected it to be 2
. Am I missing something or algorithms don't handle overlapping segments?
If segment intersection functions would return not only a boolean result (is the segment pair intersecting inside the stripe) but also the parity of the intersection number, we could use the same trick for nonline segments as we did for line segments to speed up the algorithm.
If the current segment intersects the ladder stair below with an odd number of points, it cannot intersect any stair above (and vice versa), and the appropriate intersection checks can be removed.
So, the return value needs to be 0,1 or 2.
0 - no intersections
1 - odd intersection number
2 - even intersection number
Other changes are rather straightforward: if a nonline segment intersection number is odd, treat it as a line segment.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.