How to Find Correct Vertice formation for polyxpoly function
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kayra Dernek
am 29 Mär. 2022
Bearbeitet: Matt J
am 30 Mär. 2022
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 Kommentare
Akzeptierte Antwort
Matt J
am 30 Mär. 2022
Bearbeitet: Matt J
am 30 Mär. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
