or

# Thank goodness for CSG (Constructive Solid Geometry)

Written by Paul Bourke
December 1996

What single object can slide exactly through each of the holes shown below without leaving gaps? That is, the object must slip through each hole filling the hole completely.

The solution is the intersection of each of the outlines of the holes extruded along each of the three orthogonal axes in 3 space. This is where CSG based rendering engines come to the rescue, generating this intersection in a facet based modeller would be extremely difficult, it is trivial in a solid modeller.
The following show the three primitives that intersect, a cylinder, a rectangle, and a plus sign. The plus sign is in turn made up of the union of two rectangles.

Below is a transparent version of the above in an attempt to illustrate the intersecting volume.

And finally the actual intersecting volume. It is circular in along one axis (x), square along another axis (z) and a plus sign along the last axis (y).

If you have good woodworking skills and make one of these, probably from wood, please let me know and perhaps send me a copy.

The base into which the object fits might look something like the following.

Again using CSG this is particularly easy to generate using the same forms as described earlier but subtracting them from a rectangular box.

### Source

The images above were generated using the RayShade rendering package, the geometric description for the union and intersecting volume is given below.
```eyep 1.5 -2 2
lookp 0 0 0
up 0 0 1
fov 60
screen 200 200
light 1 1 1 directional 1 -0.5 1.5
light 0.5 0.5 0.5 directional -1 -0.5 0.7
light 0.2 0.2 0.2 directional 1 0 0
surface surfx
ambient .2 .05 .05
diffuse .8 .05 .05
specular .05 .05 .05
specpow 20
surface surfy
ambient .2 .05 .05
diffuse .05 .8 .05
specular .05 .05 .05
specpow 20
surface surfz
ambient .2 .05 .05
diffuse .05 .05 .8
specular .05 .05 .05
specpow 20

/* Plus sign along the x axis */
name xobject
union
box surfx -0.16666667 -1 -0.5 0.16666667 1 0.5
box surfx -0.5 -1 -0.16666667 0.5 1 0.16666667
end

/* Cylinder along the y axis */
name yobject
list
cylinder surfy .5 -1  0.0  0.0  1  0.0  0.0
disc surfy .5 -1  0.0  0.0 -1.0  0.0  0.0
disc surfy .5  1  0.0  0.0  1.0  0.0  0.0
end

/* Box along the z axis */
name zobject
list
box surfz -0.5 -0.5 -1 0.5 0.5 1
end

/* Create the unio of the three extruded forms */
name solidobject
list
object xobject
object yobject
object zobject
end

/* Create the intersecting volume
name solidobject
intersect
object xobject
intersect
object yobject
object zobject
end
end
*/

/* Create the base
name solidobject
difference
box surfa -2.5 -1 -0.25 2.5 1 0.25
union
object xobject rotate 1 0 0 90
union
object yobject
object zobject
end
end
end */
```