intersection

Checking if two cubic Bézier curves intersect

ぐ巨炮叔叔 提交于 2019-11-26 19:08:52
问题 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 what is a Sylvester matrix, what is a determinant, what is a resultant and why it's useful, I thought I figured how the solution works. However, reality begs to differ, and it

How to check intersection between 2 rotated rectangles?

一笑奈何 提交于 2019-11-26 18:46:16
Can someone explain how to check if one rotated rectangle intersect other rectangle ? For each edge in both polygons, check if it can be used as a separating line. If so, you are done: No intersection. If no separation line was found, you have an intersection. /// Checks if the two polygons are intersecting. bool IsPolygonsIntersecting(Polygon a, Polygon b) { foreach (var polygon in new[] { a, b }) { for (int i1 = 0; i1 < polygon.Points.Count; i1++) { int i2 = (i1 + 1) % polygon.Points.Count; var p1 = polygon.Points[i1]; var p2 = polygon.Points[i2]; var normal = new Point(p2.Y - p1.Y, p1.X -

Finding where two linear fits intersect in R

可紊 提交于 2019-11-26 18:22:42
问题 I have two linear fits that I've gotten from lm calls in my R script. For instance... fit1 <- lm(y1 ~ x1) fit2 <- lm(y2 ~ x2) I'd like to find the (x,y) point at which these two lines ( fit1 and fit2 ) intersect, if they intersect at all. 回答1: One way to avoid the geometry is to re-parameterize the equations as: y1 = m1 * (x1 - x0) + y0 y2 = m2 * (x2 - x0) + y0 in terms of their intersection point (x0, y0) and then perform the fit of both at once using nls so that the returned values of x0

The opposite of Intersect()

≡放荡痞女 提交于 2019-11-26 18:21:44
Intersect can be used to find matches between two collections, like so: // Assign two arrays. int[] array1 = { 1, 2, 3 }; int[] array2 = { 2, 3, 4 }; // Call Intersect extension method. var intersect = array1.Intersect(array2); // Write intersection to screen. foreach (int value in intersect) { Console.WriteLine(value); // Output: 2, 3 } However what I'd like to achieve is the opposite, I'd like to list the items that are missing when comparing two collections: // Assign two arrays. int[] array1 = { 1, 2, 3 }; int[] array2 = { 2, 3, 4 }; // Call Intersect extension method. var intersect =

Test if lists share any items in python

妖精的绣舞 提交于 2019-11-26 18:07:12
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]: def lists_overlap(a, b): ....: for i in a: ....: if i in b: ....: return True ....: return False ....: In [82]: lists_overlap(a, b) Out[82]: False In [83]: lists_overlap(a, c) Out[83]: True In [84]: def lists_overlap2(a, b): ....: return len(set(a).intersection(set

Efficiently find points inside a circle sector

南笙酒味 提交于 2019-11-26 17:58:57
问题 I have a set of 2d points distributed randomly. I need to perform a time intensive operation on a small subset of these points but I need to first figure out what points I need to perform this time intensive operation on. To determine what points I need they must pass a series of geometric criteria. The most basic criteria is are they within a certain distance of a specific point. The second most basic criteria is whether they are contained within a circle sector (a 2-D cone) extending out

Java- Intersection point of a Polygon and Line

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 14:23:04
问题 Is there any function that will give me the intersection point of a Polygon and Line2D ? I have a Polygon and a line segment that I know intersect I want the actual value of the intersection point not a boolean answer. 回答1: Here you are. The interesting methods are getIntersections and getIntersection. The former parses over all polygon segments and checks for intersections, the latter does the actual calculation. Do keep in mind that the calculation can be seriously optimized and doesn't

How to calculate the intersection of two sets? [duplicate]

依然范特西╮ 提交于 2019-11-26 12:50:16
Possible Duplicate: Efficiently finding the intersection of a variable number of sets of strings Say, have two Hashset, how to calculate the intersection of them? Set<String> s1 = new HashSet<String>(); Set<String> s2 = new HashSet<String>(); S1 INT S2 ? Use the retainAll() method of Set : Set<String> s1; Set<String> s2; s1.retainAll(s2); // s1 now contains only elements in both sets If you want to preserve the sets, create a new set to hold the intersection: Set<String> intersection = new HashSet<String>(s1); // use the copy constructor intersection.retainAll(s2); The javadoc of retainAll()

3D Line-Plane Intersection

最后都变了- 提交于 2019-11-26 12:39:34
问题 If given a line (represented by either a vector or two points on the line) how do I find the point at which the line intersects a plane? I\'ve found loads of resources on this but I can\'t understand the equations there (they don\'t seem to be standard algebraic). I would like an equation (no matter how long) that can be interpreted by a standard programming language (I\'m using Java). 回答1: Here is a method in Java that finds the intersection between a line and a plane. There are vector

How to check intersection between 2 rotated rectangles?

流过昼夜 提交于 2019-11-26 12:16:23
问题 Can someone explain how to check if one rotated rectangle intersect other rectangle ? 回答1: For each edge in both polygons, check if it can be used as a separating line. If so, you are done: No intersection. If no separation line was found, you have an intersection. /// Checks if the two polygons are intersecting. bool IsPolygonsIntersecting(Polygon a, Polygon b) { foreach (var polygon in new[] { a, b }) { for (int i1 = 0; i1 < polygon.Points.Count; i1++) { int i2 = (i1 + 1) % polygon.Points