matlab - Polyxpoly returns empty matrix -
i'm writing code in have use polyxpoly , i'm having issues output.
my code:
x=[-286.1018 -363.2334]; y=[4617.4 4725.1]; xv=[-316.7 -128-9 -268.3 -1864.6 -840.4]; yv=[4694.4 4944.7 5641.7 6002.0 4519.9]; [xi,yi] = polyxpoly(x,y,xv,yv); and returns:
empty matrix: 0-by-2 what doing wrong can't understand why not working (it should return intersection points)? can me? bug of function polyxpoly?
you're getting empty matrix because polylines defined (x,y) , (xv,yv) don't intersect. can shown plotting polylines:
x=[-286.1018 -363.2334]; y=[4617.4 4725.1]; xv=[-316.7 -128-9 -268.3 -1864.6 -840.4]; yv=[4694.4 4944.7 5641.7 6002.0 4519.9]; mapshow(xv, yv); mapshow(x,y,'color','red') we get:

as can see, bigger shape defined xv , yv not closed, smaller line defined x , y never intersect shape. if want find intersection points, you'll need close larger polygon. can done duplicating first xv , yv point in array , making sure these appear at end of xv , yv arrays close polygon:
x=[-286.1018 -363.2334]; y=[4617.4 4725.1]; xv=[-316.7 -128-9 -268.3 -1864.6 -840.4]; yv=[4694.4 4944.7 5641.7 6002.0 4519.9]; %// change xv = [xv xv(1)]; yv = [yv yv(1)]; mapshow(xv, yv); mapshow(x,y,'color','red') we get:

that's better! try polyxpoly on new xv , yv values:
>> [xi,yi] = polyxpoly(x, y, xv, yv) xi = -336.5178 yi = 4.6878e+03 we can show point of intersection adding 1 more mapshow call spawned figure:
mapshow(xi,yi,'displaytype','point','marker','o') we get:

you can see point of intersection has been found, , delineated red circle in map.
Comments
Post a Comment