Scalar Fields, Isosurfaces and Constructive Solid Geometry
This page provides the mathematical foundation for this library. Understanding of the notation, conventions and constructions in this page is integral to effective use the advanced methods the library has to offer.
Tensor Notation
This library employs tensor notation throughout. Understanding the notation conventions will help clarify the mathematical exposition.
- Objects with no indices are scalar-valued. (e.g. , )
- Objects with one or more indices are tensor-valued. (e.g. , , )
- Rank- tensors (vectors) are represented in lower-case, rank- where tensors use upper-case. (e.g. , )
- Tensor operations use Einstein summation notation, eliding the summation notation (e.g. )
- Element-wise or broadcasted multiplication is indicated by juxtaposition (e.g. ). Shared indices indicate broadcasted multiplication (e.g. is the action of multiplying each row of by the -th element of ).
- The spacial dimension is indexed by , and the batch dimension is indexed by . (e.g. , )
Scalar Fields and Isosurfaces
Consider a scalar-valued function . This function is a field defined over a domain . An isosurface of is the set of points such that , where is a constant. Without loss of generality, we study only.
Naturally, we define the surface of , , as the set of points such that .
Classifying vectors as inside or outside the region enclosed by is a common task in computer graphics. Specifically, a vector is inside the surface if and outside the surface if .
Batch Processing with Tensors
In the form above, operates sequentially over vectors . To enable batch evaluation of , we define a tensor-valued function .
where is a rank- tensor with length . Concretely, satisfies the following properties:
where is the Kronecker delta.
The first property states that is equivalent to evaluating over each row of independently.
The second property states that the Jacobian of with respect to our choice of input is block diagonal, meaning each output row is a function of only its corresponding input row.
For the remainder of this work, we opt to use our batch, tensor-valued formulation of for all computations.
Transformations
Any function can be used to perform covariant transformations on our scalar fields, without having to change our definition of .
Intuitively, the transformation is not on , but on the domain of .
Concretely, we can implement common transformations on our scalar fields by choosing an appropriate .
Translation
Translation can be written as a tensor-valued function that takes a tensor and returns a translated tensor .
where is the translation vector.
Scaling
Scale can be written as a tensor-valued function that takes a tensor and returns a scaled tensor .
where is the scale factor.
Rotation
A general -dimensional coordinate rotation can be written as an operator that takes a tensor and returns a rotated tensor and .
Rotations like can be represented by a sequence of individual plane rotations. A plane rotation is a rotation in a 2D plane spanned by two coordinate axes, and , and is parameterized by a rotation angle . Call this plane rotation . Then, the general -dimensional rotation can be written as a product of plane rotations.
Intuitively, is the identity tensor.
CSG Operations
The fundamental object in CSG is the Region
, which is defined as the set of points such that . Region
s are combined using the set-theoretic operations of union, intersection, and difference 4. Mathematically, these operations are defined as the following tensor:
In direct set notation, these composite Region
s are defined as follows:
These operations align with our intuitive understanding of set theory over , but they are expressed solely in terms of scalar fields.
CSG Algebras
In practice, one is free to override and redefine these operations. We define an Algebra
as an implementation of the above contract. This is an algebra in the mathematical sense, as well as in our algorithms. The theoretical foundation for R-functions used in CSG operations was established by Rvachev 3.
where is the power set of .
Advanced CSG Operations
Beyond the basic operations, crater.rs implements more sophisticated ways to combine scalar fields.
Differentiable Approximations
In practice, one may wish to use a differentiable approximation of the basic CSG operations. These methods provide smooth blending capabilities as described in the Function Representation literature 2.
where is a parameter that controls the smoothness of the operation. reduces to the original min-max operations.
Blending
One such custom CSG algebra enables continuous blending between two regions.
The blending function is defined as follows, and is added to the outputs of both the and operators.