Advanced · optional
Shapes of Revolution
This one’s a bonus, not part of the main five lessons – come back to it any time after Cutting Shapes. It’s here because it’s genuinely fun, not because you’ll need it for anything else in this course.
Why Spin a Shape
Every extrude so far has worked the same way: take a flat shape, push it
straight up. There’s a second way to turn a 2D shape into a 3D one:
spin it around an axis, like a lump of clay on a potter’s wheel, or a
block of wood on a lathe. rotate_extrude(profile) does exactly that.
That’s a plain cylinder – something you’ve built a dozen times with
Cylinder(1.5, 3). That’s not a coincidence: spinning a rectangle all
the way around its edge produces exactly the same shape a cylinder is.
rotate_extrude() is really the more general tool; Cylinder() is just
the one shape it makes so often that it got its own shortcut.
Radius and Height, Not Left and Top
Here’s the one idea this whole lesson rests on: once a profile is headed
into rotate_extrude(), its two coordinates stop meaning what they
meant everywhere else. The first number isn’t “left” or “x” anymore –
it’s how far out from the axis. The second isn’t “top” – it’s
how far up. The axis itself is the z-axis, standing at x = 0.
Move that same rectangle away from the axis instead of starting right at it, and you get something very different:
A pipe, not a solid cylinder – because the profile never reached the axis, there’s a gap all the way through the middle once it’s spun around. The size of that gap is exactly the profile’s own distance from x = 0.
A profile's closest edge sits at x = 1 instead of x = 0, then gets rotate_extrude()'d. What's different about the result, compared to a profile that starts right at the axis?
A profile that dips to the left of the axis (a negative radius) gets clamped to the axis instead of wrapping around to the other side – keep your profile’s x-coordinates at 0 or above, same rule real CAD tools like OpenSCAD use.
Building a Real Profile
A rectangle only gets you cylinders and pipes. Polygon() – the same
one from the Flat Shapes lesson, just now doing double duty as a
rotate_extrude() profile – can trace out any outline you want, point
by point. Trace the silhouette of half a vase, from base to rim, and
spinning it fills in the rest:
Every point you added is one stop along the vase’s outline, read from bottom to top. Wherever the profile swings out wide, the vase gets wide there too; wherever it pulls in, the vase pinches in.
In that profile, `2, 2.5` is the point with the largest first number (radius) of any of them. What part of the vase does it correspond to?
Leaving a Wedge Open
rotate_extrude(profile, angle=360) is the default – spin all the way
around. Anything less leaves a wedge open, like a slice missing from a
cake. Before that, though, it helps to see what a sweep actually is:
not a smooth curve, but flat copies of your profile, evenly spaced
around the circle and connected to their neighbors – the same
segments= you already know from Cylinder(). The default (32) is
smooth enough to look round. Turn it way down and the individual flat
panels become obvious:
Eight flat panels, not a smooth tube – that’s really what segments=32
is too, just with so many panels they read as curved. Now leave a wedge
open on that same low-segment shape:
Once you can see the panels, the open end stops looking strange: it’s
just where the sweep stopped. The flat profile is standing there same
as every other panel, with nothing built past it. Turn segments= back
up (or drop it, since 32 is the default) once you’re building something
for real – the low value here was only to see how it’s built.
That's `angle=270` out of a full 360. Roughly how much of the ring is missing?
Bonus: A Ring from a Circle
One more, just to see it: a Circle() that never reaches the axis at
all, spun all the way around.
A donut. The circle’s own center sits 1.5 out from the axis and never
gets closer to it than 1.0, so spinning it traces out a ring instead of
a ball. hole=True works on a rotate_extrude() result too, same as
everywhere else in this course – and so does combining one with
union()/difference(), wrapping it in translate()/rotate(), all
of it. rotate_extrude() is a shape like any other once it exists.
Checking Your Work
Exercise: build something with rotate_extrude()
that's taller than it is wide -- a cup, a vase, a bottle, a chess
piece, whatever you like. Use at least three points in your profile
(a plain rectangle is too simple to count here).
Practice
rotate_extrude(): spin a profile around the z-axis instead of pushing
it straight up. The profile’s coordinates become radius and height, not
left and top. angle= for a partial sweep, hole= and every boolean
operation work exactly like they do everywhere else.
If you want to see how a real CAD tool explains this same idea, the OpenSCAD User Manual has a page on rotate_extrude – OpenSCAD is the tool this whole course’s style of Python is modeled after.