Perform boolean operations on surfaces
- Peter Mortier
- Feb 23
- 1 min read
Updated: 6 days ago
Boolean operations on surfaces are fundamental techniques used in 3D modeling. These operations allow designers and engineers to manipulate and combine geometric shapes in various ways, enabling the creation of complex forms from simpler ones. The primary Boolean operations include union, intersection, and difference, each serving a unique purpose in the modeling process.
In this example, we will show how to perform the various types of Boolean operations on surfaces using HelloTriangle. We will illustrate this using a simple cube and a sphere. If you are interested to learn more about other tools to edit and analyse triangulated surfaces, please check our post The online stl editor that redefines triangle mesh editing.
from hellotriangle import shapes
# create and draw a basic cube
cube = shapes.cube()
draw(cube, color = "#2BB786")
# create and draw a basic sphere
sphere = shapes.sphere().scale([0.65, 0.65, 0.65])
draw(sphere, color = "#D62246")

diff = cube.boolean_difference(sphere)
draw(diff, color = "#006992")

inter = cube.boolean_intersection(sphere)
draw(inter, color = "#006992")

union = cube.boolean_union(sphere)
draw(union, color = "#006992")
