CSG: intersection

An intersection builds a new solid from a list of shapes by taking the common part of all them.

Though intersections can be defined using both convex and concave solids, XSight RT provides internal classes for implementing convex solids intersections in a more efficient way. All ray intersections with a convex volume yields one or two intersection points, at most. Our current intersection algorithm takes advantage of this fact to optimize memory use. All primitive shapes in XSight RT are also convex solids, with one exception: tori. Planes are considered convex solids: when used in CSG intersections, planes are considered as hemispaces, with one regular intersection point and a second intersection in the infinite limit.

Syntax

For instance, when two intersected solids share a common surface, which material should we choose for the intersection?.

Just for your convenience, we have added this alternative constructor if you prefer to specify the new material as the first parameter.

Operator syntax

Two shapes can be intersected by using the star operator * with them:

    cylinder([-2, 0, 0], [+2, 0, 0], 0.8, plastic(red)) *
        cylinder([0, -2, 0], [0, +2, 0], 0.8, plastic(blue))

In this case, no material is specified.

Example

This expression intersects three orthogonal cylinders, and then rotates the result, looking for a more dramatic effect:

    rotate(20, 20, 20,
        intersection(
            cylinder([-2, 0, 0], [+2, 0, 0], 0.8),
            cylinder([0, -2, 0], [0, +2, 0], 0.8),
            cylinder([0, 0, -2], [0, 0, +2], 0.8),
            metal(royalblue, 0.1, 0.0, 0.8, 1, 10)))

See also

Home | CSG operations | Difference | Union | Cone | Cylinder | Sphere | Torus