Algorithm Search⌘K

Modeladvanced

Function representation

Also called FRep, F-rep.

Represents a solid as the set where a continuous real function is at least 0. Booleans, blends, offsets and maps are operations that make new functions from old ones.

Function representation (F-rep) describes a solid by one real function. A continuous function ff on space defines the solid {x:f(x)≥0}\{x : f(x) \ge 0\}: the points with f>0f > 0 are inside, the points with f=0f = 0 are on the boundary, and the points with f<0f < 0 are outside. A union, an intersection, a blend or a twist of solids is then an operation that makes a new function from the old ones, so a model is an expression tree of primitives and operations, like a CSG tree with more kinds of nodes. Pasko, Adzhiev, Sourin and Savchenko proposed this framework in 1995, and its set operations use the R-functions of Rvachev, of which min⁡\min and max⁡\max are the simplest. The page has the kind "model", but F-rep is a representation scheme, not a model of cost; so the four sections of the model kind give the representation ("the machine"), what it can express ("what it counts"), its relation to other representations, and the known results.

The machine

The "machine" here is the representation: the data that stores a solid and the one query that it answers directly, the sign of ff at a point. An F-rep object in Rn\mathbb{R}^n is given by a continuous function f:Rn→Rf : \mathbb{R}^n \to \mathbb{R}, and the object is

S(f)={x∈Rn:f(x)≥0}.S(f) = \{x \in \mathbb{R}^n : f(x) \ge 0\}.

The sign is the opposite of the signed distance function, which is negative inside; if dd is the signed distance to a solid, then f=−df = -d represents it here. The function is stored as an expression: a tree whose leaves are primitives and whose inner nodes are operations. To classify a point, evaluate the tree at the point and look at the sign of the value. This takes one pass over the tree.

Some primitives, with cc a point and r>0r > 0:

primitive function f(x)f(x)
ball of radius rr at cc r2−∥x−c∥2r^2 - \lVert x - c \rVert^2
halfspace a⋅x≤ba \cdot x \le b b−a⋅xb - a \cdot x
infinite cylinder of radius rr about the zz axis r2−x12−x22r^2 - x_1^2 - x_2^2
a sampled volume, such as a CT scan the interpolated value minus a threshold

The set operations come from R-functions. For a parameter α\alpha with −1<α≤1-1 < \alpha \le 1,

f1∨αf2=f1+f2+f12+f22−2αf1f21+α,f1∧αf2=f1+f2−f12+f22−2αf1f21+α.f_1 \vee_\alpha f_2 = \frac{f_1 + f_2 + \sqrt{f_1^2 + f_2^2 - 2 \alpha f_1 f_2}}{1 + \alpha}, \qquad f_1 \wedge_\alpha f_2 = \frac{f_1 + f_2 - \sqrt{f_1^2 + f_2^2 - 2 \alpha f_1 f_2}}{1 + \alpha}.

Union is f1∨αf2f_1 \vee_\alpha f_2, intersection is f1∧αf2f_1 \wedge_\alpha f_2, complement is −f-f and difference is f1∧α(−f2)f_1 \wedge_\alpha (-f_2). With α=1\alpha = 1 the root is ∣f1−f2∣\lvert f_1 - f_2 \rvert, so ∨1=max⁡\vee_1 = \max and ∧1=min⁡\wedge_1 = \min. With α=0\alpha = 0 the operations are f1+f2±f12+f22f_1 + f_2 \pm \sqrt{f_1^2 + f_2^2}, which are smooth wherever f1f_1 and f2f_2 are smooth and not both 0.

The other operations of the F-rep framework act on the function in the same way. The blend below is the bounded blending used in F-rep: a displacement added to an R-function.

