line-intersection

How to extend the line of 2 PolyFit from either side to intersect and get a combined fit line

99封情书 提交于 2019-12-25 08:34:41
问题 I am trying to get combined fit line made from two linear polyfit from either side (should intersect), here is the picture of fit lines: I am trying to make the two fit (blue) lines intersect and produce a combined fit line as shown in the picture below: Note that the crest can happen anywhere so I cannot assume to be in the center. Here is the code that creates the first plot: xdatPart1 = R; zdatPart1 = z; n = 3000; ln = length(R); [sX,In] = sort(R,1); sZ = z(In); xdatP1 = sX(1:n,1); zdatP1

How to calculate ray-line segment intersection preferably in OpenCV? And get its intersection points and distance from origin?

。_饼干妹妹 提交于 2019-12-23 04:45:24
问题 I have 4 lines segment, A, B, C and D. Each line is represented as two points. Eg. line A is represented as point A1 and point A2. What I want is point X, which is the point where line A ray intersect with line B distance between X and A1(origin) When testing for intersection, line A ray should not intersect with line segment D intersect with line segment C How do I do this? 回答1: Finally got it working on OpenCV C++. Based on this https://stackoverflow.com/a/32146853/457030. // return the

Lines intersection using Boost Geometry

拜拜、爱过 提交于 2019-12-22 10:23:34
问题 How line can be represented using Boost Geometry? I don't need finite segment, but I need infinite lines (maybe Segment or Linestring can be extended?) As I understand I can use boost::geometry::intersects , but I don't know how to define infinite line. 回答1: If you want to test whether an infinite line A intersects a line segment B , this can be done using boost::geometry::strategy::side::side_by_triangle: template <typename Point> struct line { boost::geometry::model::segment<Point> segment;

Find the Intersection Points of All the Line Segments

元气小坏坏 提交于 2019-12-18 14:46:14
问题 Given a list of line segments, the easiest way to find the intersection points is to loop through the line segment list, check whether they are intersecting and record the intersection point if they do. But the runtime of this method is O(n^2) , which is very inefficient. Is there any other algorithm that could speed up this process? 回答1: The Bentley-Ottmann Algorithm may be what you are looking for. 来源: https://stackoverflow.com/questions/4125452/find-the-intersection-points-of-all-the-line

Detect if two line segments intersect using Cramer

牧云@^-^@ 提交于 2019-12-13 15:41:21
问题 I have used the code that has been posted here. Here is the code again: from __future__ import division def line(p1, p2): A = (p1[1] - p2[1]) B = (p2[0] - p1[0]) C = (p1[0]*p2[1] - p2[0]*p1[1]) return A, B, -C def intersection(L1, L2): D = L1[0] * L2[1] - L1[1] * L2[0] Dx = L1[2] * L2[1] - L1[1] * L2[2] Dy = L1[0] * L2[2] - L1[2] * L2[0] if D != 0: x = Dx / D y = Dy / D return x,y else: return False # Usage L1 = line([0,1], [2,3]) L2 = line([2,3], [0,4]) R = intersection(L1, L2) if R: print

Intersection point of QPainterPath and line (find QPainterPath y by x)

谁说我不能喝 提交于 2019-12-10 16:45:32
问题 I have QPainterPath. I need to find y coordinate of QPainterPath by x. I found intersected() method in QPainterPath. So, I created new QPainterPath, which is line from left to right edge of my path's bounding rect with x coordinate, to find point as result of intersection. intersects() method returns true. But intersected() returns empty path. Everything works If I use rect with height = 1 instead of line. Maybe you have a better idea how to find intersection of QPainterPath with line? 回答1:

Reduce time taken to find N line intersection

我的未来我决定 提交于 2019-12-10 09:23:18
问题 There are N line segments which are either Horizontal or vertical. Now I need to find out total number of Intersections and total number of Intersections per line segment. N can go upto 100000 . I tried checking every pair of lines. The answer is correct but I need to reduce it's time taken by it. Here's my code : using namespace std; typedef struct Point { long long int x; long long int y; } ; bool fun(Point p0, Point p1, Point p2, Point p3) { double s1_x, s1_y, s2_x, s2_y; s1_x = p1.x - p0

Determine if two lines intersect

微笑、不失礼 提交于 2019-12-09 19:35:03
问题 I've seen many postings here on stackoverflow, which are discussing this topic. I took a solution from stackoverflow, but I couldn't find the posting. It was to say: If two lines are intersecting, then the crossproduct produces for the left and the right side two different results. One positive and one negative. Otherwise both have the same sign. So far it is okay. The used formula is, where AB is one line and CD another. dotproductleft = (B.x-A.x) (C.y-B.y)-(B.y-A.y) (C.x-B.x)

Line/Plane intersection based on points

陌路散爱 提交于 2019-12-09 13:15:39
问题 I have two points in space, L1 and L2 that defines two points on a line. I have three points in space, P1, P2 and P3 that 3 points on a plane. So given these inputs, at what point does the line intersect the plane? Fx. the plane equation A*x+B*y+C*z+D=0 is: A = p1.Y * (p2.Z - p3.Z) + p2.Y * (p3.Z - p1.Z) + p3.Y * (p1.Z - p2.Z) B = p1.Z * (p2.X - p3.X) + p2.Z * (p3.X - p1.X) + p3.Z * (p1.X - p2.X) C = p1.X * (p2.Y - p3.Y) + p2.X * (p3.Y - p1.Y) + p3.X * (p1.Y - p2.Y) D = -(p1.X * (p2.Y * p3.Z

Algorithm to find intersections between polylines

一曲冷凌霜 提交于 2019-12-09 06:15:41
问题 Bentley-Ottmann algorithm works for finding intersections of set of straight lines. But I have lot of polylines: Is there a way to find intersections of the set of polylines? I'm figuring out, but in the meanwhile, if someone can give some pointers or ideas, that would be helpful. Thanks for reading. By the way, I'm using WPF/C# and all the polylines are PathGeometry. Source of the Image: http://www.sitepen.com/blog/wp-content/uploads/2007/07/gfx-curve-1.png 回答1: The sweep line algorithm has