How to Find Correct Vertice formation for polyxpoly function
13 ビュー (過去 30 日間)
古いコメントを表示
I am trying to find intersection points of horizontal lines and drawn polygon with a hole. However, pgon.Vertices does not give proper formation for polyxpoly function and I get incorrect results for intersection points (For example y = 0 intersection point return 0.514 value). The code I am running as follows, how can I transform pgon.Vertices format format suitable for polyxpoly. Figure displays the lines and annulus I am trying to find intersection points.
Thanks

clear
clc
clf
t = 0.05:0.005:2*pi;
x1 = cos(t);
y1 = sin(t);
x2 = 0.5*cos(t);
y2 = 0.5*sin(t);
pgon = polyshape({x1,x2},{y1,y2});
[corrected_x1,corrected_y1] = poly2ccw(pgon.Vertices(:,1), pgon.Vertices(:,2));
plot(pgon)
hold on
for j = -1.5:0.1:2
x = [-2,4];
y = [j, j];
[xi,yi] = polyxpoly(x,y,corrected_x1,corrected_y1);
plot(x,y)
end
2 件のコメント
採用された回答
Matt J
2022 年 3 月 30 日
編集済み: Matt J
2022 年 3 月 30 日
Instead of polyxpoly, I would recommend downloading linexlines2D(),
t = 0.05:0.005:2*pi;
x1 = cos(t);
y1 = sin(t);
x2 = 0.5*cos(t);
y2 = 0.5*sin(t);
pgon = polyshape({x1,x2},{y1,y2});
lineEq=[0,1,-0.25];
xy=linexlines2D(pgon,lineEq); %intersection points
plot(pgon)
hold on
fimplicit(@(x,y)lineEq*[x;y;x.^0],[-2,2]); %plot line
plot(xy(1,:), xy(2,:),'ro'); %plot intersection points
hold off
axis equal
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