operation new function what it does
blended union f1∨αf2+a01+(f1/a1)2+(f2/a2)2f_1 \vee_\alpha f_2 + \dfrac{a_0}{1 + (f_1 / a_1)^2 + (f_2 / a_2)^2} adds material near the meeting of the two boundaries, so the join is rounded; a0<0a_0 < 0 removes material instead
offset f−tf - t or f+tf + t shrinks or grows the solid; it is the true offset by tt only when ff is a distance
bijective map TT f(T−1(x))f(T^{-1}(x)) moves, scales, twists or bends the solid
metamorphosis (1−τ)f1+τf2(1 - \tau) f_1 + \tau f_2 for 0≤τ≤10 \le \tau \le 1 turns one solid into the other as τ\tau goes from 0 to 1
Cartesian product f1(x)∧αf2(y)f_1(x) \wedge_\alpha f_2(y) on the pairs (x,y)(x, y) the product of an nn-dimensional and an mm-dimensional object
projection max⁡yf(x,y)\max_y f(x, y) the shadow of an object of dimension n+1n + 1 in dimension nn

What it counts

F-rep counts no cost; this section says which solids it can express. In the terms of Requicha's theory of representation schemes, F-rep has these properties.

  • Domain. Every closed set is S(f)S(f) for some continuous ff, for example f(x)=−dist⁡(x,S)f(x) = -\operatorname{dist}(x, S). So the domain is limited only by the primitives and operations that a system offers. With polynomial primitives and min⁡\min and max⁡\max, the domain is exactly the closed semialgebraic sets (see the known results).
  • Validity. Every continuous ff gives a closed set, but the set can be empty, unbounded, or not regular. For f(x)=−x12f(x) = -x_1^2 the set is the plane x1=0x_1 = 0, which has no interior. So a valid solid needs a check that the tree alone does not give.
  • Unambiguity. The function decides each point, so the set is fixed by the function.
  • Uniqueness. It fails. The functions ff, 2f2f and f3f^3, and the R-function operations for every α\alpha, give the same set with different functions.

The model is not limited to three dimensions. A function of (x,τ)(x, \tau) is an object that changes with the time τ\tau, a function of more coordinates can carry material or colour, and the product and the projection move between dimensions.

Relation to other models

The other models here are the other representation schemes of solids and surfaces.

  • Constructive solid geometry. A CSG tree whose primitives have defining functions becomes an F-rep tree when each ∪∗\cup^*, ∩∗\cap^* and −∗-^* is replaced by max⁡\max, min⁡\min and min⁡(f1,−f2)\min(f_1, -f_2). The known results below give the condition under which this is exact for the regularized operations. Blends, metamorphosis and general maps have no CSG node, so F-rep is the larger scheme.
  • Implicit surfaces. The boundary f=0f = 0 is an implicit surface, and it is a smooth surface where the gradient of ff is not 0. F-rep is about the solid, not about the surface: the sign gives the inside.
  • Distance functions. A signed distance is one choice of ff, with the opposite sign. F-rep does not need it: most F-rep functions, among them every ∨0\vee_0 and ∧0\wedge_0 result, are not distances.
  • Spatial occupancy enumeration. Sampling the sign of ff at the centres of grid cells gives a voxel set, and a voxel grid of values with interpolation gives an F-rep primitive.
  • Boundary representation. F-rep stores no faces or edges. A B-rep or a mesh must be computed, usually by isosurface extraction such as marching cubes, and it is an approximation. In the other direction, B-rep to CSG conversion in the work of Shapiro and Vossler finds a Boolean expression of halfspaces, and R-functions can turn such an expression into one function.

Known results in the model

The sign sets of min and max. For continuous ff and gg, S(max⁡(f,g))=S(f)∪S(g)S(\max(f, g)) = S(f) \cup S(g), S(min⁡(f,g))=S(f)∩S(g)S(\min(f, g)) = S(f) \cap S(g) and S(min⁡(f,−g))=S(f)∩{g≤0}S(\min(f, -g)) = S(f) \cap \{g \le 0\}, since max⁡(a,b)≥0\max(a, b) \ge 0 exactly when a≥0a \ge 0 or b≥0b \ge 0, and min⁡(a,b)≥0\min(a, b) \ge 0 exactly when both are. These are the ordinary set operations, not the regularized ones. For the halfspaces f=x1f = x_1 and g=−x1g = -x_1, S(min⁡(f,g))S(\min(f, g)) is the plane x1=0x_1 = 0: a dangling face.

