implicit integration collision detection

101
CS-C3100 Fall 2018 – Lehtinen 1 CS-C3100 Computer Graphics Jaakko Lehtinen Implicit Integration Collision Detection Philippe Halsman: Dali Atomicus Good pointers to extra credit in Assignment 4)

Upload: others

Post on 23-Oct-2021

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 1

CS-C3100 Computer Graphics Jaakko Lehtinen

Implicit Integration Collision Detection

Philippe Halsman: Dali Atomicus

Good pointers to extra credit in Assignment 4)

Page 2: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

In These Slides

2

• Implicit Integration • Collision detection and response

– Point-object and object-object detection – Only point-object response

Page 3: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

ODE: Path Through a Vector Field

3

• X(t): path in multidimensional phase space

• f = d/dt X is a vector that sits at each point in phase space, pointing the direction.

“When we are at state X at time t, where will X be after an infinitely small time interval dt ?”

ddt

X = f(X, t)

Page 4: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit integration

4

• So far, we have seen explicit Euler – X(t+h) = X(t) + h X’(t)

• We also saw midpoint and trapezoid methods – They took small Euler steps, re-evaluated X’ there, and

used some combination of these to step away from the original X(t).

– Yields higher accuracy, but not impervious to stiffness

Page 5: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit integration

5

• So far, we have seen explicit Euler – X(t+h) = X(t) + h X’(t)

• Implicit Euler uses the derivative at the destination! – X(t+h) = X(t) + h X’(t+h) – It’s implicit because we don’t have X’(t+h),

it depends on where we go

Page 6: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit integration

5

• So far, we have seen explicit Euler – X(t+h) = X(t) + h X’(t)

• Implicit Euler uses the derivative at the destination! – X(t+h) = X(t) + h X’(t+h) – It’s implicit because we don’t have X’(t+h),

it depends on where we go

Page 7: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit integration

6

• So far, we have seen explicit Euler – X(t+h) = X(t) + h X’(t)

• Implicit Euler uses the derivative at the destination! – X(t+h) = X(t) + h X’(t+h) – It’s implicit because we don’t have X’(t+h),

it depends on where we go (HUH?) – Two situations

• X’ is known analytically and everything is closed form (doesn’t happen in practice)

• We need some form of iterative non-linear solver.

Page 8: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 7

• Remember our model problem: x’ = -kx – Exact solution was a decaying exponential x0 e-kt

• Explicit Euler: x(t+h) = (1-hk) x(t) – Here we got the bounds on h to avoid oscillation/explosion

Simple Closed Form Case

Page 9: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 8

• Remember our model problem: x’ = -kx – Exact solution was a decaying exponential x0 e-kt

• Explicit Euler: x(t+h) = (1-hk) x(t)

• Implicit Euler: x(t+h) = x(t) + h x’(t+h)

Simple Closed Form Case

Page 10: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 9

• Remember our model problem: x’ = -kx – Exact solution was a decaying exponential x0 e-kt

• Explicit Euler: x(t+h) = (1-hk) x(t)

• Implicit Euler: x(t+h) = x(t) + h x’(t+h) x(t+h) = x(t) - hk x(t+h) = x(t) / (1+hk) – It’s a hyperbola!

Simple Closed Form Case

Page 11: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 10

• Remember our model problem: x’ = -kx – Exact solution was a decaying exponential x0 e-kt

• Explicit Euler: x(t+h) = (1-hk) x(t)

• Implicit Euler: x(t+h) = x(t) + h x’(t+h) x(t+h) = x(t) - h k x(t+h) = x(t) / (1+hk) – It’s a hyperbola!

Implicit Euler is unconditionally stable!

1/(1+hk) < 1, when h,k > 0

Simple Closed Form Case

Page 12: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit vs. Explicit

From the siggraph PBM notes11

Page 13: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler, Visually

12

Xi Xi+1

Xi+1 = Xi + h f( Xi+1, t+h ) Xi+1 - h f( Xi+1, t+h ) = Xi

