Tube
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:
- An integer
nlatitudes
that specifies the number of lines of latitude that the tube has. The higher the number, the more circular it will be. - An integer
nlongitudes
that specifies the number of lines of longitude that the tube has. Higher numbers won’t have much of an effect on the appearance. - The
majorRadius
of the tube. - The
minorRadius
of the tube. - The
height
of the tube.
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.