Re nement Methods for Geometric Bounds in Constructive ... - CiteSeerX

9 downloads 0 Views 329KB Size Report
Abstract. In Constructive Solid Geometry, geometric solids are represented as trees whose leaves are labelled by primitive solids and whose internal nodes areĀ ...
Re nement Methods for Geometric Bounds in Constructive Solid Geometry Stephen Cameron Chee-Keng Yap Computing Laboratory Courant Institute University of Oxford, UK New York University February 1991

Abstract

In Constructive Solid Geometry, geometric solids are represented as trees whose leaves are labelled by primitive solids and whose internal nodes are labelled by set-theoretic operations. A bounding function in this context is an upper or lower estimate on the extent of the constituent sets; such bounds are commonly used to speed up algorithms based on such trees. We introduce the class of totally consistent bounding functions, which have the desirable properties of allowing surprisingly good bounds to be built quickly. Both outer and inner bounds can be re ned using a set of rewrite rules, for which we give some complexity and convergence results. We have implemented the re nement rules for outer bounds within a solid modelling system, where they have proved especially useful for intersection testing in three and four dimensions. Our implementations have used boxes as bounds, but di erent classes (shapes) of bounds are also explored. The rewrite rules are also applicable to relatively slow, exact operations, which we explore for their theoretical insight, and to general Boolean algebras. Results concerning the relationship between these bounds and Active Zones are also noted. This paper appeared in ACM Transaction on Graphics 11(1):12{39, January 1992,

c ACM 1992. Contact address: Oxford University Computing Laboratory, Wolfson Building, Parks Road, Oxford OX1 3QD, UK. Phone: +44 1865 273850.

Categories and Subject Descriptors: F.2.2: Geometrical problems and computations; Computations on discrete structures; I.1.1: Simpli cation of expressions; I.3.5: Hierarchy and geometric transformations; J.6: Computer-aided design; Computer-aided manufacturing. General Terms: Algorithms, Design, Performance, Theory. Additional Key words and Phrases: Boolean algebra, constructive solid geometry, interference detection, collision detection, representation simpli cation, robotics, solid modelling. 1

1 Introduction Outer bounds are commonly used to speed up geometric algorithms. For example, if we wish to tell whether two geometric entities intersect, then if we form spheres around the entities and the spheres do not intersect, we deduce that the entities cannot intersect. This concept of a bound is so `obvious' that it may seem strange that we can spend an entire paper talking about bounds! However, some subtleties arise if we allow bounds which are not bounds in the normal sense but do have desirable computational properties. We will show that these other types of bounds are possible, and useful, when geometric entities are described constructively. In Constructive Solid Geometry (CSG), we build up complicated shapes from a collection of simple shapes [11]. We can think of a CSG description as a tree, in which the internal nodes correspond to set operations, and the leaf nodes correspond to the simple shapes, or primitives, and the branches of the tree imply functional application. To compute the shape represented by the tree, we start at the leaves and work our way up the tree, applying set operations as we go. Many modelling systems use CSG as their primary construction method (e.g., [3, 6]), and many other systems permit constructive operations in making up their data-structures (e.g., [2]). The normal way of applying bounds with a CSG tree is to attach suitable supersets of the primitives (the bounds) to the leaf nodes. However we can then extend the notion of a bound to every node in the tree, as follows. If we have a binary node T , corresponding to a union operation, and we know that its child nodes represent shapes that are bounded by Sl and Sr , then the shape represented by T must be contained within Sl [ Sr , and so this set is a bound on T . Similarly, if the node corresponded to an intersection operation then the corresponding composite bound would be Sl \ Sr . In this way we could recursively compute a bound for every node in the tree. Other considerations arise to make this idea more involved: in particular, for eciency of processing we may desire the bounds at each node to be a `rectangle' (of appropriate dimensionality). Then Sl [ Sr must be replaced by the smallest enclosing rectangle. If other shapes are desired, the solution may not be so obvious. However, besides the propagation of bounds upwards in a tree, we can also have downward propagation. Consider a simple example, where the `shapes' are one dimensional lines. If shape A can be bounded by the interval [0; 2], and shape B by [1; 3] then we can bound A \ B by [1; 2]. Thus if we want to compute the intersection, we should only have to worry about intersection points within [1; 2], and so [1,2] should be a bound on both A and B (in this new sense). These observations form the basis for all of the work reported: from them we have obtained practical insight that has allowed us to signi cantly speed up certain geometric computations in a solid modelling system, as well as discovering a rich area for theoretical results. The practical implementations have been detailed elsewhere [4, 5], and so the emphasis in this paper is on the theoretical underpinnings. However for clarity we will rst describe the main results using the system of bounding boxes that form the basis of our practical implementation (x2), and how it relates to other work (x3), before considering the general cases that apply for any type of system of bounds that obey our rules (x4). x5 will continue the study of such bounds, with algebraic properties and convergence results 2

for di erent types of bounds (e.g., boxes, spheres, and convex hulls). We will then consider two other, related, bounding systems. In x6 we will consider bounds based on subsets of objects, rather than supersets, which turn out to have dual properties to the properties of the superset bounds. All the above discussion is based on CSG trees limited to set union and set intersection operations. In x7 we will show that these results do not entirely hold if we have complement or di erence operators in our CSG trees; however, we show that a slightly less general system of bounds, called S-bounds, can be successfully applied in these cases. (S-bounds are, in fact, the basis of our implementations.)

2 Overview

The one-dimensional example of x1 introduced the reasoning behind the rules that we use to reason about the extent of expressions in a CSG tree; a two-dimensional example will suce to illustrate the practical use of these ideas. Consider gure 1(a), which shows a small CSG tree with two operators,  and denoting union and intersection respectively. The squares in the gure are frames that help to show the relative size and position of polygons, three of which are primitive shapes (shown at the leaves of the tree), and the fourth shows the nal shape denoted by the tree1 (i.e., the union of the triangle and the parallelogram, intersected with the wedge.) We can now consider bounds on the tree nodes, restricting ourselves to boxes aligned with the frames. Such a restriction makes a lot of sense computationally, as each box can be denoted by four numbers, and they are easy to work with. Figure 1(b) shows bounds that are larger than the primitive polygons, and also shows bounds on the two internal nodes of the tree; as we have no a priori knowledge of what constitutes sensible bounds for these nodes we will use , the universal set, as

is bigger than any set. We are now in a position to apply the reasoning described in x1. Working our way up the tree, we take the union of the lower two primitives' bounds, and this indeed will be a superset of the partial shape given by the union node in the tree. However, for computational reasons we actually store a box that ts around the union of the two bounds, rather than the union itself, and indeed this box can be generated directly (without explicitly forming the union of the bounds) by taking maxima and minima of the coordinates that de ned the corners of the leaf-node boxes. This box is shown in gure 1(c) (the boxes that were used to generate it are shown dashed). We now have two nite bounds below the root node of the tree, and a nite bound for this node can now be generated, by taking the intersection of the two bounds on its child nodes ( gure 1(d)). We now have supersets of the shapes formed by evaluating the CSG tree at every node in the tree. If we now treat the box at the root node as a `window' through which all of the interesting parts of the tree can be viewed, we can take this window and intersect it with the boxes at its child nodes. Repeating this process about the union node, we can intersect the new bound found here with its two children, giving the bound set of gure 1(e). The boxes that have been generated are no longer supersets of the partial shapes generated if we were to evaluate the tree in the normal way (shown dotted), and in particular the left-most node has an empty box (;) as its bound now. However, if we evaluate the tree, 1

The terminology will be made precise in x4.

3

using the bounds generated as windows on which parts of the partial shapes to bother evaluating (throwing out parts that lie outside their windows), we will indeed obtain the same shape as before at the root node of the tree. The general form of the rules are as follows. Working our way up the tree, take the set operation at a node, apply it to the two bounds in the child nodes, and intersect the result with the bound that was already at the node. (The usage described in the example was a special case of this rule, as the existing bounds were both .) Working our way down the tree, take the bound at a parent node and intersect it with the bound at the child node, replacing the child's bound. As we shall see, the order of applying the rules does not a ect the validity of the process as we always end up with a suitable set of `windows'. However, the natural order of working our way from the bottom up, and then working our way down again, is guaranteed to continue making progress. What may be surprising is that we may often improve matters by repeating the process; the example of gure 1 is a case in point, whereby performing another sweep up the tree and then down the tree gives us the set of bounds of gure 1(f). In this case applying the rules again makes no di erence. The fact that the left-most node is bounded by ; means that we can ignore this node entirely2, and we can in fact replace the original tree by a simpler tree that is the intersection of the parallelogram and the wedge. Further, we only need to worry about computing the intersection within the relatively small window (bound) that has formed about the root node. This fact may not make much di erence in this simple case, but we can apply the same sort of reasoning for arbitrarily complex primitive shapes in any number of dimensions. As a three-dimensional example, gure 2(a) shows a robot (modelled using 19 primitive shapes) in an environment (modelled using 4 primitive shapes). We can perform interference testing between the robot and the environment by checking whether their intersection set is empty (null). Thus we form, symbolically, the CSG tree that represents this intersection set, and we could evaluate this immediately. Instead we use aligned three-dimensional boxes to bound each node in the tree. Figure 2(b) shows the nite boxes3 initially formed about the primitive nodes; we can then work our way up and down the tree, using the re nement rules, until the bounds are no longer changing. In this case, every node in the tree becomes bounded by ; after two passes, implying that the intersection is null without even having to consider the detailed geometry. Rotating the waist joint of the robot to ensure interference gives us an example in which the objects do interfere: gure 2(c) shows an outline of the objects, with the thick lines around the intersection volume showing the 5 non-empty bounds left after three passes. The smallness of these bounds means that the subsequent processing required to prove interference requires little computation time [4]. We may be tempted to ask questions about the way that the bound system converges| if at all. These issues are detailed later in this paper, but basically:  This bound system always does converge. Further, using the natural application sequence described, it always converges in at most n ? 1 passes up and down the tree, and it always converges to the same nal state (given the same starting state).  These results apply whatever the dimensionality of the boxes used. 2 3

Tilove calls such nodes ;-redundant [15]. In nite half-spaces were used to model the robot, which are initially bounded by .

4



 HHj H

?? @@ ??   @ ?? @@       (a)







(b)

(c) p p p p p p p p pp p

p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p

p p p p p p p p p pp p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p

p

p p p p p p p p p pp p

p p p p p p p p p p p p p p p p p p p p p p p p p p p p p

(d)

5

;

p

p p p p p p p p p p p p p p p

(e)

p p

Y Z X

(a)

(b)

Y Z X

(c)

Figure 2: Three-Dimensional Example

 Rules also exist for trees with di erence and complement operations in them.  Similar (though not as powerful) results hold for other types of bounds, such as bubbles and convex hulls.

3 Related Work The use of bounds has passed into the folklore of computational geometry and solid modelling. Most of the work described here has been heavily in uenced by work at the University of Rochester's Production Automation Project, which resulted in the padl series of geometric modelling systems. In particular, Tilove introduced the notion of redundant primitives [14] and others at the project investigated some of the `obvious' rules described here, which were later introduced into padl-2. However they did not introduce the abstraction of a bounding function (which allows us to consider the algebraic and convergence properties of these rules), and they did not generalise the rewrite rules to allow multiple applications [9]. Instead they took the idea that we call `consistency' and de ned a concept called the active zone, which is e ectively (in our notation) the `smallest' possible consistent bound [12, 8]. Active zones have been used to design faster geometrical operations on CSG trees, especially boundary evaluation, but instead of being evaluated directly they are used to prune geometric information within complex geometric computations (such as boundary evaluation). In contrast, our work has concentrated on a general, computational framework for arbitrary bounds, which may be evaluated eciently, normally as a preprocessing stage. We have implemented this work as part of the robmod geometric modelling system [6], where it has proved especially useful for interference detection [4] and collision detection (by considering intersections in four-dimensional space-time [5]).

6

4 Totally-Consistent Bounds We now start the formal analysis of systems of bounds. To characterise bounds we need some notation and conventions that allow us to discuss them; in particular, we need to be able to distinguish between the CSG tree as a data-structure within the computer, and the set4 represented by that data-structure. Thus we say that a tree consists of a number of internal nodes, which we label with the symbols , and , corresponding to the operations [, \ and ? (set di erence) respectively5. The leaf nodes of the tree correspond to primitive shapes; we label these nodes as convenient (e.g., L, Pn ). Any node in the tree can also be given a convenient label to uniquely distinguish it for the purpose of the discussion. We use T , T1, etc., as labels for general nodes, and reserve the label T for the root node of the entire tree. We can also regard the label of a node as standing for the subtree with that node as the root|these uses may be distinguished by context. For most of this paper we will consider only trees with union and intersection nodes, called positive trees. This is not a theoretical limitation as we can always rewrite a tree that contains di erence nodes using the set identity X ? Y = X \ Y (where is the set complement operation), and we can always rewrite a tree that contains complement operations by repeated use of De Morgan's Laws, starting at the root node of the tree and working down towards the leaves. However there may be practical reasons for preferring to deal with the original tree, and in x7 we discuss the case where these other operators are allowed. These foundations allow us to describe a tree as a syntactic structure: to enable us to assign some semantics to a tree we need to know what shapes each leaf node corresponds to. We assume the existence of a primitive interpretation function, , which takes a leaf node and returns a shape (i.e., a subset of d2 > rl2 ? rs2; (c) d2 = rl2 ? rs2 (from now on, the smaller sphere forms the `intersection'); (d) d = rl ? rs .

15

B A

D

F

C

E

Figure 6: A collection of circles that exhibit two, distinct xed-points. and in fact the xed-points of this system need not be unique. Consider gure 6, which shows a number of circles with colinear centres. If we consider the circles A, B and C as initial bounds on nodes A, B and C in the tree A \ (B \ C ) and apply the normal up-then-down procedure (with the internal nodes initially bounded by ) we obtain the circle F = (Au_ (Bu_ C))u_ C as the nal bound on each node after two passes. (The other circles shown are D = Bu_ C and E = Au_ (Bu_ C), which are intermediate bounds on nodes.) However, if we take a di erent order whereby we take the initial bound on A and pass it up to the root node and then down to B and C , we nd that C becomes null-bounded (as A \ C = ;), and that this bound propagates to all the nodes. Thus this example exhibits two, distinct xed-points, depending on the order in which the (deterministic) rules are applied.

5.2.2 Convex Hulls

Another possibility for a bounds system is to use convex hulls. That is, each bound is a convex set, with operators u and t , so that u is equivalent to \, and t is equivalent to [ followed by taking the convex hull. These operations are easily shown to be monotonic and associative, and so the operators share some of the properties of a Box-BF system. However the operators do not take constant time to compute. If we assume that we are dealing with convex polytopes (rather than general convex sets) then two convex polygons can be `merged' in time linear in the number of edges in the polygons, and two convex polyhedra can be merged in O(n log n) time [10]. This leads to a total cost bound of O(Nd) for an Up pass or Down pass in the two-dimensional case, where N is the total number of vertices in all of the leaf-node hulls and d is the depth of the tree, and thus a cost bound of O(N log N ) when the tree is balanced. We have not implemented this bound system within our modelling system, but gure 7 illustrates a two-dimensional example. Imagine a two-dimensional robot arm, modelled 16

as the union of seven polygons, and an environment modelled as the union of 4 rectangles ( gure 7(a)). Let T = R E be set up to test for interferences between the robot and its environment, where R and E are the appropriate 13 and 7 node subtrees that model the robot and the environment, and consider the bounds generated in this system on R and E . Figure 7(b) shows these bounds after the initial Up pass, together with the outlines of the primitives (shown dotted). The intersection of these two hulls is generated at the root node, and passed back down the tree at the subsequent Down pass. Figure 7(c) gives the same bounds after the next Up pass, and shows that much of the robot is now being null-bounded. Figure 7(d) shows the next Up pass, and as these bounds do not overlap all of the tree nodes becomes null-bounded after the next Down pass. (This proof of non-interference would not have occurred if we had used box-bounds instead.)

5.2.3 Prism Bounds

Consider a case where we wish to evaluate the intersection of two entities, each of which is described as a CSG tree. We construct a new tree, T = T1 T2, where T1 describes one entity and T2 the other, and apply the rules to generate a good TC-BF. We could use box-bounds for T , all aligned with some standard coordinate axes; this is the approach used in [4]. However we may have some reason for preferring to align the bounds in T1 with one set of axes, and those in T2 with another set. Formally, this can be accommodated by using arbitrary polytopes for the bounds, whilst choosing to store bounds at each node which are boxes with the preferred alignment. As a simple example, consider the intersection of the two two-dimensional shapes shown in gure 8. This intersection is described by a simple, two-leaf tree. Using the standard aligned bounds, the diagonal bar will be bound by a large square, and so we obtain only the horizontal bar as a bound on each node. However, if we use a bound aligned with the diagonal bar for that bar, we can compute the intersection of the two bounds exactly at the root node, whilst passing down bounds to the leaves that have the appropriate alignment; this gives the bounds shown with dotted lines for the two bars. The usefulness of just having, in e ect, a special rule at the root node is that we preserve the unit time cost for the bound operations. In the general case we would have more structure in the trees T1 and T2, but we can still use the standard box operations within each subtree as all the bounds there have the same alignment, and use the special u operation at the root node to combine information from the two subtrees. The example of gure 8 may seem contrived, as the intersection of the bars is small. However the method works for bounds of arbitrary dimension, and as the dimensionality of the bounds increases, the number of simultaneous constraints increases, which conspires to make the intersected region small. In particular, we have used these aligned bounds in a collision detection application where the intersection test in performed in four dimensions (the fourth dimension being time). Then we arrange the bounds on each object to be aligned boxes, moving with their corresponding object, which gives rise to di erent alignments of the four-dimensional prisms at the root node [5].

17

(a)

(b)

(c)

(d)

Figure 7: An example of the convex hull BF system.

18

?@ @?@ @@ @ @@ @@ @ @@ @@ @@ @@ @ @@ @@ @ @@ @@ @@?@? p

p

p

p

p

p

p p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

Figure 8: Example of TC-BFs with Di erent Alignments

5.3 Mixing Bounds

No single type of bound is universally good for all situations; it might be useful if we could use a number of di erent types of bounds and somehow `combine' the results. To do this meaningfully it would be nice if we could take two arbitrary TC-BFs for the same tree, say 1 and 2, and merge them by considering the sets (T ) = 1(T ) \ 2(T ) for each node T . This is not strictly possible with TC-bounds, as the resulting need not be totally consistent! (As an example, consider T = A  B with (A) = (B ) = X 6= ;, 1(T ) = 2(T ) = 1(A) = 2(B ) = , and 2(A) = 1(B ) = ;.) However it is possible to merge TC-BFs generated in the normal way (namely by taking a standard BF and applying the rewrite rules). This follows as such TC-BFs are instances of S-bounds (see x7), for which the merging property does hold. With this proviso in mind we can consider di erent schemes for mixing bounds. One manner of mixing bounds would be to compute a number of bounds in parallel (say a sphere and an aligned box), and leave it to the application to use the di erent bounds as required. For example, in rendering applications the application might generate potential edge segments to be membership classi ed against the CSG tree [13, 12]; the segments can be pruned against all the bounds in the appropriate (generating) node rst. An alternative possibility is to establish a hierarchy of bounds, using, say, aligned boxes and convex hulls. Under this scheme the standard box bounds may be computed rst, and then convex hulls generated for the non-null bounded nodes. This has two advantages: we do not waste time computing convex hull bounds for nodes that are easily proved to be null-bounded, and the box bounds generated can be used as initial convex-hull bounds, with the aligned boxes at the leaf nodes being replaced by their intersection with convex hulls around the primitives. The key idea here is to re ne the `current' bounds only when required. (Such an idea is used in the University of Leeds' isos system [1], in which they use inner bounds as well as outer, standard bounds.) 19

5.4 Theoretical Aspects

For completeness we collect together here some results of interest in developing the theory of TC-bounds, pertaining to what happens if we make the bounds exact, and the idea of ordering di erent TC-BFs.

5.4.1 Exact Combination Operations

We can imagine a TC-BF system in which we start with some standard bound set which has bounds at the internal nodes, and then combine the bounds using the exact form of the Upward and Downward rules (where t  [ and u  \). This system|the exactcombination system|has interesting properties.

 Theorem 2 The exact-combination system forms a xed-point after exactly one Upward pass, followed by a Downward pass.

Proof: Let 0 be the TC-BF generated after the Upward pass, and 00 the TC-BF generated after the Downward pass. Then for a general internal node T = Tl ? Tr we have 0(T ) = 0(Tl) ? 0(Tr ). If the node is a , after the Downward pass we will obtain 00(Tl) = 00(Tr ) = 00(T ), as required by Lemma 1. If the node is , we have 00(T ) = 0(T ) \ Z for some set Z , and so 00(Tl) = 00(T ) \ 0(Tl) = Z \ ( 0(Tl) [ 0(Tr )) \ 0(Tl) = Z \ 0(Tl) Similarly 00(Tr) = Z \ 0(Tr ), and so 00(T ) = 00(Tl) t 00(Tr), thus satisfying Lemma 1. E ectively the exact combination system is the best TC-BF we can generate, in the sense that it gives the best t. Further the BF generated in this way satis es an exact relationship with the active zones [12] for the tree, namely

(T ) = I(T ) \ jT j  Z(T ) \ jT j where I(T ) is the I-zone for the node T and Z(T ) is its active zone [7].

5.4.2 Relative Consistency

Once we have an initial TC-BF for a particular tree the original primitive interpretation  is almost incidental: any further TC-BFs that we generate will also be TC-BFs for any other primitive interpretation 0 for which was a TC-BF. This observation suggests that we can abstract away the interpretation, and just consider the rewrite rules as operating on an arbitrary bounding function. This is the idea behind relative consistency.  Relative Consistency Given a tree T a bounding function 0 is relatively consistent with respect to (written 0  or  0) if for every primitive interpretation  for which is totally consistent, 0 is totally consistent. 20

Then it is easily shown that the Upward and Downward principles produce new bounding functions which are relatively consistent (i.e., if 0 is generated from by use of the Upward or Downward principles then 0  ), and we have the properties:   is re exive and transitive.   is preserved by the Upward and Downward principles.

6 Double Bounds Totally-consistent bounds were derived from the idea of reasoning about supersets, or upper bounds. Although we have been considering only examples using the set algebra, all of our results apply to an arbitrary Boolean algebra (as they are demonstrated only by reference to the axioms and theorems of Boolean algebra). The concept of superset is a specialisation of the concept of supremum in the appropriate Boolean lattice (the powerset lattice), and it is interesting to consider whether a dual system can be developed, based around the lattice in mum. Indeed it can, and for the set algebra it is based around the idea of nding subsets of set expressions. Such subsets could be used, say, to prove interference by demonstrating a lower bound that is known to lie within the intersection set. Without further ado, we introduce the appropriate de nitions.

 De nitions An double bounding function (DBF) is a function from tree-

nodes to pairs of subsets of space; one element of the pair is called the outer bound, and the other element is called the inner bound. We denote DBFs by B, B, etc., and the outer and inner bounds of B(T ) by B^(T ) and B(T ) respectively. A double-bounded interpretation, j  jB , is given by the rules:  If T = Tl ? Tr then jTl ? Tr jB = f(jTljB ? jTr jB ) [ B(T )g \ B^(T )  Otherwise, T is a leaf node, and jT jB = f(T ) [ B(T )g \ B^(T ) In other words, we force the interpretation for the node to be a superset of the inner bound, and then intersect with the outer bound. We say that B is consistent (on T over ) if jT jB = jT j; and we say that B is totally consistent if jT jB0 = jT j; for all other DBFs B 0 with B^0 w B^ and B0 v B. We may consider as DBF a de ning a `skin' around the sets given by the subtrees in a CSG tree, namely the di erence between the outer bound and the inner bound. Indeed, if we take the limiting case where the approximations are exact, by starting with the exact sets and using the exact form of the combination operators, we end up with an exact relationship between this skin and the active zone of a node11. The DBF whose outer bounds are all and whose inner bounds are all ; is a totally consistent double-bounding function Speci cally, B^(T ) = I(T ) \jT j and B(T ) = U(T ) [jT j where I(T ) and U(T ) are the I-zone and U-zone of a node, respectively [12, 7]. 11

21

(TC-DBF). Further, any DBF whose outer/inner bounds are /; on branch nodes, and satis es B^(L)  (L), B(L)  (L) on leaf nodes, is also a TC-DBF. Thus we can usually generate an initial TC-DBF, and use Upward and Downward principles to generate new TC-DBFs. Let the notation f [X ` S ] denote the function that returns the same values as f everywhere except on X , when it returns S . Then the appropriate principles are:

 The Upward Principle (for DBFs) Given a DBF B over a tree T , and an internal node T of the form T = Tl ? Tr, replace the bound at T by a B0 satisfying

B^0 w B^[T ` B^(T ) \ (B^(Tl) ? B^(Tr))] B0 v B[T ` B(T ) [ (B(Tl) ? B(Tr))]  The Downward Principle (for DBFs) Given a DBF B over a tree T , and a node T = 6 T with parent Tp, replace the bound at T by a B0 satisfying B^0 w B^[T ` B^(T ) \ B^(Tp)] B0 v B[T ` B(T ) [ B(Tp)] We outline the proof of the validity of these principles in the appendix. Note that if we start with a TC-DBF whose inner bounds are all ;, we obtain the system of TC-BFs previously described. Also, if we start with a TC-DBF whose outer bounds are all , then we have the immediate dual of the TC-BF system with inner bounds only. It is then tempting to try to set up a speci c inner bound system based on internal boxes. Figure 9 shows such a construction for the two-dimensional outer bound example of gure 1. Figure 9(a) shows a suitable set of initial internal bounds; gure 9(b) shows the bound set achieved after a single pass of the Upward rule. The root node has been internally bounded by ;, and the system has converged. One reason for this is that there is no natural choice for performing the bound operations, as there was with the outer bounds. In gure 9 we picked a rectangle, interior to the set union, with the largest area. Another problem is that the object given by the root node is small, and so any inner bound must be smaller. Figure 9(c) shows the bound set resulting from the same tree, but with the rightmost primitive moved to the left slightly (by 10% of the width of the frame) so that the overlap area is larger. In this case an overlap can be proven by observing the internal bounds.

7 S-bounds

In all of our discussion so far we have admitted CSG trees containing and  operations only. If we admit set di erence or complement operations the theory is not so tidy, as we will illustrate by means of examples. (However the practical results are even more useful, and are indeed what we have implemented within our solid modelling system.) Note that the de nitions of interpretation, bounded interpretation, etc., have natural extensions to the case where these new operators are allowed. So consider a simple tree, T = A B (3) 22

;

;

;

(a)

(b)

(c)

Figure 9: Two-Dimensional Example of TC-DBFs (where is the symbol for the set di erence operation ?). Then, noting the identity X ? Y  X \ Y , we see that the `obvious' Upward rule for T is to re ne the bound (T ) by (T ) \ (A) \ Z , where Z is an outer bound on the extent of jB j. However, we have no information in the existing bounds for such a bound. (This point will be returned to later, when we consider double bounds again.) Thus we obtain:  Upward Principle for Nodes If T = Tl Tr , replace (T ) by a superset of (T ) \ (Tl). We already have a single downward principle (for all set operations), and it would be nice to extend this to the di erence case. However, as the following counterexample shows, this rule does not then preserve total-consistency.  Counter-example Consider the tree T = A B , and the primitive interpretation (A) = (B ) = X 6= ;. Then jT j = ;, and so a TC-BF for this example is given by (A) = (B ) = , (T ) = ;. However, the BF 0 = [B ` (T ) \ (B )] = [B ` ;] is not TC, as the BF 00 = 0[T ` ] w 0 is not consistent. If we examine this counter-example we see that , although totally-consistent, is not the sort of BF that would be generated by starting with a standard BF, and applying the Upward and Downward rules. This suggests that we might retrieve our rules by restricting the `interesting' bounds in some way. This may be done with S-bounds.

 S-bound Functions Given a tree T with primitive interpretation  the bounding function is an S-bound function (on T over ) if it is totally consistent with respect to all smaller primitive interpretations: i.e., if jT j0 0 = jT j0 for all 0 w and all 0 v . The sets returned by an S-bound function are called S-bounds.

23

In other words, we have introduced an arti cial constraint|that the BF must be TC with respect to all smaller interpretations. S-bounds are explored in detail in [4], and so we will only give an overview of their properties here.

Properties of S-bounds  A standard BF is an S-bound function.  S-bounds are preserved by the Upward principle and the Downward principle (including the cases of and : operations).  If 1 and 2 are two S-bound functions over the same tree (and primitive interpretation), then so is 1 2, where ( 1 2)(T ) = 1(T ) \ 2(T ) for all T Given the need for an additional rule if di erences are allowed we might be tempted to always convert a CSG tree into positive form (one with only and  internal nodes) and to just use the rules for TC-BFs. However it is not true that the bounds generated will necessarily be the same in both cases. As an example, consider the tree A (B C ) with initial bounds A, B and C about A, B and C respectively. Using a system in which the u operation is equivalent to \ (as in the Box-BF system) convergence will occur after one Upthen-Down pass, with the bounds about the leaves being A, A \ B and A \ B \ C.However, if we convert to the `equivalent' tree A (:B  C ) before applying the rewrite rules we will obtain a bound of A \ C about C , rather than A \ B \ C. E ectively the conversion to positive form has meant that B can only `export' a bound of , whereas in the original form the bound on B could be exported locally to C .

7.1 Double Bounds

One problem with extending TC-BFs to trees containing di erence operations was that it is impossible to bound the complement of the interpretation of a subtree. However DBFs contain both an outer and an inner bound, and so it seems plausible that meaningful, symmetric rules could be developed. In particular, the `obvious' Upward principle for a is Given a DBF B over a tree T , and an internal node T of the form T = Tl Tr, replace the bound at T by a B0 satisfying B^0 w B^[T ` B^(T ) \ B^(Tl) \ B(Tr)] B0 v B[T ` B(T ) [ B(Tl) [ B^(Tr)] Unfortunately, this rule does not preserve consistency, as shown by a counter-example. Consider T = A B , with (A) = (B ) = X 6= ;, and the DBF B^(A) = B^(B ) = B^(T ) = B(A) = B(T ) = X , B(B ) = ;. Then applying the `rule' above gives B0 with B^0(T ) = X , B0(T ) = , which is not consistent. This counter-example, together with others, has convinced us that it is not possible to combine inner and outer bounds in a consistent manner. Thus, the proper principle at a di erence node is: 24

 Upward Principle for Double-Bounds at Given a DBF B over a tree T , and an internal node T of the form T = Tl Tr , replace the bound at T by a B0 satisfying B^0 w B^[T ` B^(T ) \ B^(Tl)] B0 v B[T ` B(T ) [ B(Tl)] E ectively, we cannot pass any useful information up from the right-hand child of a node.

8 Conclusions We have presented what might seem like a bewildering array of concepts and de nitions concerning various types of bounds. In fact we may organise the concepts along di erent, orthogonal axes. One axis we could label `Generality': as far as our work is concerned standard bounds occupy one end of this axis and consistent bounds occupy the other, with S-bounds and TC-bounds in between. We have concentrated on TC-bounds in this paper as most of the results apply to them, but in practise we start with a standard BF and so generate S-bounds (which are themselves, of course, totally consistent). Another axis could be labelled `Accuracy of Bound': for this, boxes and spheres might be at one end, convex hulls a little further along, and the exact-shapes at the far end. Conversely, we might label the same axis as `Speed of Computation', with a note that we are talking about speed for explicitly computing these bounds (active zones being exact, but computed implicitly). The bound systems are a rich source of algebraic problems. Most of our work has been done on the Box-BF system, as this is computationally very useful and has nice algebraic properties. Unfortunately the other practical systems are much harder to analyse, despite their apparent simplicity. Monotonicity has been shown to be a desirable property, as it guarantees a unique xed point, but we would not suggest that the sphere system is not used simply on the grounds that it is not monotonic! We have not said too much about the applications of these techniques. In our CSG modeller, robmod [6], we use the Box-BF system for all of our geometric computations as a matter of course, as convergence is so rapid that we can ignore the time that it takes. For drawing, volume property calculation, and the like, the advantages of performing these bound computations tend to be small (but measurable); however for interference detection and collision detection the advantages are huge (speedups of an order of magnitude or more are common). This is because there is then an implicit intersection node at the root of the CSG tree, and so the reductions in the size of the bounds tend to be large [4]. Ray-casting could also bene t from the use of TC-bounds, as we can perform a bound analysis between the ray (bounded by a thin box) and the objects. Another way of thinking about the bound systems is as a set of constraints on subexpressions. For example, a standard bound places de nite constraints on the values of x, y and z that are coordinates of points in the set given by the sub-expression. Turning this observation around we can regard the rewrite rules for TC-bounds as the rules of a constraint manipulation system, and use them to solve constraint problems which might 25

not normally be given a geometric signi cance. Indeed, as the de nitions and rewrite rules hold for any Boolean algebra, the rewrite-rules could (in principle) be used to set up TC-bounds for elements in any such algebra. As we stated, this topic has proved to be a rich ground for theoretical results, and there is much work still to be done. In particular, we would like to strengthen the convergence results for the BF systems that show the most practical promise, namely spheres and convex hulls. In the meantime though the general applicability of the Upward and Downward theorems means that we can safely use these bound systems to practical e ect. Another area of interest is in alternative orderings for the application of the rules, and in implementations that make use of multiple BF systems. All in all, there have been a lot of surprises generated by the simple observations with which we started!

Acknowledgement Most of the work of the rst author described in this paper was supported by an SERC studentship at the University of Edinburgh Department of Arti cial Intelligence. The second author was partially supported by NSF grants #CCR-8703458 and #DCR-8401898. Both authors would like to thank Mike Brady for encouragement and for promoting the collaboration that lead to this work.

References [1] G. R. Beacon, J. R. Dodsworth, S. E. Howe, R. G. Oliver, and A. Saia. Boundary evaluation using inner and outer sets: the ISOS method. IEEE Comp. Graphics & Applications, 9(2):39{51, March 1989. [2] J. W. Boyse and J. E. Gilchrist. GMSolid: interactive modeling for design and analysis of solids. IEEE Comp. Graphics & Applications, 2(2):27{40, March 1982. [3] Chris Brown. padl-2: a technical summary. IEEE Comp. Graphics & Applications, 2(2):69{84, March 1982. [4] S. A. Cameron. Ecient intersection tests for objects de ned constructively. Int. J. Robotics Res., 8(1):3{25, February 1989. Similar to Oxford Programming Research Group TM-85. [5] S. A. Cameron. Collision detection by four-dimensional intersection testing. IEEE Trans. Robotics & Automation, 6(3):291{302, June 1990. Similar to Oxford Programming Research Group TM-86. [6] Stephen Cameron and Jon Aylett. robmod: A geometry engine for robotics. In Int. Conf. Robotics & Automation, pages 880{885, Philadelphia, April 1988. [7] Stephen Cameron and Jarek Rossignac. Relationship between S-bounds and active zones in constructive solid geometry. In Theory and Practise of Geometric Modelling, 26

[8] [9] [10] [11] [12]

[13] [14] [15]

pages 369{382, Blaubeuren, October 1988. Springer-Verlag. Also as IBM Research Report RC 14246. A. R. Halbert, S. J. P. Todd, and J. R. Woodwark. Generalizing active zones for set-theoretic solid models. Computer Journal, 32(1), February 1989. Also as IBM UKSC Report 182. U. S. Kohli. An experimental study of null object detection algorithms in E2. PAP Internal Technical Report, May 1981. F. P. Preparata and M. I. Shamos. Computational Geometry: An Introduction. Springer-Verlag, New York, 1985. A. A. G. Requicha and H. B. Voelcker. Solid modeling: A historical summary and contemporary assessment. IEEE Comp. Graphics & Applications, 2(2):9{24, March 1982. J. R. Rossignac and H. B. Voelcker. Active zones in CSG for accelerating boundary evaluation, redundancy elimination, interference detection, and shading algorithms. ACM Trans. Graphics, 8(1):51{87, January 1989. Also as IBM Research Report RC13490, Yorktown Heights, NY, February 1988. R. B. Tilove. Set membership classi cation: A uni ed approach to geometric intersection problems. IEEE Transactions on Computers, 29(10):874{883, October 1980. R. B. Tilove. Expoiting Spatial and Structural Locality in Geometric Modelling. PhD thesis, University of Rochester, October 1981. Available as TM-38, College of Engineering and Applied Science. R. B. Tilove. A null-object detection algorithm for constructive solid geometry. Communications of the ACM, 27(7):684{693, July 1984.

Appendix: Set-Algebraic Results

Proof of the Upward and Downward Theorems for TC-DBFs

Consider the subtree T0 = T1 ? T2, where ? is either  or . For these proofs only we introduce some additional shorthand: let B^n , Bn and In denote B^(Tn), B(Tn), and jTnjB respectively (for an arbitrary B). Also, we de ne an auxiliary function , where n is computed by applying just the appropriate set operation to the results obtained from the child nodes of Tn. Thus we may compute In as (n [ Bn ) \ B^n .

Downward Theorem If B is a TC-DBF, let B0 be formed by application of the exact downward rule about T1, viz: B^0 = B^[T1 ` B^0 \ B^1] B0 = B[T1 ` B0 [ B1] 27

Then, given a DBF B00 with B^00 w B^0 and B00 v B0, de ne the sets A = B^100 [ B^0, B = B^100 [ B^1, C = B100 \ B0, and D = B100 \ B1, so that A  B^0, B  B^1, A \ B = B^100 C  B0, D  B1, C [ D = B100 Now we de ne the two DBFs By, Bz by B^y = B^z[T0 ` A \ B^000] By = B00[T1 ` D] B^z = B^00[T1 ` B ] Bz = By[T0 ` C [ B000] and note that both are TC-DBFs (as B^y w B^, etc.). For an arbitrary DBF B, we note that I0 = f[1 [ B0 [ B1] \ [B^1 [ B0] \ B^0g ? f[I2 [ B0] \ B^0g By comparing this expansion for By, B00 and Bz, we observe

I0y  I000  I0z and as the DBFs are equivalent outside of T0, we get

jT jBy  jT jB00  jT jBz and thus that B00 is consistent, as required.

Note The proof of the Downward Theorem for the case where di erences are allowed

(S-bounds) is far more complex than that given above [4].

Upward Theorem If B is an TC-DBF, let B0 be formed by application of the exact Upward rule about T0, viz:

B0 = B[T0 ` B0 [ (B1 ? B2)] B^0 = B^[T0 ` B^0 \ (B^1 ? B^2)] and consider an arbitrary B00 with B^00 w B^0, B00 v B0. For each case (of ?) we demonstrate a DBF B: which is equal to B00, except on T0, T1 and T2; which is a TC-DBF, by virtue of B^ w B^ and B v B; and for which I0 = I000. We de ne the sets A = B^000 [ B^0 B = B^000 [ B^1 C = B^000 [ B^2 X = B [ C D = B000 \ B0 E = B000 \ B1 F = B000 \ B2 Y = E \ F Then

A  B^0 B  B^1 C  B^2 A \ [B ? C ] = B^000 D  B0 E  B1 F  B2 D [ [E ? F ] = B000

28

Case 1: ? is  We set

B^0 = A B^1 = X \ (B^100 [ E ) B^2 = X \ (B^200 [ F ) B0 = X \ D B1 = B100 [ E B2 = B200 [ F

To show that this is valid, note that I000 = [f[001 [ B100] \ B^100g [ f[002 [ B200] \ B^200g [ D [ E [ F ] \ B^000 = [f[001 [ B100 [ E ] \ [B^100 [ E ]g [ f[002 [ B200 [ F ] \ [B^200 [ F ]g [ D] \ A \ X = [f[001 [ B100 [ E ] \ [B^100 [ E ] \ X g [ f[002 [ B200 [ F ] \ [B^200 [ F ] \ X g [ fD \ X g] \ A = I0 as required

Case 2: ? is

We set

B^0 = A B0 = B \ C \ D

B^1 = B \ (B^100 [ Y ) B1 = B100 [ Y

B^2 = C \ (B^200 [ Y ) B2 = B200 [ Y

To show that this is valid, note that

I000 = f[f[001 [ B100] \ B^100g \ f[002 [ B200] \ B^200g] [ [D [ Y ]g \ B^000 = [f[001 [ B100 [ Y ] \ [B^100 [ Y ] \ [002 [ B200 [ Y ] \ [B^200 [ Y ]g [ D] \ A \ B \ C = f[f[001 [ B100 [ Y ] \ [B^100 [ Y ] \ B g \ f[002 [ B200 [ Y ] \ [B^200 [ Y ] \ C g] [ [D \ B \ C ]g \ A = I0

as required

29