59
1 1 Static & Dynamic Static & Dynamic Maintenance of Kinematic Maintenance of Kinematic Structures Structures Spheres, Molecules, and Hidden Surface Removal D. Halperin and M-H. Overmars Dynamic Maintenance of Kinematic Structures D. Halperin, J-C. Latombe and R. Motwani Presented by Iftah Gamzu

Static & Dynamic Maintenance of Kinematic Structures

Embed Size (px)

DESCRIPTION

Static & Dynamic Maintenance of Kinematic Structures. Spheres, Molecules, and Hidden Surface Removal D. Halperin and M-H. Overmars Dynamic Maintenance of Kinematic Structures D. Halperin, J-C. Latombe and R. Motwani. Presented by Iftah Gamzu. Agenda. Static case: Hard Sphere Model - PowerPoint PPT Presentation

Citation preview

11

Static & Dynamic Static & Dynamic Maintenance of Kinematic StructuresMaintenance of Kinematic Structures

Spheres, Molecules, and Hidden Surface Removal D. Halperin and M-H. Overmars

Dynamic Maintenance of Kinematic Structures D. Halperin, J-C. Latombe and R. Motwani

Presented by Iftah Gamzu

2

AgendaAgenda Static case:Static case:

Hard Sphere Model Molecules Special Properties Data Structures for Answering Intersection Queries Computing the Boundary of a Molecule

Dynamic case:Dynamic case: Graph Theoretic Definition Abstract Data Structure for Answering Intersection Queries Online Maintenance Case for Path / Trees Offline Maintenance Case

Background for future lecturesBackground for future lectures (if time allows): Hidden Surface Removal (Static Case)

3

Static CaseStatic Case Goal: Goal: devise techniques to represent and manipulate a

static collection of overlapping spheres in .

Motivation: Motivation: molecular biology representation of molecular configurations (e.g. union

boundary of a molecule). manipulation of molecular configurations (e.g.

collision detection).

3R

4

Hard Sphere ModelHard Sphere Model

Each atom in the molecule is represented as a sphere in

Spheres can interpenetrate one another

There are recommended values for:1) Radios of each sphere (e.g. van der Waals radii)2) Distance between centers of each pair of spheres

3R

AcetylAcetyl

5

might have complexity of

Molecule Special PropertiesMolecule Special Properties

Generally, spheres in might be complex combinatorially - arrangement defined by n spheres in

3R

3R 3O( )n

However, molecules have special properties: Atoms centers cannot get too close to one another (repellent forces) Atoms radii range is fairly restricted

6

Main Theorem - DefinitionsMain Theorem - Definitions

min max

1

1

1

Atom Radius: ( min , max )

Atom Center:

Ball (atom): { | ( , ) }

Molecule: { ,... }

is the Euclidean distance function

i ii i

i

i

i i

n

i r r r r

p d p c r

B B

r

c

B

M

d

7

Main TheoremMain Theorem

max

min

~

if , (positive constants) such that

(i)

(ii) { | ( , ) } does not contain any

constant

( )

(i) intersects a number of balls in

(ii) The maximal combinat

orial complexi

i i i j

i

r

r

i B p d p c r c j i

i B M

ty of the

boundary of the union of balls is ( )O n

8

Main Theorem - ProofMain Theorem - Proof

constan(i) intersects a number of balls t in ii B M

max{ | ( , ) 2 }i iB p d p c r r

Every ball in M that intersects must lie completely in B

For each that lies completely inside B, let

are pair-wise interior-disjoint

iB

jB

min{ | ( , ) }2j jp d p c r

j

9

Main Theorem - ProofMain Theorem - Proof

By volume considerations, the total number of balls that are completely contained in B cannot exceed…

3 3

max max3 3

mi i

3

n m n

2162 3

2 2

ir r r

r r

(i) is proved.

10

Main Theorem - ProofMain Theorem - Proof(ii) The maximal combinatorial complexity of the

boundary of the union of balls is ( )O n

Immediately follows from (i) since the number of features involving on the union boundary is bounded by the number of balls intersecting it, which is a constant (O(1)) .

The complexity of the union boundary of M is O(n)

iB

11

Main Theorem - ExampleMain Theorem - Example

max and aver. indicate the maximal and average number of balls intersecting a single ball in each molecule.

12

Intersection QueriesIntersection Queries

Goal: Goal: devise a data structure that can answer intersection queries with either a point or with a ball whose radius is bounded by .

Motivation:Motivation: molecular biology - computer aided drug design. checking whether molecules fit together. checking whether a particular position in lie inside

