# 2.3. CSG Operations¶

class raysect.primitive.csg.CSGPrimitive

Constructive Solid Geometry (CSG) Primitive base class.

This is an abstract base class and can not be used directly.

CSG is a modeling technique that uses Boolean operations like union and intersection to combine 3D solids. For example, the volumes of a sphere and box could be unified with the ‘union’ operation to create a primitive with the combined volume of the underlying primitives.

Parameters: primitive_a (Primitive) – Component primitive A of the compound primitive. primitive_b (Primitive) – Component primitive B of the compound primitive. parent (Node) – Scene-graph parent node or None (default = None). transform (AffineMatrix3D) – An AffineMatrix3D defining the local co-ordinate system relative to the scene-graph parent (default = identity matrix). material (Material) – A Material object defining the CSG primitive’s material (default = None).
primitive_a

Component primitive A of the compound CSG primitive.

Return type: Primitive
primitive_b

Component primitive B of the compound CSG primitive.

Return type: Primitive
class raysect.primitive.csg.Union

CSGPrimitive that is the volumetric union of primitives A and B.

All of the original volume from A and B will be in the new primitive.

Parameters: primitive_a (Primitive) – Component primitive A of the union operation. primitive_b (Primitive) – Component primitive B of the union operation. parent (Node) – Scene-graph parent node or None (default = None). transform (AffineMatrix3D) – An AffineMatrix3D defining the local co-ordinate system relative to the scene-graph parent (default = identity matrix). material (Material) – A Material object defining the new CSG primitive’s material (default = None).
class raysect.primitive.csg.Intersect

CSGPrimitive that is the volumetric intersection of primitives A and B.

Only volumes that are present in both primtives will be present in the new CSG primitive.

Parameters: primitive_a (Primitive) – Component primitive A of the intersection operation. primitive_b (Primitive) – Component primitive B of the intersection operation. parent (Node) – Scene-graph parent node or None (default = None). transform (AffineMatrix3D) – An AffineMatrix3D defining the local co-ordinate system relative to the scene-graph parent (default = identity matrix). material (Material) – A Material object defining the new CSG primitive’s material (default = None).
class raysect.primitive.csg.Subtract

CSGPrimitive that is the remaining volume of primitive A minus volume B.

Only volumes that are unique to primitive A and don’t overlap with primitive B will be in the new CSG primitive.

Parameters: primitive_a (Primitive) – Component primitive A of the intersection operation. primitive_b (Primitive) – Component primitive B of the intersection operation. parent (Node) – Scene-graph parent node or None (default = None). transform (AffineMatrix3D) – An AffineMatrix3D defining the local co-ordinate system relative to the scene-graph parent (default = identity matrix). material (Material) – A Material object defining the new CSG primitive’s material (default = None).