Page 14: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler, Visually

13

Xi Xi+1

-hf(X,t)

Xi+1 = Xi + h f( Xi+1, t+h ) Xi+1 - h f( Xi+1, t+h ) = Xi

What is the location Xi+1=X(t+h) such that the derivative there, multiplied by -h, points back to Xi=X(t) where we are starting from?

Page 15: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler and Large Systems

14

• To simplify, consider only time-invariant systems – This means X’ = f(X,t) = f(X) is independent of t – Our spring equations satisfy this already

• Implicit Euler with N-D phase space: Xi+1 = Xi + h f( Xi+1 )

Page 16: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler and Large Systems

15

• To simplify, consider only time-invariant systems – This means X’ = f(X,t) = f(X) is independent of t – Our spring equations satisfy this already

• Implicit Euler with N-D phase space: Xi+1 = Xi + h f( Xi+1 )

• Non-linear equation, unknown Xi+1 on both the LHS and the RHS – Do you know methods for solving such equations?

Page 17: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton’s Method (1D)

16

• Iterative method for solving non-linear equations

• Start from initial guess x0, then iterate

F (x) = 0

Page 18: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton, Visually

17

We are heref(x)

Wik

iped

ia u

sers

Ole

gale

xand

rov,

Pbr

oks1

3

Page 19: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton, Visually

18

We are here

Let’s approximate f by its tangent at point (xn, f(xn))

f(x)

Wik

iped

ia u

sers

Ole

gale

xand

rov,

Pbr

oks1

3

Page 20: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton, Visually

19

We are here

Let’s approximate f by its tangent at point (xn, f(xn))

Then we’ll see where the tangent line crosses zero and take that as

next guess

f(x)

Wik

iped

ia u

sers

Ole

gale

xand

rov,

Pbr

oks1

3

Page 21: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton, Visually

20

f(x)

Wik

iped

ia u

sers

Ole

gale

xand

rov,

Pbr

oks1

3

Repeat

xn+2

Page 22: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton’s Method (1D)

21

• Iterative method for solving non-linear equations

• Start from initial guess x0, then iterate

• Also called Newton-Raphson iteration

F (x) = 0

xi+1 = xi �f(xi)f �(xi)

Page 23: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton’s Method (1D)

22

• Iterative method for solving non-linear equations

• Start from initial guess x0, then iterate

F (x) = 0

xi+1 = xi �f(xi)f �(xi)

one step

⇥ f �(xi)(xi+1 � xi) = �f(xi)

Page 24: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton’s Method – N Dimensions

23

• 1D:

• Now locations Xi, Xi+1 and F live in N-D phase space • N-D Newton step is just like 1D:

NxN Jacobian matrix

replaces f’

JF (Xi)(Xi+1 �Xi) = �F (Xi)unknown N-D

step from current to next

guess

⇥ f �(xi)(xi+1 � xi) = �f(xi)

Page 25: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Newton’s Method – N Dimensions

24

• Now locations Xi, Xi+1 and F are N-D • Newton solution of F(Xi+1) = 0 is just like 1D:

• Must solve a linear system at each step of Newton iteration – Note that also Jacobian changes for each step

NxN Jacobian matrix

JF (Xi)(Xi+1 �Xi) = �F (Xi)

JF (Xi) =�

�F

�X

Xi

unknown N-D step from

current to next guess

Page 26: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Questions?

25

Page 27: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler – N Dimensions

26

• Implicit Euler with N-D phase space: Xi+1 = Xi + h f( Xi+1 )

• Let’s rewrite this as withF (Y ) = 0,

F (Y ) = Y �Xi � hf(Y )

Page 28: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler – N Dimensions

27

• Implicit Euler with N-D phase space: Xi+1 = Xi + h f( Xi+1 )

• Let’s rewrite this as with

• Then the Y that solves F(Y)=0 is Xi+1

F (Y ) = 0,

F (Y ) = Y �Xi � hf(Y )

Page 29: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 28

