intersection

python date interval intersection

dear all, As a matter of general interest I'm wondering if there's a more elegant/efficient way to do this. I have a function that compares two start/end tuples of dates returning true if they intersect. from datetime import date def date_intersection(t1, t2): t1start, t1end = t1[0], t1[1] t2start, t2end = t2[0], t2[1] if ...

Negating the truthiness of a boolean evaluation causing 5x slowdown?

I'm trying to implement an octree, and for that, I need a fast AABB-ray intersection algorithm. After some searching, I came across this paper that seemed to offer that. From the source code, available here, I translated the pluecker_cls_cff function to C# as this: public bool Intersect_2(ref RayPluecker r) { switch (r.Classification)...

Line intersection with AABB Rectangle?

Preferably without using any kind of loop, as this'll be used in a game. I wish to intersect a line with a rectangle, of arbitrary size. But I also wish for the intersection point[s] to be returned. It's possible, I've done a little googling, but still have not worked it out. The line is defined using (x1,y1,x2,y2). The rectangle has ...

NHibernate intersection

Hi, How can i do intersection in nhibernate? is select enterprise.Id from Enterprises intersect select enterpiseID from vEnterprise ...

Python -Intersection of multiple lists?

I am playing with python and am able to get the intersection of two lists: result = set(a).intersection(b) Now if d is a list containing a and b and a third element c, is there an built-in function for finding the intersection of all the three lists inside d? So for instance, d = [[1,2,3,4], [2,3,4], [3,4,5,6,7]] then the result sh...

Collision test between a triangle and a rectangle (AABB) in 2D

I've spent a good amount of time getting intersections working correctly between various 2D shapes (circle-circle, circle-tri, circle-rect, rect-rect - a huge thanks to those who've solved such problems from which I drew my solutions from) for a simple project and am now in the process of trying to implement an triangle-AABB intersection...

Algorithm for finding intersection point between two arcs

I am working in c# with directX, i need to find the intersection point between two arcs I searched the net but didn't find anything. I have StartPoint,EndPoint,StartAngle,EndAngle,Centre,Radius for both Arcs, now i need Algorithum or formula for finding intersection points between the two Arcs. ...

MySQL query, intersection on many-to-many relationship

Does someone have a good idea/solution how to achieve this? Situation is: I have the tables 'releases' and 'ntags', related via 'releases_ntags' (containing 'release_id' and 'ntag_id') And I would like to fetch results for releases via the ntag's 'slug'. I manage to have this semi-working: sql SELECT r.id, r.name FROM releases r LE...

Non-LINQ implementations of Union, Intersect, and Except

LINQ to objects has the incredibly useful Union, Intersect, and Except methods. Sadly, there's a client I'm doing work for and they are mandating .NET 2.0 so LINQ is not an option. I looked through the reflected code and it didn't reverse well at all. Is there a .NET 2.0 library or easy implementation of Union, Intersect, and Except? ...

Set_union/Set_intersect for more than two sets in c++

I know those commands are for two sets. Does there any simple and fast way to do this for more then two sets. I think I can use some kind of loop for this but maybe there are better way. Thank you ...

How to determine if line intersect simple polygon?

Hi, I need to know how to determine fast if line intersects simple polygon. It should work in O(log n) time, where n is number of polygon's vertexes. I searched in google, but I didn't find anything useful, maybe I'm blind. ;) Edit: I'm using C++ but I think language isn't a problem, and it isn't homework, just doing some algorithms trai...

Need help with merging two data collections

Hello! I need to retrieve all items from two lists that contains a given value. Example: var list1 = { new Dummy(){ Name = "Dummy1", Number = 1 }, new Dummy(){ Name = "Dummy2", Number = 2 }, new Dummy(){ Name = "Dummy3", Number = 3 } }; var list2 = { new Dummy(){ Name = "Dummy4", Number = 4 }, new Dummy(){ Name = ...

How to intersect multiple sets?

I have this list: private List<Set<Address>> scanList; So my list contains multiple scans as you can see. After each scan I add new set into the list. After all scans are finished I would like to take only the addresses that occur in every set and put it into: private List<Address> addresses; Does something like this already exist...

Full Join/Intersection in couchdb

Hi, I have some documents which have 2 sets of attributes: tag and lieu. Here is an example of what they look like: { title: "doc1", tag: ["mountain", "sunny", "forest"], lieu: ["france", "luxembourg"] }, { title: "doc2", tag: ["sunny", "lake"], lieu: ["france", "germany"] }, { title: "doc3", tag: ["sunny"], lieu: ["b...

Line and Line Segment intersection

How can I detect whether a line (direction d and -d from point p) and a line segment (between points p1 and p2) intersects in 2D? If they do, how can I get their intersection point. There are lots of example how to detect whether two line segments intersects but this should be even simpler case. I found this but I do not understand wha...

Checking if two cubic Bézier curves intersect

Hello guys, For a personal project, I'd need to find out if two cubic Bézier curves intersect. I don't need to know where: I just need to know if they do. However, I'd need to do it fast. I've been scavenging the place and I found several resources. Mostly, there's this question here that had a promising answer. So after I figured wha...