Skip to content

Latest commit

 

History

History
88 lines (60 loc) · 2.01 KB

ex3-solution.adoc

File metadata and controls

88 lines (60 loc) · 2.01 KB

Exercise 3 Solution

1. The Crude Pawn Model

// A model of a (somewhat crude) chess pawn.

// Dimensions of the base, the shaft, the collar, and the head.

baseDiameter = 25;
baseHeight = 5;

headDiameter = 18;

collarDiameter = 18;
collarHeight = 4;
collarAltitude = 30;

shaftBottomDiameter = 15;
shaftTopDiameter = 10;
shaftLength = 35;

// The base.
cylinder(d=baseDiameter, h=baseHeight);

// The tapering shaft.
translate([0, 0, baseHeight])
cylinder(d1=shaftBottomDiameter, d2=shaftTopDiameter, h=shaftLength);

// The "collar", partway up the shaft.
translate([0, 0, collarAltitude])
cylinder(d=collarDiameter, h=collarHeight);

// The head, a sphere.
translate([0, 0, baseHeight + shaftLength + headDiameter/2 - 2])
sphere(d=headDiameter);

2. Smoother and Rougher

These assignments added to the model, as one eample, will decrease the size of the facets in the rendering.

$fs = .5;
$fa = 10;

These assignments, as one example, make the facets larger than the default.

$fs = 5;
$fa = 15;

3. Creating an STL File

Values to use may vary depending on the printer and print settings. I have had success with use these assignments in several models, but rendering can be lengthy. The pawn takes about 20 seconds to render on my computer.

$fs = .1; // 1/10 mm
$fa = 3; // 3 degrees of arc

4. Tapered Octagonal Shaft

Add a value for $fn when creating the “cylinder” for the shaft.

translate([0, 0, baseHeight])
cylinder(d1=shaftBottomDiameter, d2=shaftTopDiameter, h=shaftLength, $fn=8);

5. Changing the Shape

These variable values increase the size of the base and collar and make the shaft narrow. Nothing else in the script need change.

baseDiameter = 35;
collarDiameter = 25;
shaftBottomDiameter = 8;
shaftTopDiameter = 4;

Strangely shaped pawn

Note that since the last assignment to a variable is the value that is used, you can add those 4 lines to the bottom without changing the original script.