• Then iterate until F(Y)=0: – Initial guess (or result of explicit method)

– For each step, solve

– Then set

Y 0 = Xi

JF (Y i)�Y = �F (Y i)

Y is variable Xi is fixed

Y i+1 = Y i + �Y

F (Y ) = Y �Xi � hf(Y )

Implicit Euler – N Dimensions

Page 30: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

What is the Jacobian?

29

• Simple partial differentiation...

• Where

F (Y ) = Y �Xi � hf(Y )

JF (Y ) =�

�F

�Y

⇥= I � hJf (Y )

Jf (Y ) =�

�f

�Y

⇥The Jacobian of

the derivative (force) function f

Page 31: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Putting It All Together

30

• Iterate until convergence

– Initial guess (or result of explicit method)

– For each step, solve

– Then set

�I � Jf (Y i)

⇥�Y = �F (Y i)

Y 0 = Xi

Y i+1 = Y i + �Y

Page 32: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Page 33: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1

Page 34: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1-hf(X,t)

Page 35: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1

Page 36: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1Y2

Page 37: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1Y2

-hf(X,t)

Page 38: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1Y2

Page 39: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1Y2

Y3

Page 40: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1Y2

Y3

-hf(X,t)

Page 41: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1Y2

Y3

Page 42: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

31

Xi=Y0

Y1Y2

Y3Y=Xi+1

Page 43: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler with Newton, Visually

32

Xi=Y0

-hf(X,t)

What is the location Xi+1=X(t+h) such that the derivative there, multiplied by -h, points back to Xi=X(t) where we are starting from?

Y=Xi+1

Page 44: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

One-Step Cheat

33

• Often, the 1st Newton step may suffice – People often implement Implicit Euler using only one step. – This amounts to solving the system

where the Jacobian and f are evaluated at Xi, and we are using Xi as an initial guess.

�I � h

�f

�X

⇥�X = hf(X)

Page 45: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Questions?

34

Page 46: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Good News

35

• The Jacobian matrix Jf is usually sparse – Only few non-zero entries per row

�I � Jf (Y i)

⇥�Y = �F (Y i)

Page 47: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Good News

36

• The Jacobian matrix Jf is usually sparse – Only few non-zero entries per row – E.g. the derivative of a spring force only depends on the

adjacent masses’ positions • Makes the system cheaper to solve

– Don’t invert the Jacobian! – Use iterative matrix solvers like

conjugate gradient, perhaps with preconditioning, etc.

�I � Jf (Y i)

⇥�Y = �F (Y i)

Page 48: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler Pros & Cons

37

Page 49: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler Pros & Cons

37

• Pro: Stability!

Page 50: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler Pros & Cons

37

• Pro: Stability!

• Cons: – Need to solve a linear system at each step – Stability comes at the cost of “numerical viscosity”, but

then again, you don’t have to worry about explosions. • Recall exp vs. hyperbola

Page 51: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Implicit Euler Pros & Cons

37

• Pro: Stability!

• Cons: – Need to solve a linear system at each step – Stability comes at the cost of “numerical viscosity”, but

then again, you don’t have to worry about explosions. • Recall exp vs. hyperbola

• Note that accuracy is not improved – error still O(h) – There are lots and lots of implicit methods out there!

Page 53: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Example

39Dongsoo Han

Page 54: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Questions?

40

Page 55: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collisions for Particles

41

• Detection • Response • Overshooting problem

(when we enter the solid)

Page 56: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Examples

42

Page 57: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Detecting Collisions

43

• Easy with implicit equations of surfaces: H(x,y,z) = 0 on the surface H(x,y,z) < 0 inside surface

• So just compute H and you know that you’re inside if it’s negative

• More complex with other surface definitions like meshes – A mesh is not necessarily even closed, what is inside?

Page 58: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collision Response for ParticlesNv

44

Page 59: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collision Response for ParticlesNv

45

vn

vt

v=vn+vt

normal component tangential component

Page 60: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collision Response for ParticlesNv

46

