User Tools


This is an old revision of the document!


Operations

All shapes (primitives or the results of operations) can be passed to special functions to perform logical operations, e.g. removing a hole using difference. In all cases, the operation returns the results, and never changes the original shapes.

Union

Several shapes can be combined (merged) into a single shape. The result is the logical union of the shapes. The combining of smaller obects together allows easier transformations, etc.

let shape = union(sphere({r: 1, center: true}), cube({size: 1.5, center: true})

The CSG library functions can also be used. NOTE: Deprecated in the V2 API

sphere({r: 1, center: true}).union(cube({size: 1.5, center: true}))

Intersection

Several objects can be combined (overlapped) into a single shape. This result is the logical intersection of the shapes.

let shape = intersection(sphere({r: 1, center: true}), cube({size: 1.5, center: true}))

The CSG library functions can also be used. NOTE: Deprecated in the V2 API

sphere({r: 1, center: true}). intersect(cube({size: 1.5, center: true}))

Difference

Several shapes can be removed (subtracted) from another. The result is the logical difference of shapes.

Note: The first shape given is the base shape for all subtractions.

let shape = difference(sphere({r: 1, center: true}), cube({size: 1.5, center: true}))

The CSG library functions can also be used. NOTE: Deprecated in the V2 API

sphere({r: 1, center: true}). subtract(cube({size: 1.5, center: true}))

Hull

Several shapes can be combined together to form the convex hull, i.e. sum of the outside shells. This includes irregular shapes such as combining a circle with a square.

Note: Convex hulls can be viewed as elastic wrapping around several shapes.

EXAMPLE

Learn more about convex hull at Wikipedia.org

let h = hull(square(10), translate([5, 10, 15], circle(10)))

Chain Hull

Chain Hull is a variant of Hull across multiple 2D forms, essentially sequential hulling, then creating a union of the results.

chain_hull( 
    circle(), circle().translate([2,0,0]), ... );   // list of CAG/2D forms
 
let a = [];
a.push(circle()); 
chain_hull( a );                       // array of CAG/2D forms
 
chain_hull({closed: true},             // default is false
   circle(), circle().translate([2, 0, 0]), circle().translate([2, 2, 0]))