or outside the molecule.

3R

maxr

13

Intersection Queries – Solution 1Intersection Queries – Solution 1

Store C (the set of centers of the balls in M) in a three dimensional range tree suitable for answering:

Given a query axis-parallel box, report the points in C contained in this box.

Preprocessing:Preprocessing:

14

Intersection Queries – Solution 1Intersection Queries – Solution 1

Given a query ball Q (with radius ), construct a ball Q’ with radius and concentric with Q.

B’ is the axis-parallel bounding box of Q’.

Query the range search structure on C with the box B’.

Qr

maxQr r

Query:Query:

15

Intersection Queries – Solution 1Intersection Queries – Solution 1

For each of the answers, check whether the corresponding ball intersects Q.

Preprocessing Space O(n O(n · · loglog²n)²n)

Preprocessing Time O(n O(n ·· log log²n)²n)

Query Time O(logO(log²n)²n)

Performance:Performance:

16

Intersection Queries – Solution 2Intersection Queries – Solution 2

Subdivide space into cubes whose side is long.

For each ball in M compute the grid cubes that it intersects (at most 8 cubes).

Arrange C (the set of non-empty grid cubes) in a balanced binary search tree and attach to each cube a list (of constant number) of balls in M that intersect it.

max2r

Preprocessing:Preprocessing:

17

Intersection Queries – Solution 2Intersection Queries – Solution 2

Given a query ball Q, compute the grid cubes it intersects (at most 8 cubes).

For each grid cube, find it in the binary search tree and (if it exists) check the balls in its list for intersection with Q.

Preprocessing Space O(nO(n))

Preprocessing Time O(n O(n ·· log logn)n)

Query Time O(logO(logn)n)

Query:Query:

Performance:Performance:

18

Intersection Queries – Solution 3Intersection Queries – Solution 3

Use hash structure instead of the binary search tree.

Preprocessing Space O(nO(n))

Preprocessing Time O(nO(n) randomized.) randomized.

Query Time O(1O(1))

PPerformanceerformance::

19

Intersection Queries – Solution 3Intersection Queries – Solution 3

Testing Results:Testing Results:

density of the molecule is more dominant then the size of the molecule.

20

Computing BoundaryComputing Boundary

Goal: Goal: devise an algorithm to compute the boundary of a

collection of interpenetrating spheres.

Motivation:Motivation: molecular biology

computing van der Waals surface.

computing the approximate solvent accessible surface.

other surfaces…

21

Computing Boundary – cont.Computing Boundary – cont.

The algorithm also solves the problem of computing the approximate solvent accessible surface.

Reduction:

New instance with different constants

( ) on which we need to

compute the union boundary.

' ' ' 'min max, , and r r

Increase the radius of each ball in M by r` (the radius of the solvent sphere).

22

Computing Boundary – SolutionComputing Boundary – Solution

Algorithm Outline:Algorithm Outline:1) For each ball identify the other balls intersecting it.

2) For each ball compute its contribution to the union boundary.

Use the intersection query data structure.

Each pair of intersecting balls (which none contains the other) defines a circle that partitions each ball into two parts. For each ball, calculate all the circles on it (a 2D arrangement on the ball) and decide which faces are on the boundary (using brute force).

23

Computing Boundary – SolutionComputing Boundary – Solution

3) Transform the local information into global structures describing the union boundary.

We start with a face (f) that must be on the boundary (e.g. the face that has the largest z-coordinate on its boundary). Recursively, traverse the neighboring faces (f `) of (f) that haven’t been visited yet.

24

Computing Boundary – SolutionComputing Boundary – Solution

PPerformanceerformance::

Step 1 Step 2 Step 3

Space O(nO(n)) O(nO(n)) O(nO(n))

Time O(nO(n) randomized) randomized

O(n O(n ·· log logn) n) deterministicdeterministic

O(nO(n)) O(nO(n))

Preprocessing time + Queries time

25

Computing Boundary – SolutionComputing Boundary – Solution

Testing Results:Testing Results:

Notice: although steps 1 and 2 theoretically take O(n), step 2 dominates the amount of time required (larger constant).

SOD

26

Dynamic CaseDynamic Case

Goal: Goal: devise a data structure that allows us to answer intersection queries on a moving collection of bodies connected by joints in .

Motivation: Motivation: conformational search in molecular biology. collision detection. simulation of hyper-redundant robots.

3R

27

Dynamic Case – cont.Dynamic Case – cont.

Concept: Concept: Assumption: we know how to solve the problem for the static

