Intersecting lines from coordinates and fixed lines
2 次查看(过去 30 天)
显示 更早的评论
How can I find the intersecting points between the line that is created from a set of coordinates and a fixed line? I am trying to use the Curve Intersections function.
Specifically, I have a set of coordinates with x: (NAN NAN NAN x1 x2 x3 x4 x5... xN-1 xN NAN NAN NAN) and y:(NAN NAN NAN y1 y2 y3 y4 y5...yN-1 yN NAN NAN NAN). I want to find whether the line created from these connected corrdinates is intersecting a line with specific start and end point.
x1=val(:,2);
y1=val(:,3);
x2=[-226.586 , -238.954];
y2=[112.566 , 49.459];
plot(x1,y1,x2,y2)
P = InterX([x1;y1],[x2;y2]);
plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro'
And the result I get is:
Error using .*
Matrix dimensions must agree.
Error in InterX (line 60)
S1 = dx1.*y1(1:end-1) - dy1.*x1(1:end-1);
while the plot work just fine! Then, I want to a counter to increase by one IF there is an intersection point between these two lines.
0 个评论
采纳的回答
Andrei Bobrov
2015-4-27
x1=val(:,2);
y1=val(:,3);
x2=[-226.586 , -238.954];
y2=[112.566 , 49.459];
plot(x1,y1,x2,y2)
P = InterX([x1.';y1.'],[x2;y2]);
plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!