Skip to content

Instantly share code, notes, and snippets.

@xunker
Last active November 8, 2016 23:14
Show Gist options
  • Save xunker/daabf70dbb8e990077d3a1a11d1e06dd to your computer and use it in GitHub Desktop.
Save xunker/daabf70dbb8e990077d3a1a11d1e06dd to your computer and use it in GitHub Desktop.
Drawing an N-gon around a circle using OpenSCAD
/*
Drawing an N-gon around a circle using OpenSCAD
https://gist.github.com/xunker/daabf70dbb8e990077d3a1a11d1e06dd
Matthew Nielsen - github.com/xunker
Math credit: http://mathcentral.uregina.ca/QQ/database/QQ.09.06/s/cliff1.html
*/
/* Diameter of the circle around which the n-gon will be built. */
circle_d = 21.6; // 21.6mm is 3/4 inch.
/* Number of sides the n-gon should have. Needs to be 3 or more, or else it's
not a polygon anymore. */
sides = 8;
/* -- no more changes needed below this -- */
circle_r = circle_d/2;
theta = 360 / (sides*2); // sides*2 because each section has two radians to centre.
side_length = (circle_r*2)*tan(theta);
side_angle = theta*2;
%cylinder(h=1, d=circle_d, $fn=32, center=true);
for (angle = [0:side_angle:359]) {
rotate([0,0,angle])
translate([0,circle_d/2,0])
cube([side_length,0.1,1], center=true);
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment