Outline
- Bounding Objects and Minimax Tests
- Surrounding Tests
Introduction
- On Tuesday, we were talking about converting between CSG reps and B-reps
- We then talked about how to compute intersection of a line and a plane.
- This latter was a start at looking at a basic toolkit for geometric modeling.
- Today, we will continue to develop this toolkit
- We will start by looking at bounding objects and minimax tests.
Bounding Objects
- We are interested in quickly determining if two objects intersect. We gave some reasons why this was important last day.
- If the two objects are complicated this might be computationally intensive.
- One trick is to surround each object with a simple bounding object and to check for the intersection of the bounding objects.
Only if the bounding objects intersect, do we do any more complicated intersection testing.
Definition. A bounding object for an object `A` is any object `B` that contains `A`.
- We will typically be interested in bounding boxes:
Definition. A box in `\mathbb{R}^n` is any subset of the form
`[a_1, b_1]\times[a_2, b_2]\times \cdots\times [a_n, b_n],`
where `a_i, b_i \in \mathbb{R}`. Here `[a_i, b_i]` are segments rather than intervals. i.e., we allow `b_i < a_i`.
Bounding Box Intersection
- It is easy to check the intersection of bounding boxes:
Theorem. The boxes
`X = [a_1, b_1]\times[a_2, b_2]\times \cdots\times [a_n, b_n]` and `Y = [c_1, d_1]\times[c_2, d_2]\times \cdots\times [c_n, d_n]`
will intersect iff
`lb_i = \max(\min(a_i, b_i), \min(c_i, d_i)) \leq ub_i = \min(\max(a_i, b_i), \max(c_i, d_i))`
for all `i`. If they intersect, then
`X \cap Y = [lb_1, ub_1]\times[lb_2, ub_2]\times \cdots\times [lb_n, ub_n]`.
- Because we take min's and max's in the above calculation, the above test is called a minimax test.
Generalizing Bounding Boxes
- One way to generalize the notion of a bounding box is to allow bounding faces to be slanted and not just horizontal or vertical.
Definition. A slab in `\mathbb{R}^n` is the region between two parallel hyperplanes.
- Given a bounded set `X` (i.e., any set that lives in some finite radius ball in `\mathbb{R}^n`), a unit vector `\vec n`
determines a slab as follows: Starting arbitrarily far out on the two ends of the line through the origin with direction vector `\vec n`, slide two hyperplanes orthogonal to `\vec n` towards the origin until they touch `X`.
- We will call this slab the slab for X induced by the unit vector `\vec n` and denote it `Slab(X, \vec n)`.
- The equations of the two hyperplanes will be `\vec n \cdot \vec p = d^(n\ear)` and `\vec n \cdot \vec p = d^(far)` where
`d^(n\ear) \leq d^(far)`. We denote the former hyperplane the near hyperplane and the later the far hyperplane.
Definition. The generalized bounding box for `X` determined by a fixed set `\vec n_1,\vec n_2, \ldots, \vec n_k` of unit normal vectors is the intersection of the slabs they determine. i.e.,
`B(X, \vec n_1,\vec n_2, \ldots, \vec n_k) = \cap_{i=1}^k Slab(X, \vec n_i).`
Example Slab
Determining Generalized Bounding Boxes
- For some types of objects finding a generalized bounding boxes is still straightforward:
- Bounded, Linear Polyhedra (a union of finitely many bounded, linear, convex polyhedra where a bounded, linear, convex polyhedra is a bounded, finite intersection of hyperplane halfspaces). In this case, we project all of the polyhedra's vertices `\vec p_j` onto the `\vec n_i` and use the minimum and maximum of those values. That is,
`d_i^(n\ear) = \min_j(\vec n_i \cdot \vec p_j)` and `d_i^(far) = \max_j(\vec n_i \cdot \vec p_j)`
- Implicitly Defined Surfaces. Suppose `S` is defined by an equation `f(x,y,z) = 0`. The `d_i^(n\ear)` and
`d_i^(far)` will be the minimum and maximum, respectively of the linear function `g(x,y,z) = \vec n_i\cdot(x,y,z)` subject to the constraint of being on the surface. This minimum and maximum can be found using Lagrange multipliers.
- Compound Objects. Assume that the object is defined by successive application of the regular set operations starting from primitive objects of the above two types. The `d_i^(n\ear)` and
`d_i^(far)` can be computed in terms of the `d_i^(n\ear)` and
`d_i^(far)` of the primitives that define it. For example, to get the `d_i^(n\ear)` and
`d_i^(far)` of the union of two objects `X` and `Y`, one takes the minimum of the `d_i^(n\ear)`'s and the maximum of
the `d_i^(far)`'s.
Determining Intersection of Generalized Bounding Boxes
- Suppose one has two generalized bounding boxes `B_1` and `B_2` each of which is defined with respect to the same
set of normal vectors.
- To determine if their intersect `B` we calculate minima of `d_i^(n\ear)`'s and maxima of the `d_i^(far)`'s:
`d_i^(n\ear)(B) = \max(d_i^(n\ear)(B_1), d_i^(n\ear)(B_2))` and `d_i^(far)(B) = \min(d_i^(far)(B_1), d_i^(far)(B_2))`
- The generalized boxes `B_1` and `B_2` are disjoint iff `d_i^(far)(B) < d_i^(n\ear)(B)` for some `i`.
Surrounding Tests
- Another common task that we often need to do in geometric modeling is to determine if a point is inside a surface.
- This task is called a surrounding test.
- There are two main types of surrounding tests we will look at: those of convex polyhedra and those of arbitrary polyhedra.
The Normal Test
- We begin by considering the case of convex polyhedra.
- We defined bounded, linear convex polyhedra earlier. A convex polyhedra (as a surface) `Q` is the intersection of a collection of halfplanes. These give the faces of `Q`. Each face `i` can be defined via a point `\vec q_i` on the face and a normal `\vec n_i`.
- A point `\vec p` will belong to `Q` iff `(\vec p - \vec q_i)\cdot \vec n_i \geq 0` for all `i`.
- This is called the normal test.
The Normal Test Example
- As an example, the square `[0,4]\times[0,4]` can be defined via
`\vec n_0 = (0,1), \vec n_1 = (-1,0), \vec n_2 = (0,-1), and \vec n_3 = (1,0)`,
`\vec q_0 = (0,0), \vec q_1 = (4,0), \vec q_2 = (4,4), and \vec q_3 = (0,4)`.
The four normal tests for a point `\vec p = (x,y)` amount to checking:
`(\vec p - \vec q_0)\cdot \vec n_0 \geq 0` that is `y\geq 0`
`(\vec p - \vec q_1)\cdot \vec n_1 \geq 0` that is `x\leq 4`
`(\vec p - \vec q_2)\cdot \vec n_2 \geq 0` that is `y\leq 4`
`(\vec p - \vec q_3)\cdot \vec n_3 \geq 0` that is `x\geq 0`
The Equation Test
- Sometimes it is more convenient to store planes, lines, etc. via equations of the form `a_1x_1 + a_2x_2 + \cdots + a_nx_n =0`, rather than use a normal and a point on the object.
- If this is the case, then we can modify the normal test to get the so-called equation test.
- In 2D, we notice `\vec n_i = (a_i, b_i)` and `c_i = - \vec q_i\cdot \vec n_i`.
- So `\vec p = (x,y)` will belong to the polygon iff
`a_i x + b_iy +c_i \geq 0`
for all `i`.