# teaching machines

## Swirl Ball

A few months back, I saw a 2D illustration in Mathographics that was begging to be expanded into 3D.

Here’s my “spin” on that expansion. First, I started with a simple circle.

interDelta = 5

for azimuth through 360 by interDelta
x = radius * cos azimuth
y = radius * sin azimuth
moveto x, y, 0
end


I anticipated doing a lot of plotting of polar coordinates, so I factored out a helper function.

interDelta = 5

x = radius * cos degrees
y = radius * sin degrees
moveto x, y, 0
end

for azimuth through 360 by interDelta
end

Next up was shaping the circle into a lobed, flowery shape. I fed the angle into the sine function to get an undulating radius as I traversed the circle’s perimeter.

interDelta = 5
nlobes = 7

x = radius * cos degrees
y = radius * sin degrees
moveto x, y, 0
end

for azimuth through 360 by interDelta
end


Next I wanted a stack of flowers. However, I like abstraction a lot, so I made a flower function first.

interDelta = 5
nlobes = 7

x = radius * cos degrees
y = radius * sin degrees
moveto x, y, 0
end

to flower
for azimuth through 360 by interDelta
end
end

flower

I wanted the stack of flowers eventually to shape themselves into a ball, so it made sense to me to walk the altitudes from -90 to 90. At the extremes -90 and 90, I wanted more flowers because the radius changes faster at the ends and I needed to capture the detail. So, I fed the azimuth angle into another sine function to calculate a flower slice’s z-coordinate.

interDelta = 15
nlobes = 7

x = radius * cos degrees
y = radius * sin degrees
moveto x, y, z
end

to flower altitude
for azimuth through 360 by interDelta
z = maxRadius * sin altitude
end
end

for altitude in -90..90 by interDelta
flower altitude
end

Now I shrunk the flowers according to the altitude. At the extremes -90 and 90, I wanted the flowers to be small. At 0, I wanted the flower to be its full size. Cosine to the rescue!

interDelta = 15
nlobes = 7

x = radius * cos degrees
y = radius * sin degrees
moveto x, y, z
end

to flower altitude
for azimuth through 360 by interDelta
z = maxRadius * sin altitude
end
end

for altitude in -90..90 by interDelta
flower altitude
end

Then it was time make a solid. I added a surface solidifier. I stopped interDelta + 1 times going through the azimuth angles and intraDelta + 1 times going through the altitudinal angles.

interDelta = 5
nlobes = 7

x = radius * cos degrees
y = radius * sin degrees
moveto x, y, z
end

to flower altitude
for azimuth through 360 by interDelta
z = maxRadius * sin altitude
end
end

for altitude in -90..90 by interDelta
flower altitude
end

surface 360 / interDelta + 1, 180 / intraDelta + 1

Finally, I added a little twist between flower slices.

interDelta = 5
nlobes = 7

x = radius * cos degrees
y = radius * sin degrees
moveto x, y, z
end

to flower altitude
for azimuth through 360 by interDelta
z = maxRadius * sin altitude
end
end

for altitude in -90..90 by interDelta
flower altitude
rotate 0, 0, 1, 3
end

surface 360 / interDelta + 1, 180 / intraDelta + 1

Missing from this process are the steps where I made a bunch of mistakes.

I think cornflower blue is pretty.