Constructive Solid Geometry

Welcome to reference documention for a chicken scheme library 'constructive-solid-geometry'. All the values are exported from module 'constructive-solid-geometry':

(import constructive-solid-geometry)

Contents

Primitives

Box

(box width length height)

An orthogonal cuboid with one corner at origin and the other at [width, length, height] coordinates.

(box vector0 vector1)

An orthogonal cuboid with one corner at vector0 and the other at vector1. This is constructed as (translate u (box w l h))

(box? value)

True if value is a box.

(width box)
(box-length box)
(height box)

Returns the parameters of the box. box-length is chosen to not conflict with base scheme function length.

Cylinder

(cylinder radius height)

Constructs a cylinder primitive. The cylinder extends in z-axis direction, with the base center at origin, and the other base center at [0, 0, height].

(cylinder? value)

True if the value is a cylinder

(radius cylinder)
(height cylinder)

Returns the parameters of the cylinder primitive.

Sphere

(sphere radius)

Returns a sphere solid with the center at origin and the given radius.

(sphere? value)

True, if the value is a sphere.

(radius sphere)

Return the sphere's radius.

Cone

(cone bottom-radius top-radius height)

Construct a truncated cone - a frustum. One base is at z=0 plane with the center at the origin and radius bottom-radius. Cone extends for height in positive z direction, ending with the other base with top-radius. One of bottom-radius or top-radius may be zero. When equal, the shape is identical to cylinder.

(cone? value)

Checks if the value is cone.

(bottom-radius cone)
(top-radius cone)
(height cone)

Extracts the cone's parameters.

Transformations

(rotate axis angle child)

Rotate child around the axis. The axis is specified as a vector of three coordinates. The axis of rotation draws from origin to the point specified in the vector, the amplitude of the vector is ignored. Angle is expressed in radians.

(rotate? value)

True if the value is a rotation transformation.

(axis rotation)
(angle rotation)
(child rotation)

Access rotation parameters.

(translate translation child)

Move the child in the coordinate system. translation is a vector of three numbers.

(translate? value)

Check if the value is translation transformation.

(translation translate)
(child translate)

Get the parameters of translation transformation.

Operations

(union child ...)

Merge children. This is a boolean 'or' operation.

(union? value)

True if the value is an union operation.

(children union)

Returns the children of the union.

(difference upper lower)

Subtract lower from upper. Returns a part of upper that is not part of lower.

(difference? value)

Checks if value is a difference operations

(upper difference)
(lower difference)

Get the operands of the difference operation.

(intersection child ...)

Construct an intersection of all the children. This is a boolean 'and' operation.

(intersection? value)

Checks if the value is an intersection operation.

(children intersection)

Returns the children of the intersection.

Export

(export-stl filename solid)

Calculates the triangular surface mesh, and writes it in STL format to a file.

Other

(solid? value)

Returns true if the value is a solid: either primitive, transformation or operation.

(inside? point solid)

Returns true if the point is inside a solid. If it point lies on the surface of the solid, the return value is unspecified.