Professional Documents
Culture Documents
Collision Detection and Response: Philippe Halsman
Collision Detection and Response: Philippe Halsman
Collision Detection
and Response
MIT EECS 6.837 – Durand
MIT EECS 6.837 – Matusik Philippe Halsman: Dali Atomicus 1
This image is in the public domain. Source:Wikimedia Commons.
Collisions
• Detection
• Response
• Overshooting problem
(when we enter the solid)
2
Collision Response for Particles
v N
3
Collision Response for Particles
v N
vt
vn
v=vn+vt
normal component
tangential component
4
Collision Response for Particles
• Tangential velocity vt v N
often unchanged vt
• Normal velocity vn reflects:
vn
v N vnew
• Coefficient of restitution ε ε=1
5
Collisions – Overshooting
• Usually, we detect collision when it is too late:
we are already inside
xi
xi+1
6
Collisions – Overshooting
• Usually, we detect collision when it is too late:
we are already inside
• Solution: Back up
xi
• Compute intersection point backtracking
• Ray-object intersection!
• Compute response there
• Advance for remaining
fractional time step
xi+1
7
Collisions – Overshooting
• Usually, we detect collision when it is too late:
we are already inside
• Solution: Back up
xi
• Compute intersection point backtracking
• Ray-object intersection!
• Compute response there fixing
• Advance for remaining
fractional time step
• Other solution: xi+1
Quick and dirty hack
• Just project back to object closest point
8
Questions?
• Pong: ε =?
• http://www.youtube.com/watch?v=sWY0Q_lMFfw
• http://www.xnet.se/javaTest/jPong/jPong.html
This image is in the public domain. Image courtesy of Chris Rand on Wikimedia Commons. License: CC-BY-SA.
Source:Wikimedia Commons.
This content is excluded from our Creative Commons license. For more info
rmation, see http://ocw.mit.edu/help/faq-fair-use/.
9
Collision Detection in Big Scenes
• Imagine we have n objects. Can we test all pairwise
intersections?
– Quadratic cost O(n2)!
10
Hierarchical Collision Detection
• Use simpler conservative proxies
(e.g. bounding spheres)
11
Bounding Spheres
• Place spheres around objects
• If spheres do not intersect, neither do the objects!
• Sphere-sphere collision test is easy.
12
Sphere-Sphere Collision Test
• Two spheres, centers C1 and C2, radii r1 and r2
• Intersect only if ||C1C2||<r1+r2
C1 r1 r2 C2
13
Hierarchical Collision Test
• Hierarchy of bounding spheres
– Organized in a tree
• Recursive test with early pruning
Root encloses
whole object
© Gareth Bradshaw. All rights reserved. This content is excluded
from our Creative Commons license. For more information, see
http://ocw.mit.edu/help/faq-fair-use/. 14
Examples of Hierarchy
• http://isg.cs.tcd.ie/spheretree/
© Gareth Bradshaw. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
15
Pseudocode (simplistic version)
boolean intersect(node1, node2)
// no overlap? ==> no intersection!
if (!overlap(node1->sphere, node2->sphere)
return false
16
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
node 1
node 2
© Gareth Bradshaw. All rights reserved. This content is excluded Courtesy of Patrick Laug. Used with permission.
from our Creative Commons license. For more information, see
http://ocw.mit.edu/help/faq-fair-use/.
22
Pseudocode (with leaf case)
boolean intersect(node1, node2)
if (!overlap(node1->sphere, node2->sphere)
return false
return false
23
Other Options
• Axis Aligned Bounding Boxes
– “R-Trees”
24
Questions?
• http://www.youtube.com/watch?v=b_cGXtc-nMg
• http://www.youtube.com/watch?v=nFd9BIcpHX4&f
eature=related
• http://www.youtube.com/watch?v=2SXixK7yCGU
25
Hierarchy Construction
• Top down
– Divide and conquer
• Bottom up
– Cluster nearby objects
• Incremental
– Add objects one by one, binary-tree style.
26
Bounding Sphere of a Set of Points
• Trivial given center C
– radius = maxi ||C-Pi||
© Gareth Bradshaw. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
27
Bounding Sphere of a Set of Points
• 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
© Gareth Bradshaw. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
28
Bounding Sphere of a Set of Points
• 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
Questions?
© Gareth Bradshaw. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
29
Top-Down Construction
• Take longest scene dimension
• Cut in two in the middle
– assign each object or triangle to one side
– build sphere around it
© Sara McMains. All rights reserved. This content is excluded
from our Creative Commons license. For more information, © Gareth Bradshaw. All rights reserved. This content is
see http://ocw.mit.edu/help/faq-fair-use/. excluded from our Creative Commons license. For more
information, see http://ocw.mit.edu/help/faq-fair-use/.
Image of the cover of the book, "Real Time Collision Detection," by Christer Ericson has been removed
due to copyright restrictions.
33
The Cloth Collision Problem
• A cloth has many points of contact
• Stays in contact
• Requires
– Efficient collision detection
– Efficient numerical treatment (stability)
Image from Bridson et al.
© ACM. All rights reserved. This content is excluded from our Creative Commons
license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
34
Robust Treatment of Simultaneous Collisions
David Harmon, Etienne Vouga, Rasmus Tamstorf, Eitan Grinspun
35
MIT OpenCourseWare
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.