teaching machines

Torus

May 27, 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.

Rings are a big deal. We coat them in sugar and eat them for a snack. We commit to a partner with one. We drive on two or four or eighteen of them. To mathematicians, a ring is a torus. In this exercise, you’ll craft you’re very own torus using just a revolved circle.

Draw

On your paper, draw the y-axis. To its right, draw a circle with a few points spread around the perimeter. This circle holds the set of seed points of your torus. You will revolve this circle around the y-axis to form your torus.

Draw a similar circle to the left of the y-axis. Connect the two circles to each other to form a half donut.

Function

Write a function named generateTorus. 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 torus are very similar to the seed positions of the sphere, but instead of generating just those on a semicircle, you must generate points across the entire circle, and that circle must be pushed rightward of the y-axis. Follow these steps to adapt your sphere code:

When you render your torus after making these changes, you should see a torus-like shape.

Triangles

You may see some a gap in your torus. That’s because a sphere and torus have a different topology. In both, the right edge of the grid wraps back around to the left edge. Only in the torus does the top edge of the grid wrap back around to the bottom. To fix the topology, ensure that you visit every possible latitude index, and used wrapped addition to connect each row to the next one “above” it.

Comments

Leave a Reply

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