Merge pull request #43 from rockstorm101/fix-reg-polygon

regular_shapes: Avoid the circle trick
This commit is contained in:
Chow Loong Jin 2018-10-03 12:25:40 +08:00 committed by GitHub
commit cd134456c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,7 +33,11 @@ module reg_polygon(sides,radius)
if(sides<2) square([radius,0]);
if(sides==3) triangle(radius);
if(sides==4) square([dia(radius),dia(radius)],center=true);
if(sides>4) circle(r=radius,$fn=sides);
if(sides>4) {
angles=[ for (i = [0:sides-1]) i*(360/sides) ];
coords=[ for (th=angles) [radius*cos(th), radius*sin(th)] ];
polygon(coords);
}
}
module pentagon(radius)