# teaching machines

## Button

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

Here’s an unsung hero whose worth isn’t recognized until it’s gone:

Just in case you lose one and need to print a replacement, you should have a 3D model of a button available.

Write a function named generateButton to generate the kind of shape you see in the image above. Have it accept these parameters:

• An integer nlongitudes that specifies the number of lines of longitude that the cylinder has. Higher numbers won’t have much of an effect on the appearance.
• The height of the button, which measures the cylindrical height.
• The majorRadius of the button, which marks the distance from the y-axis to the outer rim.
• The minorRadius of the button, which marks the distance from the y-axis to the inner rim.
• The holeRadius of the button, which measures the size of a thread hole.
• The holeGap of the button, which measures the distance between thread holes.

Use boolean operations to create your button.