case – e.g. if the collection represents a molecule then we can use the previously discussed hash structure.

Goal: we would like to devise a data structure that will maintain a collection of static substructures and will be able to (efficiently) support dynamic operations (e.g. update of the joint parameter).

28

Dynamic Case – cont.Dynamic Case – cont. Example 1:Example 1: for each link there is a substructure (e.g. hash structure

representing a grid occupancy by a link).

1T

2T

(joint parameter) update operation update the coordinate system transformation (O(1)).

query operation each substructure must be queried (O(n)).

29

Dynamic Case – cont.Dynamic Case – cont. Example 2:Example 2: Suppose we knew that the sequence of update and query

operations would have the special feature that all the update operations modify the same joint. What would be a decent strategy ?

30

Graph Theoretic Problem DefinitionGraph Theoretic Problem Definition

Input:Input: L – articulated linkage of n links with no closed loops.

A tree T(V, E) such that

Links map to vertices -

Joints map to edges - joint connecting links i and j

1, 2 1 2,..., { , ,... }n nl l l V v v v

( , )i jv v E

31

Graph Theoretic Problem DefinitionGraph Theoretic Problem Definition

Output:Output: D – a dynamic collection of substructures that supports two operations:

- change joint (edge) parameter to q.

- query some region for intersections.

Notes:Notes: the substructures in D can be viewed as a decomposition of T (into sub-trees) induced by the removal of a set of edges in E (marked as BROKEN). each substructure represents the space occupied by L-elements corresponding to a sub-tree of T.

( , , )i jUPDATE v v q

(...) QUERY

32

Graph Theoretic Problem DefinitionGraph Theoretic Problem Definition

Example:Example:

T is decomposed into 2 sub-trees (i.e. D is made of 2 substructures).

Each sub-tree’s corresponding L-elements are maintained in a substructure that represents the space occupied by them.

33

The Abstract Data StructureThe Abstract Data Structure

Primitive operations:Primitive operations:

- breaks the edge (this results in a partition of the substructure that held into two substructures).

Cost: O(1) if the edge is already BROKEN.

if the edge is MARGED.

- merges the edge (this results in a union of the corresponding substructures).

Cost: O(1) if the edge is already MARGED.

if the edge is BROKEN.

( , )i jBREAK v v

( , )i jMERGE v v

( , )i jv v( , )i jv v

( )ijO n

( , )i jv v

( )ijO n

34

is:

The Abstract Data Structure – cont.The Abstract Data Structure – cont.

( )ijO n

TOTAL cost measure The total number of vertices that participate in the operation.

MIN cost measure The number of vertices in the smaller tree that participates in the operation.

The TOTAL cost measure corresponds to a situation where each operation destroys the old structure(s) and then re-computes new structure(s) from sketch

The MIN cost measure corresponds to a situation where new structure(s) can be re-computed by inserting/deleting of elements.

35

How How QUERY QUERY is performed ?is performed ?For simplicity, assume that T is a serial linkage.

Let denote the static structure that holds the link , be the next static structure along the path and so on. Each static structure has a coordinate frame attached to it in which the links in this structure are described ( has the universal frame).

The Abstract Data Structure – cont.The Abstract Data Structure – cont.

1S

1S 1v 2S

36

The Abstract Data Structure – cont.The Abstract Data Structure – cont. For every pair of successive static structures and we maintain a rigid transformation which transforms points described in the frame of to the frame of .

iS 1iS

iTiS 1iS

Given a query region Q, we query with Q.

The we query with Q’ = (Q)… and so on.1S

2S 1T

37

Initial state:Initial state: BROKEN edges are spaced regularly along the path at intervals of .

Operations:Operations:

- as explained.

- 1. 2. Update the q parameter in it (and the transformation).3. (if not one of the initially BROKEN edges).

Online Case for PathOnline Case for Path

( , )i jBREAK v v

(...)QUERY

( , , )i jUPDATE v v q

n

( , )i jMERGE v v

T

n n n

38

Online Case for Path – cont.Online Case for Path – cont.

Time complexity:Time complexity:

QUERY – O( ) – since there are substructures

UPDATE – O( ) – for the TOTAL and MIN cost measure.

n

n

n

can we do better ? NO

39

Online Case for Path – Lower BoundOnline Case for Path – Lower Bound

Adversary Approach:Adversary Approach:

If the number of BROKEN edges exceeds , it request a query operation (takes ).

Else (the number of BROKEN edges is fewer then ) , then there exists a sub path with more then vertices and the adversary inputs operation which involves breaking the middle most edge in this sub path (takes for both TOTAL and MIN cost measures).

