Jump to content

User:LABoyd2/cylinder 150920

From Wikibooks, open books for an open world

cylinder

[edit | edit source]

Creates a cylinder or cone centered about the z axis. When center is true, it is also centered vertically along the z axis.

Parameter names are optional if given in the order shown here. If a parameter is named, all following parameters must also be named.

cylinder(h = height, r1 = BottomRadius, r2 = TopRadius, center = true/false);
Parameters
h : height of the cylinder or cone
r  : radius of cylinder. r1 = r2 = r.
r1 : radius, bottom of cone.
r2 : radius, top of cone.
d  : diameter of cylinder. r1 = r2 = d /2.
d1 : diameter, bottom of cone. r1 = d1 /2
d2 : diameter, top of cone. r2 = d2 /2
(NOTE: d,d1,d2 require 2014.03 of later. Debian is currently know to be behind this)
center
false (default), z ranges from 0 to h
true, z ranges from -h/2 to +h/2
$fa : minimum angle (in degrees) of each fragment.
$fs : minimum circumferential length of each fragment.
$fn : fixed number of fragments in 360 degrees. Values of 3 or more override $fa and $fs
$fa, $fs and $fa must be named. click here for more details,.
defaults: cylinder();  yields: cylinder($fn = 0, $fa = 12, $fs = 2, h = 1, r1 = 1, r2 = 1, center = false);

equivalent scripts
 cylinder(h=15, r1=9.5, r2=19.5, center=false);
 cylinder(  15,    9.5,    19.5, false);
 cylinder(  15,    9.5,    19.5);
 cylinder(  15,    9.5, d2=39  );
 cylinder(  15, d1=19,  d2=39  );
 cylinder(  15, d1=19,  r2=19.5);

equivalent scripts
 cylinder(h=15, r1=10, r2=0, center=true);
 cylinder(  15,    10,    0,        true);
 cylinder(h=15, d1=20, d2=0, center=true);
equivalent scripts
 cylinder(h=20, r=10, center=true);
 cylinder(  20,   10, 10,true);
 cylinder(  20, d=20, center=true);
 cylinder(  20,r1=10, d2=20, center=true);
 cylinder(  20,r1=10, d2=2*10, center=true);
use of $fn

Normally rather large values of $fn are used to create smoother, more circular, surfaces. However, use of small values can produce some interesting non circular objects. A few examples are show here:

scripts for these examples
 cylinder(20,20,20,$fn=3);
 cylinder(20,20,00,$fn=4);
 cylinder(20,20,10,$fn=4);
undersized holes

When using cylinder() with difference() to place holes in objects, the holes will be undersized. This is because circular paths are approximated with polygons inscribed within in a circle. The points of the polygon are on the circle, but straight lines between are inside.

To have all of the hole larger than the true circle, the polygon must lie wholly outside of the circle (circumscribed). This can be accomplished by specifying a radius, or diameter, which is multiplied by a fudge factor dependent on the angle between points of the polygon. This fudge factor = 1 / cos(0.5 * angle).

 $fn  angle  fudge factor
   6   60    1.154701
  60    6    1.001372
 180    1    1.000152
 360    0.5  1.000038

Notes on accuracy Circle objects are approximated. The algorithm for doing this matters when you want 3d printed holes to be the right size. Current behaviour is illustrated in a diagram . Discussion regarding optionally changing this behaviour happening in a Pull Request