teaching machines

Capsule

May 26, 2021 by . Filed under public, slai-2021.

This post is part of a course on geometric modeling at the Summer Liberal Arts Institute for Computer Science held at Carleton College in 2021.

Suppose you grabbed the North Pole, somehow, and I grabbed the South Pole. And then we pulled on the poles. What shape would we get? Earth would look like a pill. Maybe Saturn would swallow it to calm its storms. A more professional term for a pill is capsule. In this exercise, you will make a capsule.

Draw

On your paper, draw an arc that forms the bottom-right quarter-arc of a circle, starting at the south pole and moving counter-clockwise to the east pole. Draw a straight line upward. Then draw another quarter-arc, this time stopping at the pole. You should see the radial cross section of a capsule.

Draw five or more points along the arcs only. Do not include the poles.

As with the sphere, the points you have drawn represent a set of seed points along the first line of longitude. To generate the other lines of longitude, you will rotate this first line around the y-axis.

Function

Write a function named generateCapsule. Have it accept these parameters:

Copy your code from generateSphere into this function. Much of it will be the same.

Positions

The seed positions of the capsule are very similar to the seed positions of the sphere, but the first half of them are pushed down and the second half are pushed up. That’s it. You’ll accomplish this by breaking the loop into two, one for each half. Follow these steps to adapt your sphere code:

When you render your capsule after making these changes, you should see a capsule-like shape. However, the poles are probably not be right. Adjust the pole positions just as you adjust the seed positions.

Comments

Leave a Reply

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