intersection

Testing for ray-sphere intersection

I am trying to determine whether a line segment (i.e. between two points) intersects a sphere. I am not interested in the position of the intersection, just whether or not the segment intersects the sphere surface. Does anyone have any suggestions as to what the most efficient algorithm for this would be? (I'm wondering if there are any ...

Mathematical technique to check intersection

Imagine there is a very very large room in the shape of a hollow cube. There are magic balls hanging in the air at fixed discrete positions of the room. No magic ball has another one exactly above it. If we take an imaginary horizontal plane of infinite area and pass through the cube, how can we be sure that the plane doesn't cut through...

array_intersect_key PHP array with MYSQL database

I have a simple array in PHP, say [1, 2, 4, 5, 6, 7] and I wish to query a MYSQL database [1, who] [2, where] [3, some] [6, there] [9, too] I only wish to receive the rows of intersection between the PHP array and the database's indices column. So this would result in [1, who] [2, where] [6, there] Any ideas? Thanks! ...

LINQ: Find all intersecting data, not just the unique values

I thought that I understood Intersect, but it turns out I was wrong. List<int> list1 = new List<int>() { 1, 2, 3, 2, 3}; List<int> list2 = new List<int>() { 2, 3, 4, 3, 4}; list1.Intersect(list2) => 2,3 //But what I want is: // => 2,3,2,3,2,3,3 I can figure a way like: var intersected = list1.Intersect(list2); var lis...

efficiently knowing if intersection of two list is empty or not, in python

Hi! Suppose I have two lists, L and M. Now I want to know if they share an element. Which would be the fastest way of asking (in python) if they share an element? I don't care which elements they share, or how many, just if they share or not. For example, in this case L = [1,2,3,4,5,6] M = [8,9,10] I should get False, and here: L...

Area of intersection of n circles each having radius 'r'.

Prob Statement: 'N' equii radii circles are plotted on a graph from (-)infinity to (+)infinity.Find the total area of intersection i.e all the area on the graph which is covered by two or more circles. Please refer to the below image for better view. ...

3D intersection test

Hi, I have this 3D model loaded.Then on the same screen, I have many points draw on it.. how Can I determine whether the points are on the model or not.Only take the XY plane for consideration. Anyone can teach me how to do a 3D intersection test only on the XY plane, because Im really clueless. ...

2d game : fire at a moving target by predicting intersection of projectile and unit

Okay, this all takes place in a nice and simple 2D world... :) Suppose I have a static object A at position Apos, and a linearly moving object B at Bpos with bVelocity, and an ammo round with velocity Avelocity... How would I find out the angle that A has to shoot, to hit B, taking into account B's linear velocity and the speed of A's ...

fast sphere-grid intersection

hi! given a 3D grid, a 3d point as sphere center and a radius, i'd like to quickly calculate all cells contained or intersected by the sphere. Currently i take the the (gridaligned) boundingbox of the sphere and calculate the two cells for the min anx max point of this boundingbox. then, for each cell between those two cells, i do a bo...

Good acceleration structure for ray sphere tests with spheres that move

Hi! I'm looking for the proper acceleration structure to do ray-sphere intersection tests (in a game). the following conditions apply: -there are arround 100 spheres and 100 rays to test against each other per frame -the spheres move in each frame, so do the rays -there can be rays/spheres added/removed in each frame (but most of the...

How do I intersect two lists in OCaml?

When I have two lists in OCaml, for example e1 = [3; 4; 5; 6; 7] and e2 = [1; 3; 5; 7; 9] Is there an efficient way to get the intersection of those two lists? I.e.: [3; 5; 7] Because I don't like scanning every element in list e2 for every element in list e1, thus creating a big Oh of order n^2. ...

To find points of intersection between straight lines & our figure in matlab

We are doing a project on ear recognition. We have got the edges of the ear in a figure & have found the centroid of each. We have also drawn lines from the centroid at 10 degree intervals. Now we need to know how to find the points of intersection of these lines with our ear edges in matlab. Any help would be greatly appreciated. ...

Efficient intersection of two List<String> in Java?

Question is simple: I have two List List<String> columnsOld = DBUtils.GetColumns(db, TableName); List<String> columnsNew = DBUtils.GetColumns(db, TableName); And I need to get the intersection of these. Is there a quick way to achieve this? ...

Can set_intersection be used with hash_set in C++?

I am calculating intersection, union and differences of sets. I have a typedef of my set type: typedef set<node_type> node_set; When it is replaced with typedef hash_set<node_type> node_set; The results are different. It's a complicated program, and before I start debugging - am I doing it right? When I use functions like this: s...

Crossing-section-of-a-3d-mesh-object-in-an-arbitrary-coordinate-point

Hi All, (Yesterday, I had a question about cross section. Sorry due to repeating the question. I could not use the "edit" property of the page since it was not available on the screen.) Could one explain me how to have the points that are on the intersection curve of a 3d mesh object and a plane. Regards J.Jack ...

.NET Ascertaining mouse is on line drawn between two arbitrary points

I have an arrow drawn between two objects on a Winform. What would be the simplest way to determine that my mouse is currently hovering over, or near, this line. I have considered testing whether the mouse point intersects a square defined and extrapolated by the two points, however this would only be feasible if the two points had ve...

R optimization: How can I avoid a for loop in this situation?

I'm trying to do a simple genomic track intersection in R, and running into major performance problems, probably related to my use of for loops. In this situation, I have pre-defined windows at intervals of 100bp and I'm trying to calculate how much of each window is covered by the annotations in mylist. Graphically, it looks somethi...

Intersections of 3D polygons in python

Are there any open source tools or libraries (ideally in python) that are available for performing lots of intersections with 3D geometry read from an ESRI shapefile? Most of the tests will be simple line segments vs polygons. I've looked into OGR 1.7.1 / GEOS 3.2.0, and whilst it loads the data correctly, the resulting intersections ar...

Ray-box Intersection Theory

Hello: I wish to determine the intersection point between a ray and a box. The box is defined by its min 3D coordinate and max 3D coordinate and the ray is defined by its origin and the direction to which it points. Currently, I am forming a plane for each face of the box and I'm intersecting the ray with the plane. If the ray intersec...

Django Querying Question

If I were to have two different QuerySets in Django, both representing a ManyToMany relation with the same model, how would I find the intersections? ...