How do I write a Matlab function to draw a regular polygon.
Afficher commentaires plus anciens
Using the heading function drawPolygon(n, r, colstyle)
where n=no of sides
r= is the radius of the circle that would be large enough to enclose the polygon
colstyle=is the colour and line style to be used for the plotting
Réponses (1)
Walter Roberson
le 14 Mai 2013
0 votes
If you think about following along the circle, if you do not start at a vertex, then after passing "n" vertices, you return to the starting point. The polygon is regular, so the sides must be equal, so the angles must be equal. So then, at what fraction of the circle must the angle between one vertex and the next cover?
Now, how would you find the list of points that are (for example) all Pi/17 radian apart on a circle of radius "r" ?
Catégories
En savoir plus sur Elementary Polygons dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!