• Tangential velocity vt often unchanged

• Normal velocity vn reflects:

• Coefficient of restitution ε

• When ε = 1, mirror reflection

vn

vt

Nv vnew

Nv vnew

ε=1

ε<1

Page 61: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collisions – Overshooting

47

• Usually, we detect collision when it’s too late: we’re already inside

• Your ODE integrator just evaluates forces, doesn’t know about surfaces!

xi

xi+1

Page 62: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collisions – Overshooting

backtracking

48

• Usually, we detect collision when it’s too late: we’re already inside

• Solution: Back up • Compute intersection point • Ray-object intersection! • Compute response there • Advance for remaining

fractional time step

xi

xi+1

Page 63: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collisions – Overshooting

fixing

backtracking

49

• Usually, we detect collision when it’s too late: we’re already inside

• Solution: Back up • Compute intersection point • Ray-object intersection! • Compute response there • Advance for remaining

fractional time step

• Other solution: Quick and dirty fixup

• Just project back to object closest point

xi

xi+1

Page 64: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Questions?

http://en.wikipedia.org/wiki/Pong

50

• Pong: ε =1 • http://www.youtube.com/watch?v=sWY0Q_lMFfw • http://www.xnet.se/javaTest/jPong/jPong.html

Page 65: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Collision Detection in Big Scenes

51

• Imagine we have n objects. Can we test all pairwise intersections? – Quadratic cost O(n2)!

• Simple optimization: separate static objects – But still O(static × dynamic+ dynamic2)

• Can you think of ways of being smarter?

Page 66: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Hierarchical Collision Detection

52

• Use simpler conservative proxies (e.g. bounding spheres)

• Recursive (hierarchical) test – Spend time only for parts of the scene that are close

• Many different versions, we’ll cover only one

• (Remember hierarchical N-body systems from two lectures ago?)

Page 67: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Bounding Spheres

53

• Place spheres around objects • If spheres don’t intersect, neither do the objects! • Sphere-sphere collision test is easy.

Page 68: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Sphere-Sphere Collision Test

C1 C2r1 r2

54

• Two spheres, centers C1 and C2, radii r1 and r2 • Intersect only if ||C1-C2||<r1+r2

Page 69: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Hierarchical Collision Test

55

• Hierarchy of bounding spheres – Organized in a tree

• Recursive test with early pruning

Root encloses whole object

....

....

Page 70: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Examples of Hierarchy

56

• http://isg.cs.tcd.ie/spheretree/

Page 71: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Pseudocode (simplistic version)

57

boolean intersect(node1, node2) // no overlap? ==> no intersection!