n( )n

nn

( )n

can we gain more strength using randomization? NO

40

Online Case for Trees – MIN costOnline Case for Trees – MIN cost

Example Example (T is a star):

For the TOTAL cost measure, it is impossible to find a small number of edges that will decompose the star into small sub-trees for each operation.

For the MIN cost measure, do not break any edge for each operation.

( )n

(1)O

41

Online Case for Trees – MIN costOnline Case for Trees – MIN cost

Definitions: Definitions:

Heaviness of an edge

Heaviness of a tree

Balance number κ of a tree – the smallest integer κ such that the removal of κ-1 edges decomposes it to κ sub-trees, none of which is κ-heavy.

Note: κ-heavy κ’-heavy κ’ κ

42

Online Case for Trees – MIN costOnline Case for Trees – MIN cost

Assume that there is a tree T with balance number κ:

Initial state:Initial state: the BROKEN edges are the set of (at most κ-1) edges which gives a κ-balanced decomposition.

Operations:Operations: the same as for the path case.

Time complexity:Time complexity: O(κ) per operation.

is this bound tight ? YES

43

Online Case for Trees – MIN cost Online Case for Trees – MIN cost How to find a balanced decomposition of T ?

Principles:Principles:

κ is known – if κ is unknown, a binary search for its value can be performed at the cost of increasing the running time by a factor of O(log(n)).

The algorithm:

Based on DFS, thus takes O(n) time. Invariant: on final return to vertex u, the residual sub-tree rooted at u does not contain any κ-heavy edges.

44

If r (r > 1) of u’s children have in their sub-trees more then κ - 1 vertices then (at least) r - 1 of them must be cut. > κ-1 > κ-1

Must cut one of the edges

If one of u’s children has in its sub-tree more then κ - 1 vertices then the decision whether to cut it depends on the remainder of the sub-tree under u.

> κ-1 κ-1

If this residual sub-tree has > κ-1 vertices it must be cut.

Online Case for Trees – MIN costOnline Case for Trees – MIN cost

If each of the sub-trees rooted at u’s children have at most κ - 1 vertices then the sub-tree rooted at u does not contain any κ-heavy edges. κ-1 κ-1

Can’t be any κ-heavy edges

Can’t be a κ-heavy edge

45

1 1 2

1

r

i=1

, ..., ...

If

E

1:

=1+

let be the greatest integer such that 1

( 2):

Delete 1 o

At fin

Stage

f the edg

a

es

l return to vert

corre

ex

ls

A

s

e

p

r r

u i

s

children v v with values of n n n

n

n n

n

s

u

s

s

1onding to children ,..., such that

the undeleted edge ( ) corresponds to vertex which is either

Unmarked

(If all are marked) choose the one having minimal .

s

k k

k

v v

e v

m

Online Case for Trees – MIN cost Online Case for Trees – MIN cost Decompose Algorithm

46

1 1

r

i=2

1 1

1

1

(s = 1):

=1+

in not then set ( , ), 0

set ,

1 then set , , and .

( , ), set a

St

If

Else

If

Els

age

nd e

B

i

v v

u u u

u

d n

v marked p u v m

p p m m

m d n d n mark u p p m m d

delete u v n d u

. unmarked

Online Case for Trees – MIN cost Online Case for Trees – MIN cost Decompose Algorithm

47

1 1

3

4 1 1

7

1

1

1 1

1

7

1 1

4 1 1

7

1 1 1

4

5

6

1

4

3

33

1

2

d=1d=1

1

r

i=1

1:

=1+

If

u i

n

n n

Tree with balance number 4Tree with balance number 4

1

let be the greatest integer such that 1

( 2):

Delete 1 of the edges corresponding to children

,..., such that the undeleted edge corresponds

to vertex

S

having min

tage A

imal

s

s

k

s n

s

s

v v

v m

.k

1

let be the greatest integer such that 1

( 2):

Delete 1 of the edges corresponding to children

,..., such that the undeleted edge corresponds

to verte

S

x which is unm

tage A

ark

s

s

k

s n

s

s

v v

v

ed.

m=3 / d=1

1 1

r

i=2

1

1

let be the greatest integer such that 1

(s = 1):

=1+

( in ) set ,

( 1) ( , ), set and

Stage B

.

s

i

v v

u

s n

d n

v marked p p m m

m d delete u v n d u unmarked

d=3

r

i=2

1 1

1

let be the greatest integer such that 1

(s = 1):

=1+

( in not ) then set ( , ), 0