The regularized reading. Read the solid of ff as [f]=cl⁡{f>0}[f] = \operatorname{cl}\{f > 0\}, which is always closed and regular. Suppose the zero sets {f=0}\{f = 0\} and {g=0}\{g = 0\} have no interior. Then [max⁡(f,g)]=[f]∪∗[g][\max(f, g)] = [f] \cup^* [g], [min⁡(f,g)]=[f]∩∗[g][\min(f, g)] = [f] \cap^* [g] and [min⁡(f,−g)]=[f]−∗[g][\min(f, -g)] = [f] -^* [g], and the three new functions again have zero sets with no interior, so the rule holds for whole trees. In the example above, [min⁡(f,g)]=∅[\min(f, g)] = \emptyset, the regularized answer.

Proof. Write A=[f]A = [f], B=[g]B = [g], P={f>0}P = \{f > 0\} and Q={g>0}Q = \{g > 0\}; these sets are open, and PP is dense in AA. Union: {max⁡(f,g)>0}=P∪Q\{\max(f, g) > 0\} = P \cup Q, whose closure is A∪BA \cup B, and a union of two regular closed sets is regular, so it is A∪∗BA \cup^* B. Intersection: let U=int⁡A∩int⁡B=int⁡(A∩B)U = \operatorname{int} A \cap \operatorname{int} B = \operatorname{int}(A \cap B). The open set PP is dense in int⁡A\operatorname{int} A, so P∩UP \cap U is dense and open in UU, and in the same way Q∩UQ \cap U is dense and open in UU. Two dense open subsets of UU meet in a dense subset, so cl⁡(P∩Q)=cl⁡U=A∩∗B\operatorname{cl}(P \cap Q) = \operatorname{cl} U = A \cap^* B. Difference: A−∗B=cl⁡(int⁡A∩(Rn∖B))A -^* B = \operatorname{cl}(\operatorname{int} A \cap (\mathbb{R}^n \setminus B)), because BB is closed. The set N={g<0}N = \{g < 0\} is open and misses BB. Each nonempty open WW outside BB has g≤0g \le 0 on it, and WW is not inside the zero set of gg, so WW meets NN: NN is dense in Rn∖B\mathbb{R}^n \setminus B. As for the intersection, cl⁡(P∩N)=A−∗B\operatorname{cl}(P \cap N) = A -^* B. The zero sets of max⁡(f,g)\max(f, g) and min⁡(f,±g)\min(f, \pm g) lie in the union of the zero sets of ff and gg, a finite union of closed sets with no interior, which has no interior. □\square

R-functions keep the sign of min and max. For −1<α≤1-1 < \alpha \le 1, f1∨αf2f_1 \vee_\alpha f_2 has the sign of max⁡(f1,f2)\max(f_1, f_2) and f1∧αf2f_1 \wedge_\alpha f_2 has the sign of min⁡(f1,f2)\min(f_1, f_2), so every result above holds for them too. Proof. Write x=f1x = f_1, y=f2y = f_2 and D=x2+y2−2αxyD = x^2 + y^2 - 2 \alpha x y, so D−(x+y)2=−2(1+α)xyD - (x + y)^2 = -2(1 + \alpha) x y. If x,y<0x, y < 0, then D<(x+y)2D < (x + y)^2 and x+y+D<0x + y + \sqrt D < 0. If one of them is 0 and the other is at most 0, the sum is 0. If xy<0x y < 0, then D>∣x+y∣\sqrt D > \lvert x + y \rvert and the sum is positive; if x,y≥0x, y \ge 0 and not both 0, the sum is positive. Divide by 1+α>01 + \alpha > 0. For ∧α\wedge_\alpha, note f1∧αf2=−((−f1)∨α(−f2))f_1 \wedge_\alpha f_2 = -((-f_1) \vee_\alpha (-f_2)). □\square This is the defining property of an R-function: its sign depends only on the signs of its arguments, through a Boolean function. It also means that an exact sign test of an R-function tree needs no square roots: compute the signs of the leaves and combine them by the Boolean rules, as in exact geometric computation.