if (!overlap(node1->sphere, node2->sphere)

return false // recurse down the larger of the two nodes

if (node1->radius()>node2->radius())

for each child c of node1

if intersect(c, node2) return true

else

for each child c f node2

if intersect(c, node1) return true

// no intersection in the subtrees? ==> no intersection!

return false

Page 72: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

node 1

node 2

58

boolean intersect(node1, node2)

if (!overlap(node1->sphere, node2->sphere)

return false

if (node1->radius()>node2->radius())

for each child c of node1

if intersect(c, node2) return true

else

for each child c f node2

if intersect(c, node1) return true

return false

Page 73: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 59

boolean intersect(node1, node2)

if (!overlap(node1->sphere, node2->sphere)

return false

if (node1->radius()>node2->radius())

for each child c of node1

if intersect(c, node2) return true

else

for each child c f node2

if intersect(c, node1) return true

return false

72

Page 74: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 60

boolean intersect(node1, node2)

if (!overlap(node1->sphere, node2->sphere)

return false

if (node1->radius()>node2->radius())

for each child c of node1

if intersect(c, node2) return true

else

for each child c f node2

if intersect(c, node1) return true

return false

72

Page 75: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 61

boolean intersect(node1, node2)

if (!overlap(node1->sphere, node2->sphere)

return false

if (node1->radius()>node2->radius())

for each child c of node1

if intersect(c, node2) return true

else

for each child c f node2

if intersect(c, node1) return true

return false

72X

Page 76: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

boolean intersect(node1, node2)

if (!overlap(node1->sphere, node2->sphere)

return false

if (node1->radius()>node2->radius())

for each child c of node1

if intersect(c, node2) return true

else

for each child c f node2

if intersect(c, node1) return true

return false

Page 77: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen 63

boolean intersect(node1, node2)

if (!overlap(node1->sphere, node2->sphere)

return false

if (node1->radius()>node2->radius())

for each child c of node1

if intersect(c, node2) return true

else

for each child c f node2

if intersect(c, node1) return true

return false

Page 78: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Pseudocode (with leaf case)

64

boolean intersect(node1, node2)

if (!overlap(node1->sphere, node2->sphere)

return false

// if there is nowhere to go, test everything

if (node1->isLeaf() && node2->isLeaf())

perform full test between all primitives within nodes // otherwise go down the tree in the non-leaf path

if ( !node2->isLeaf() && !node1->isLeaf() )

// pick the larger node to subdivide, then recurse

else

// recurse down the node that is not a leaf

return false

Page 79: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Other Options

65

• Axis Aligned Bounding Boxes – “R-Trees”

• Oriented bounding boxes – S. Gottschalk, M. Lin, and D. Manocha. “OBBTree: A hierarchical Structure for

rapid interference detection,” Proc. Siggraph 96. ACM Press, 1996

• Binary space partitioning trees; kd-trees

Page 80: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Questions?

66

• http://www.youtube.com/watch?v=nFd9BIcpHX4&feature=related

Page 81: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Deformable Objects

67

• When the objects deform, things get more complex, but modern methods are pretty good with those as well – Barbic, James Subspace Self-Collision Culling,

SIGGRAPH 2010

Page 82: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Hierarchy construction

68

• Top down – Divide and conquer

• Bottom up – Cluster nearby objects

• Incremental – Add objects one by one, binary-tree style.

Page 83: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Bounding sphere of a set of points

69

• Trivial given center C – radius = maxi ||C-Pi||

C

Page 84: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Bounding sphere of a set of points

70

• Using axis-aligned bounding box – center=

((xmin+xmax)/2, (ymin+ymax)/2, (zmin, zmax)/2) – Better than the average of the vertices because does not

suffer from non-uniform tessellation

Page 85: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Optimal Bounding Sphere?

71

• Using the centroid of the vertices for the center C is not necessarily optimal.

• Optimal construction is difficult • Other approximations exist.

– We’ll leave it at that.

C

Page 86: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Questions?

72

Page 87: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction

73

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere around it

Page 88: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction

73

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere around it

Page 89: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction

73

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere around it

Page 90: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction

73

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere around it

Page 91: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction - Recurse

74

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere/box around it

Page 92: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction - Recurse

74

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere/box around it

Page 93: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction - Recurse

74

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere/box around it

Page 94: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction - Recurse

74

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere/box around it

Page 95: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Top-Down Construction - Recurse

74

• Take longest scene dimension • Cut in two in the middle

– assign each object or triangle to one side – build sphere/box around it

Page 96: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Questions?

75

Page 97: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Reference

76

Page 98: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

The cloth collision problem

Image from Bridson et al.

77

• A cloth has many points of contact • Stays in contact • Requires

– Efficient collision detection – Efficient numerical treatment (stability)

Page 99: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Robust Treatment of Simultaneous Collisions David Harmon, Etienne Vouga, Rasmus Tamstorf, Eitan Grinspun

78

Page 100: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

Robust Treatment of Simultaneous Collisions David Harmon, Etienne Vouga, Rasmus Tamstorf, Eitan Grinspun

78

Page 101: Implicit Integration Collision Detection

CS-C3100 Fall 2018 – Lehtinen

That’s All for Today!

79

• ... and for simulation and modeling, for that matter • Next we’ll start to work our way into rendering! • But before that, good luck in your midterm!

Bun

gie

/ ign

.com