# Create polygon with more contour points (not only vertices)

3 Ansichten (letzte 30 Tage)
Albert am 8 Jul. 2021
Kommentiert: Albert am 8 Jul. 2021
I would like to know how to create e.g. a hexagon with more points over the contourns, instead of having only the points for the 6 vertices. The following code creates a hexagon as a set of 7 (x,y) points that perfectly define the hexagon. However, I want to have more (x,y) points located at the lines intersecting the vertices. Thanks!
r = 0.6327/cosd(30);
theta = 0:60:360;
x = r*cosd(theta);
y = r*sind(theta);
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Matt J am 8 Jul. 2021
Bearbeitet: Matt J am 8 Jul. 2021
r = 0.6327/cosd(30);
theta = 0:60:360;
x = r*cosd(theta);
y = r*sind(theta);
t=linspace(0,1,10).'; t(end)=[];
x=t*x+(1-t)*circshift(x,1);
y=t*y+(1-t)*circshift(y,1);
scatter(x,y) ##### 1 KommentarKeine anzeigenKeine ausblenden
Albert am 8 Jul. 2021
great, thanks!!

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Elementary Polygons in Help Center and File Exchange

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!