To cut off unwanted part from a shape, use clipped_by {}:
An object or a shape using clipped_by {} will cause all parts of the object/shape outside of the clipping shape removed. For example, if we haveclipped_by { a shape such as sphere, box and so on }
the result is a box whose eight corners are cut off by the clipping sphere as shown in the figure below (top left):box { < -1, -1, -1 >, < 1, 1, 1 > clipped_by { sphere { 0*x, 1.45 } } // pigment and finish }
If the role of the box and clipping sphere is reversed as follows:
we have the top right object. It is obtained by cutting off all part of a sphere that is inside of the box.sphere { 0*x, 1.45 clipped_by { box { < -1, -1, -1 >, < 1, 1, 1 > } } // pigment and finish }
This reverse the inside/outside definition of a sphere. Thus, point < 2, 0, 0 > and < 0.5, 0, 0 > now lie in the "inside" and "outside" of the sphere, respectively. Thus, using inverse will affect all CSG operations and clipping.sphere { 0*x, 1 inverse }
The lower left object above is generated by
All parts of the box that are in the outside of the unit sphere (or the inside of the "inverted" unit sphere) are preserved. Please compare this with the top left object. In fact, the union of these two objects is the box itself. Why?box { < -1, -1, -1 >, < 1, 1, 1 > clipped_by { sphere { 0*x, 1.45 inverse } } // pigment and finish }
The lower right object above is generated with the following:
All parts that are outside of the clipping box (or inside of the "inverted" box) are preserved.sphere { 0*x, 1.45 clipped_by { box { < -1, -1, -1 >, < 1, 1, 1 > inverse } } // pigment and finish }