3
votes

It is known that the intersection points between a line and a polyline can be found using Polyxpoly command in MATLAB.
However, the examples given here involve the polylines that are composed of points, but not real lines. Here, a polyline object is created with the interpolation of space between the points.
What I want to do is to obtain the intersection points between the polyline and line that are defined by line equations, but not from a point to another. Image below is to illustrate what I'm looking for

I want to obtain the coordinates of the intersection points in MATLAB (Denoted with blue circles).

1
this looks like a simple algebra problem, if you have the equations of the line and the eq of the polygon... see for example mathopenref.com/coordintersection.html - bla
If you create a line segment by choosing two points on your infinite line which are outside the polyline, then you'll have what you need for polyxpoly. Choose, for example, x=min(black_polyline_x) - 100, and max(black_polyline_x) + 100 - Peter
@Peter this seems like a good solution. How come I could not think of it! You can add your comment as answer if you want, so I can accept it. Thanks! - rooter

1 Answers

1
votes

If you create a line segment by choosing two points on your infinite line which are outside the polyline, then you'll have what you need for polyxpoly. Choose, for example,

x0=min(black_polyline_x) - 100;
x1=max(black_polyline_x) + 100;

Then compute y0 and y1 to be on the line.