Previous: Repeated objects, Up: Introduction by example [Contents][Index]
Many familiar shapes can be generated by sweeping simpler ones through
space and considering the resulting path, surface, or volume.
Sketch
implements this idea in the sweep command.
def n_segs 8 sweep { n_segs, rotate(180 / n_segs, (0,0,0), [0,0,1]) } (1,0,0)
This code sweeps the point (1,0,0) eight times by rotating it 180/8 = 22.5 degrees each time and connecting the resulting points with line segments. The def used here is a scalar definition. References to scalars have no enclosing brackets at all.
• Point sweeps: | Swept points make lines and polygons. | |
• Polyline sweeps: | Swept lines make surfaces. | |
• Nested sweeps: | Swept sweeps are useful! | |
• Polygon sweeps: | Swept polygons make solids... | |
• Polyline sweeps with closure: | and so do closed polyline sweeps. | |
• Affine arithmetic: | Sketch useful math expression. | |
• More to learn: | Check out the Mobius strip! |