( 1) then set , ,

Stage

and

Bs

i

u

u

s n

d n

v marked p u v m

m d n d n mark u

p p

.um m d

Online Case for Trees – MIN cost Online Case for Trees – MIN cost Decompose Algorithm Example

48

Online Case for Trees – MIN costOnline Case for Trees – MIN cost

Conclusion:

Algorithm DFS-Decompose runs in O(n) on an input tree T with n nodes, and for any given integer κ, it returns a κ-balanced decomposition of T if it has balance number κ, and returns failure otherwise.

49

There exist a choice of O( ) vertices to break such that the tree is decomposes into O( ) sub-trees, each of size O( ).

Online Case for Trees – TOTAL costOnline Case for Trees – TOTAL cost

The idea:The idea: “breaking a vertex”

Add another primitive that breaks a vertex: replace a vertex v by two copies of itself and , with an edge between them. each edge incident to v is assigned to one of its copies.

1v 2v

nn n

50

operation between queries and

Offline Case for Path – TOTAL costOffline Case for Path – TOTAL cost

The TOTAL problem is NPC

- ordered sequence of queries. - ordered sequence of vertices in the path. update operations translate into grid points .

1 2, ,..., mq q q

1 2, ,..., nv v v

iq 1iq

1( , , )j jUPDATE v v q

1 2, ,..., ku u u

51

Offline Case for Path – TOTAL costOffline Case for Path – TOTAL cost

Claim: an optimal solution for the problem corresponds to

partitioning R into axis-parallel rectangles such that

is minimized and no rectangle contains a point of U

in its interior.

1 2, ,..., tR R R

1

( )t

i ii

h w

cost of query is the number of rectangles (substructures) in the intersection charge the cost to the portion of the lower horizontal edge.

vertical edges correspond to sub-paths that have undergone a change

charge the cost to the left vertical rectangle edges.

52

Offline Case for Path – TOTAL costOffline Case for Path – TOTAL cost

The specified rectangle partitioning problem is harder than the TOTAL problem approximation algorithms to the rectangle partitioning also approximate the TOTAL problem.

It can be proved that TOTAL problem is harder (reduction in the reverse direction) then the specified rectangle partitioning.

Gonzalez et al – 1.75 approximation in time

Gonzalez et al – 4 approximation in time

5( )O U

( log )O U U

Equivalency between the two problems.

The TOTAL problem is NPC.

53

Offline Case for Path – MIN costOffline Case for Path – MIN cost

The MIN problem is NPC ?

It can be shown that

- approximation algorithm

( ) ( ( ) log( ))TOTAL MINOPT I O OPT I U

(log( ))O U

54

Hidden Surface RemovalHidden Surface Removal

Goal: Goal: devise an algorithm for hidden surface removal among a set of intersecting spheres.

Motivation:Motivation: molecular biology – molecules display.

Reminder:

Static Case

55

Hidden Surface Removal – cont.Hidden Surface Removal – cont.

Algorithms:Algorithms:

Z-buffer algorithm – most implementations only handle polyhedral objects. Thus, we need to approximate the spheres by a triangular meshes large number of faces Slow.

Painter’s Algorithm – define the depth order on the objects (sorting from back to front) and then draws the objects in this order on top of each other what is the depth order between intersecting objects ?

56

Hidden Surface Removal – cont.Hidden Surface Removal – cont.

If the spheres do not intersect ?

The depth order is acquired by sorting the spheres by the z-coordinate of their centers.

And if the spheres intersect ?

Lets look only on pieces of the spheres that

1. constitutes the boundary of the union. And,2. are part of the visible hemisphere.

and try to define a depth order on them…

57

Hidden Surface Removal – cont.Hidden Surface Removal – cont.

- a collection of spheres sorted by z of their centers.

- a hemisphere of facing the viewing direction.

- a collection of maximal pieces that are part of

the boundary of the union of spheres.

Then

is a valid depth order for the pieces of the boundary.

1 2, ,..., nS S S

iH iS1 2, ,..., iji i iH H H

1 21 1 11 1 2 2,..., , ,..., ,...., ,..., njj j

n nH H H H H H

i < jNO

i > j

58

Hidden Surface Removal – cont.Hidden Surface Removal – cont.

Algorithm:

Compute the boundary of the of the union.

Given a viewing direction, cut off the parts that lie outside the viewable hemisphere.

Compute the depth order for the spheres and draw the pieces.

PPerformanceerformance::

O(n·log n) + O(n) + O(n·log n) =

O(n·log n) deterministic

59

Questions…Questions…