teaching machines

Swirl Ball

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

A spiral from Robert Dixon's Mathographics. It wanted to be 3D.

A spiral from Robert Dixon’s Mathographics. It wanted to be 3D.

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

Only two shapes matter: triangles and circles.

Only two shapes matter: triangles and circles.

interDelta = 5
radius = 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
radius = 5

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

for azimuth through 360 by interDelta
  polarto radius, azimuth
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.

The circle bloomed into a flower. It was a sine.

The circle bloomed into a flower. It was a sine.

interDelta = 5
minRadius = 5
nlobes = 7

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

for azimuth through 360 by interDelta
  azimuthRadius = minRadius + sin (azimuth * nlobes)
  polarto azimuthRadius, degrees
end

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

interDelta = 5
minRadius = 5
nlobes = 7

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

to flower
  for azimuth through 360 by interDelta
    azimuthRadius = minRadius + sin (azimuth * nlobes)
    polarto azimuthRadius, azimuth
  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.

A stack of flowers, with more detail at the ends.

A stack of flowers, with more detail at the ends.

interDelta = 15
intraDelta = 15
minRadius = 5
maxRadius = minRadius + 1
nlobes = 7

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

to flower altitude
  for azimuth through 360 by interDelta
    azimuthRadius = minRadius + sin (azimuth * nlobes)
    z = maxRadius * sin altitude
    polarto azimuthRadius, azimuth, z
  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!

The flower stack, with its slices shrunk according to their altitude.

The flower stack, with its slices shrunk according to their altitude.

interDelta = 15
intraDelta = 15
minRadius = 5
maxRadius = minRadius + 1
nlobes = 7

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

to flower altitude
  for azimuth through 360 by interDelta
    azimuthRadius = minRadius + sin (azimuth * nlobes)
    altitudeRadius = cos altitude
    z = maxRadius * sin altitude
    polarto azimuthRadius * altitudeRadius, azimuth, z
  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.

The flower stack made into a solid.

The flower stack made into a solid.

interDelta = 5
intraDelta = 5
minRadius = 5
maxRadius = minRadius + 1
nlobes = 7

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

to flower altitude
  for azimuth through 360 by interDelta
    azimuthRadius = minRadius + sin (azimuth * nlobes)
    altitudeRadius = cos altitude
    z = maxRadius * sin altitude
    polarto azimuthRadius * altitudeRadius, azimuth, z
  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.

A twisted flower stack. Dream accomplished.

A twisted flower stack. Dream accomplished.

interDelta = 5
intraDelta = 5
minRadius = 5
maxRadius = minRadius + 1
nlobes = 7

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

to flower altitude
  for azimuth through 360 by interDelta
    azimuthRadius = minRadius + sin (azimuth * nlobes)
    altitudeRadius = cos altitude
    z = maxRadius * sin altitude
    polarto azimuthRadius * altitudeRadius, azimuth, z
  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.

Screen Shot 2015-12-18 at 12.01.10 PMScreen Shot 2015-12-18 at 12.02.37 PM

Comments

  1. Nathan Bergeron says:

    “The circle bloomed into a flower. It was a sine.”

    There is no escape from the puns!

Leave a Reply

Your email address will not be published. Required fields are marked *