Straight line through center of polygon
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sunetra Banerjee
am 24 Mai 2021
Kommentiert: Sunetra Banerjee
am 24 Mai 2021
Hi,
I have polygon ROI and I need to draw a straight line through the center of the polygon and through the middle of superior (S1 & S2) / inferior (I1 & I2) points of the ROI. In my case, the ROI polygons are of various sizes and shapes. I am attaching a picture of a sample ROI of my work. Please help me regarding this.
0 Kommentare
Akzeptierte Antwort
KSSV
am 24 Mai 2021
Bearbeitet: KSSV
am 24 Mai 2021
If you have the vertices of the polygon, you can fit a striaght line and draw it.
Example:
P = [0 0 ; 1 0 ; 1 1 ; 0 1] ; % vertices of the polygon
p = polyfit(P(:,1),P(:,2),1) ; % fit a striaght line
xi = P(:,1) ;
yi = polyval(p,xi) ;
patch(P(:,1),P(:,2),'r')
hold on
plot(xi,yi,'b')
2 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
