intersection

Checking the Intersection of Two Collections via HQL

I have an class which has a collection, mapped as a bag in my nHibernate mapping file for that class, and I wish to return all instances of that class whose collection has a one or more of the objects which I pass in. Example: My Parent Class is called DocumentDefinition. It has a collection of Roles, which is a nHibernate entity, that...

How to get DFA intersection ?

How do we combine two dfa using intersection method ? ...

Test if lists share any items in python

I want to check if any of the items in one list are present in another list. I can do it simply with the code below, but I suspect there might be a library function to do this. If not, is there a more pythonic method of achieving the same result. In [78]: a = [1, 2, 3, 4, 5] In [79]: b = [8, 7, 6] In [80]: c = [8, 7, 6, 5] In [81...

Clustering after minimum spanning tree cut

What would be the optimal way of clustering nodes after cutting a MST with a maximum edge-length? My output from MST edge-length cut is a 2xN array where each element is an integer. The integers are the node identifiers that describe the edges. An example of the output would is given below: >>> print array[0:3] [[ 0 1] [ 0 2] [...

Calculate a vector from a point in a rectangle to edge based on angle

According to Daniel, in his answer, there is no easy way to modify the below function so I bit the bullet and started from scratch. Solution is below (as an answer). Actually, ignore my answer. See Tom Sirgedas' answer it's a lot shorter. I need to modify the solution found here: http://stackoverflow.com/questions/1343346/calculate-a...

Range intersection / union

Hello, I'm developing a programming language for which I want to provide a Range data type which for now is, not as usually, a list of pairs of int values (x,y) with the constraint that x < y. I say not as usually because usually a range is just a pair but in my case it is more than than, allowing to have for example 1 to 5, 7 to 11, 13...

Can I determine the self-intersection points of a line created using the .NET C# GraphicsPath class?

I would like to create a line path using the GraphicsPath class in C#, consisting of multiple curves and lines. Would it be possible for me to determine any self-intersecting points of the class, and in the order that they appear? e.g. as an ordered array of points. ...

numpy join entries intersecting at a cell

In numpy, how can I join the entries that intersects at a cell? For example: In the example, I want to join rows/columns B and F into one row/column BF, where each element is the average of the ones with the same color. ...

Merging two complex queries.

What I ended up doing was taking two SQL queries and using the array_intersect() in PHP to filter out the results: $sql1 = 'SELECT z.*, u.username, u.user_colour, u.username_clean, u.user_avatar, u.user_avatar_type FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u WHERE (( z.user_id = ' . $user->data['user_id'] . ' AND z...

Computing number of arrays containing an element in perl

I think I've just been looking at this too long. I have some data that looks like this: @a = ( { name => 'ethan', depth => 0 }, { name => 'victoria', depth => 1 }, { name => 'stephen', depth => 2 }, { name => 'christopher', depth => 3 }, { name => 'isabella', depth => 2 }, { name => 'ethan', depth => 3 }, { ...

Circle-circle intersection points

How do I calculate the intersection points of two circles. I would expect there to be either two, one or no intersection points in all cases. I have the x and y coordinates of the centre-point, and the radius for each circle. An answer in python would be preferred, but any working algorithm would be acceptable. ...

Howto Select rows that match the intersection of multiple rows in other tables in MYSQL?

It seems complicated (and probably it is). But i cant imagine how to solve this. There are tables: COMPANIES id | name 1 | Google 2 | Samsung 3 | Microsoft PARAGRAPHS id | name 1 | Header 2 | Body 3 | Footer TAGS id | tag 1 | Internet 2 | Softwate COMPANIES_VS_TAGS id | company_id | tag_id 1 | 1 | 1 2 | 2 | 2 3 | 3 | 1 4 | 3 |...

How can I create a parallel polyline without self intersections?

The simple algorithm to create a parallel polyline to an existing polyline is simple: you can calculate the normal of each vertex (as the average of the segment's normals) and displace the vertices using the normal with whatever amount you want. However, there's a graphical problem when I try to use this algorithm on a curved polyline, ...

Implement “intersection” method using java

How can i implement “intersection” method using java by recieve 2 integer parameters and return integer intersection point. ...

INTERSECT 2 tables in MySQL

Hi, I need to intersect two tables based on a column,in both tables. Here's my code snippet : SELECT b.VisitID, b.CarrierName, b.PhoneNum, b.PatientName, b.SubscriberID, b.SubscriberName, b.ChartNum, b.DoB, b.SubscriberEmp, b.ServiceDate, b.ProviderName, b.CPTCode, b.AgingDate, b.BalanceAmt, f.FollowUpNote, f...

finding the intersection of 3 spheres

im trying to find the intersection of 3 spheres in space but the problem is i need to use this math in a code which will have the x and y intercepts fixed but leave the z intercept a variable. for example: (x+6)^2 + (y+3.464102)^2 + (z-j)^2 = 12^2 (x-6)^2 + (y+3.464102)^2 + (z-k)^2 = 12^2 x^2 + (y-6.928203)^2 + (z-l)^2 = 12^2 any ...

How can I tell if two polygons intersect?

Hello, Imagine I have the coordinate of 4 points that form a polygon. These points are represented using PointF in C#. If I have 2 polygons (using 8 points), how can I tell if they intersect? Rectangle class has a method called IntersectsWith but I couldn't find something similar for GraphicsPath or Region. Any advice would be grea...

Java Implementation of Rectangle Intersection Algorithm..?

Hi, I am interested in this algorithm: http://stackoverflow.com/questions/115426/algorithm-to-detect-intersection-of-two-rectangles but unable to implement it myself lacking even basic mathematical skills. I think I could understand it better once I can read the code. Does somebody perhaps have already an implementation or can quickly ...

How can I efficiently detect intersection detection of a ray and a mesh?

I have several 3d models in an OpenGL ES application for iPhone and at some point i want the user to touch the screen and act on them. The problem is to recognize which, among the ones rendered on the screen, has been touched. In order to achieve this I calculated the picking ray as suggested by the OpenGL FAQ, and I now want to detect i...

How can I compute the picking ray with multiple model view matrixes?

I'd like to compute the intersection between a ray and the models the user sees on the screen of my app. I'm following the OpenGL guide but I have many models in the scene that I draw independently and dynamically in a push-pop context applying a translate to the current modelview matrix (ie for each model I do a glPushMatrix, glTrans...