intersection

How to find intersection of a line with a mesh?

夙愿已清 提交于 2019-11-27 17:03:47
问题 I have trajectory data, where each trajectory consists of a sequence of coordinates(x, y points) and each trajectory is identified by a unique ID. These trajectories are in x - y plane, and I want to divide the whole plane into equal sized grid (square grid). This grid is obviously invisible but is used to divide trajectories into sub-segments. Whenever a trajectory intersects with a grid line, it is segmented there and becomes a new sub-trajectory with new_id . I have included a simple

Finding where two linear fits intersect in R

时间秒杀一切 提交于 2019-11-27 14:11:04
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. 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 and y0 give the result: # test data set.seed(123) x1 <- 1:10 y1 <- -5 + x1 + rnorm(10) x2 <- 1:10 y2 <- 5 - x1

Generate new polygons from a cut polygon (2D)

北城以北 提交于 2019-11-27 13:11:46
问题 I'm stuck with this little problem and my algorithm to solve this doesn't hold for all cases. Does anybody has an idea how to solve this? Here's an example polygon: example http://img148.imageshack.us/img148/8804/poly.png Formal description We have a list of points in CW order defining the polygon. We also can query whether a point is a cutting point with is_cut(p) , where p is a given point. Now we want to compute new polygons caused by this "cut". The algorithm should do this: Input: {a, c1

Area of intersection between circle and rectangle

北城余情 提交于 2019-11-27 12:11:39
问题 I'm looking for a fast way to determine the area of intersection between a rectangle and a circle (I need to do millions of these calculations). A specific property is that in all cases the circle and rectangle always have 2 points of intersection. 回答1: Given 2 points of intersection: 0 vertices is inside the circle: The area of a circular segment XXXXX ------------------- X X X X Circular segment X X XX XX +-X-------X--+ XXXXXXXX | X X | | XXXXX | 1 vertex is inside the circle: The sum of

Compute the area of intersection between a circle and a triangle?

风格不统一 提交于 2019-11-27 11:43:10
How does one compute the area of intersection between a triangle (specified as three (X,Y) pairs) and a circle (X,Y,R)? I've done some searching to no avail. This is for work, not school. :) It would look something like this in C#: struct { PointF vert[3]; } Triangle; struct { PointF center; float radius; } Circle; // returns the area of intersection, e.g.: // if the circle contains the triangle, return area of triangle // if the triangle contains the circle, return area of circle // if partial intersection, figure that out // if no intersection, return 0 double AreaOfIntersection(Triangle t,

Efficiently find points inside a circle sector

那年仲夏 提交于 2019-11-27 11:03:15
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 from that specific point. (Edit: This operation is called regularly with a different specific point each

Java- Intersection point of a Polygon and Line

痞子三分冷 提交于 2019-11-27 08:55:49
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. 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 check for division by 0. This will also work only for polygons. It could be adapted to work with other shapes

Intersection of two strings in Java

半腔热情 提交于 2019-11-27 08:25:30
Need a Java function to find intersection of two strings. i.e. characters common to the strings. Example: String s1 = new String("Sychelless"); String s2 = new String("Sydney"); Using HashSet<Character> : HashSet<Character> h1 = new HashSet<Character>(), h2 = new HashSet<Character>(); for(int i = 0; i < s1.length(); i++) { h1.add(s1.charAt(i)); } for(int i = 0; i < s2.length(); i++) { h2.add(s2.charAt(i)); } h1.retainAll(h2); Character[] res = h1.toArray(new Character[0]); This is O(m + n) , which is asymptotically optimal. Extract the characters String.toCharArray Put them in a Set Find the

Finding the intersection of two arrays [closed]

六眼飞鱼酱① 提交于 2019-11-27 07:42:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . My aim is to find out values of intersection of arrays a and b and store them into a new array c so the printout will be : 3,10,4,8. How do I assign given values to a 3rd array c ? public static void main(String[] args) { int a[] = {3, 10, 4, 2, 8}; int[] b = {10, 4, 12, 3, 23, 1, 8}; int[] c; int i=0; for(int f

Circle-circle intersection points

夙愿已清 提交于 2019-11-27 06:27:21
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. Jacob Intersection of two circles Written by Paul Bourke The following note describes how to find the intersection point(s) between two circles on a plane, the following notation is used. The aim is to find the two points P 3 = (x 3 , y 3 ) if they exist. First calculate the distance d