Intersecting lines from coordinates and fixed lines
1 回表示 (過去 30 日間)
古いコメントを表示
Emmanouil Barmpounakis
2015 年 4 月 27 日
コメント済み: Emmanouil Barmpounakis
2015 年 4 月 27 日
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!