The functions are not the same as the sets. The operations ∨α\vee_\alpha and ∧α\wedge_\alpha for α<1\alpha < 1 are not idempotent on functions: f∨0f=(2+2)ff \vee_0 f = (2 + \sqrt 2) f for f≥0f \ge 0. So the function of a tree depends on its shape, a distance function does not stay a distance after an R-function, and an offset f−tf - t of such a result is not the true offset by tt (see solid offsetting).

The domain with polynomials. If the primitives are polynomials and the operations are min⁡\min, max⁡\max and −f-f, then S(f)S(f) is a closed semialgebraic set, by induction on the tree. Conversely, by the finiteness theorem of real algebraic geometry, every closed semialgebraic set is a finite union of sets {pi1≥0,…,pik≥0}\{p_{i1} \ge 0, \ldots, p_{ik} \ge 0\}, so it is S(max⁡imin⁡jpij)S(\max_i \min_j p_{ij}).

Point membership and rendering. One point test costs one evaluation of the tree, O(N)O(N) operations for a tree of NN nodes. With interval arithmetic, the same tree evaluated on a box gives an interval that contains every value of ff on the box. If the interval is positive, the whole box is inside; if it is negative, the whole box is outside. This gives guaranteed in and out boxes for meshing and for octrees, and only the unknown boxes need more work. Ray casting needs the first root of ff along a ray; when ff has a known Lipschitz constant (Lipschitz condition), sphere tracing finds it without missing a thin part. Without such a bound, sampling of ff at grid points or along a ray can miss features smaller than the step. These guarantees are proved; the speed of the methods depends on the model and is only measured.

History. Ricci in 1973 defined union and intersection of solids given by functions, with max⁡\max and min⁡\min, and smooth approximations of them that blend the joins. Rvachev developed the theory of R-functions from the 1960s, as Shapiro's survey of 2007 describes. Pasko, Adzhiev, Sourin and Savchenko gave the F-rep framework in 1995, with R-functions for the set operations and a list of other operations on the defining function, in any number of dimensions.

References

  1. Alexander Pasko, Valery Adzhiev, Alexei Sourin and Vladimir Savchenko, Function representation in geometric modeling, concepts, implementation and applications, The Visual Computer 11(8), 429 to 446, 1995, the definition of an object by f(X) ≥ 0 in n dimensions, and the operations on the defining function, set-theoretic operations by R-functions, blending, offsetting, bijective mapping, projection, Cartesian product and metamorphosis
  2. Vadim Shapiro, Semi-analytic geometry with R-functions, Acta Numerica 16, 239 to 303, 2007, the definition of R-functions, the systems R_α with min and max as the case α = 1, their smoothness, and their history from Rvachev's work of the 1960s
  3. A. Ricci, A constructive geometry for computer graphics, The Computer Journal 16(2), 157 to 160, 1973, union and intersection of solids given by functions, and their smooth approximations that blend the joins
  4. Jacek Bochnak, Michel Coste and Marie-Françoise Roy, Real Algebraic Geometry, Springer, 1998, Chapter 2, Section 2.7, Theorem 2.7.2 (the finiteness theorem, every closed semi-algebraic set is a finite union of basic closed semi-algebraic sets)
  5. Aristides A. G. Requicha, Representations for rigid solids, theory, methods, and systems, ACM Computing Surveys 12(4), 437 to 464, 1980, the properties of a representation scheme, its domain, validity, unambiguity and uniqueness, used here to place F-rep among the schemes

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/6SDGKH/text.yaml