teaching machines

Tube

June 9, 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.

Earlier you made a cylinder. That was fun, but now you will do something tubular. You will make a tube, which is a thin cylinder taken away from a thick cylinder.

Draw

On your paper, draw a tube around the y-axis. Angle the view so that one of the tube’s ends is visible. Label the distance between the y-axis and the outer perimeter as the major radius. Label the distance between the y-axis and the inner perimeter as the minor radius.

Function

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

Unlike your earlier shapes, you don’t need any loops to fill the positions and triangles arrays. Instead, you will compose the tube out of shapes you already know how to make. Generate two cylinders using the major and minor radii, convert them to CSG objects, call the appropriate boolean method, convert the result back to a mesh, and then render the result.