Download - Collision Detection
![Page 1: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/1.jpg)
Collision Detection
David Johnson
Cs6360 – Virtual Reality
![Page 2: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/2.jpg)
Basic Problems
• Too many objects
• Discrete Sampling
• Complex Objects
![Page 3: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/3.jpg)
Too Many Objects
• Even if cheap to detect collisions, will have n^2 checks
• http://www.youtube.com/watch?v=OBzBfhrjx5s&feature=related
![Page 4: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/4.jpg)
Tunneling
![Page 5: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/5.jpg)
Tunneling
![Page 6: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/6.jpg)
Tunneling
![Page 7: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/7.jpg)
Tunneling
![Page 8: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/8.jpg)
Complex Objects
• N^2 problem between triangles of individual models
![Page 9: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/9.jpg)
Approaches
• Too many objects– Partition Space– Velocity Bounds
![Page 10: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/10.jpg)
Spatial Partition
• Uniform Grid
![Page 11: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/11.jpg)
Interval Projection• Project bounding volume on each axis
– Maintain sorted lists– Possible collision when intervals overlap
![Page 12: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/12.jpg)
Tunneling
• Fundamentally a sampling problem– If you know the max velocity and minimum
thickness, can bound the error
![Page 13: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/13.jpg)
Tunneling
• Fundamentally a sampling problem– If you know the max velocity and minimum
thickness, can bound the error
![Page 14: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/14.jpg)
Sweep Methods
• Sweep out the volume along the path– Different accuracy
choices
• Test for collisions– False positives– Bisect the interval
• Rotations are tough
![Page 15: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/15.jpg)
Time of collision
• Interval Halving• Conservative
Advancement• Minkowski
Difference/ray-cast
![Page 16: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/16.jpg)
Collision for Complex Models
• Models may have millions of primitives– Not moving independently, so sweep methods
are overkill– Spatial partitions are tough to update– May be in close proximity for extended
periods• Need to avoid false positives
![Page 17: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/17.jpg)
Bounding Volumes
• Objects are often not colliding– Need fast reject for this case– Surround with some bounding
object• Like a sphere
• Why stop with one layer of rejection testing?– Build a bounding volume
hierarchy (BVH)• A tree
![Page 18: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/18.jpg)
Bounding Volume Hierarchies
• Model Hierarchy: – each node has a simple volume that bounds a set
of triangles – children contain volumes that each bound a
different portion of the parent’s triangles – The leaves of the hierarchy usually contain
individual triangles
• A binary bounding volume hierarchy:
![Page 19: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/19.jpg)
BVH-Based Collision Detection
![Page 20: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/20.jpg)
Type of Bounding Volumes• Spheres• Ellipsoids• Axis-Aligned Bounding Boxes (AABB)• Oriented Bounding Boxes (OBBs)• Convex Hulls• k-Discrete Orientation Polytopes (k-dop)• Spherical Shells • Swept-Sphere Volumes (SSVs)
– Point Swept Spheres (PSS)– Line Swept Spheres (LSS)– Rectangle Swept Spheres (RSS)– Triangle Swept Spheres (TSS)
![Page 21: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/21.jpg)
BV Choices
• OBB or AABB– OBB slightly better for close proximity– AABB better for handling deformations
![Page 22: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/22.jpg)
Building an OBBTree
Recursive top-down construction: partition and refit
![Page 23: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/23.jpg)
Given some polygons,consider their vertices...
Building an OBB Tree
![Page 24: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/24.jpg)
… and an arbitrary line
Building an OBB Tree
![Page 25: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/25.jpg)
Project onto the line
Consider variance ofdistribution on the line
Building an OBB Tree
![Page 26: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/26.jpg)
Different line,different variance
Building an OBB Tree
![Page 27: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/27.jpg)
Maximum Variance
Building an OBB Tree
![Page 28: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/28.jpg)
Minimal Variance
Building an OBB Tree
![Page 29: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/29.jpg)
Given by eigenvectorsof covariance matrixof coordinatesof original points
Building an OBB Tree
![Page 30: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/30.jpg)
Choose bounding boxoriented this way
Building an OBB Tree
![Page 31: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/31.jpg)
Good Box
Building an OBB Tree
![Page 32: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/32.jpg)
Add points:worse Box
Building an OBB Tree
![Page 33: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/33.jpg)
More points:terrible box
Building an OBB Tree
![Page 34: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/34.jpg)
Compute with extremal points only
Building an OBB Tree
![Page 35: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/35.jpg)
“Even” distribution: good box
Building an OBB Tree
![Page 36: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/36.jpg)
“Uneven” distribution: bad box
Building an OBB Tree
![Page 37: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/37.jpg)
Fix: Compute facets of convex hull...
Building an OBB Tree
![Page 38: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/38.jpg)
Better: Integrate over facets
Building an OBB Tree
![Page 39: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/39.jpg)
Building an OBB Tree
… and sample them uniformly
![Page 40: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/40.jpg)
Tree Traversal
Disjoint bounding volumes:Disjoint bounding volumes:No possible collisionNo possible collision
![Page 41: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/41.jpg)
Overlapping bounding volumes:Overlapping bounding volumes:• split one box into childrensplit one box into children• test children against other boxtest children against other box
Tree Traversal
![Page 42: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/42.jpg)
Tree Traversal
![Page 43: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/43.jpg)
Tree Traversal
Hierarchy of testsHierarchy of tests
![Page 44: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/44.jpg)
Separating Axis Theorem
L is a separating axis for OBBs A & B, since A & B become disjoint intervals under projection onto L
![Page 45: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/45.jpg)
Separating Axis Theorem
Two polytopes A and B are disjoint iff there
exists a separating axis which is:
perpendicular to a face from either
or
perpendicular to an edge from each
![Page 46: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/46.jpg)
Implications of Theorem
Given two generic polytopes, each with E edges and F faces, number of candidate axes to test is:
2F + E2
OBBs have only E = 3 distinct edge directions, and only F = 3 distinct face normals. OBBs need at most 15 axis tests.
Because edge directions and normals each form orthogonal frames, the axis tests are rather simple.
![Page 47: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/47.jpg)
OBB Overlap Test: An Axis Test
sha
bas h h+>L is a separating axis iff:
L
hb
![Page 48: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/48.jpg)
OBB Overlap Test: Axis Test Details
Box centers project to interval midpoints, so
midpoint separation is length of vector T’s image.
A
B
nTAT
BT
s
nTT BAs
![Page 49: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/49.jpg)
OBB Overlap Test: Axis Test Details
• Half-length of interval is sum of box axis images.
n
B
rB
nRnRnR BBBB bbbr 332211
![Page 50: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/50.jpg)
OBB Overlap Test
• Strengths of this overlap test:– 89 to 252 arithmetic operations per box overlap
test– Simple guard against arithmetic error– No special cases for parallel/coincident faces,
edges, or vertices– No special cases for degenerate boxes– No conditioning problems– Good candidate for micro-coding
![Page 51: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/51.jpg)
OBB Overlap Tests: Comparison
Benchmarks performed on SGI Max Impact,
250 MHz MIPS R4400 CPU, MIPS R4000 FPU
Test Method Speed(us)
Separating Axis 6.26GJK 66.30LP 217.00
![Page 52: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/52.jpg)
OBBs asymptotically outperform AABBs and spheres
Log-log plot
10-4 10-3 10-2 10-1 100 1012 3 4 5 6 7 2 3 4 5 6 7 2 3 4 5 6 7 2 3 4 5 6 7 2 3 4 5 6 7
101
102
103
104
105
106
2346
235
2346
235
235
23
Gap Size ()
Num
ber
of B
V te
sts
Parallel Close Proximity: Experiment
![Page 53: Collision Detection](https://reader035.vdocuments.us/reader035/viewer/2022062222/5681544a550346895dc25f1e/html5/thumbnails/53.jpg)
Implementation: RAPID
• Available at: http://www.cs.unc.edu/~geom/OBB
• Part of V-COLLIDE: http://www.cs.unc.edu/~geom/V_COLLIDE
• Thousands of users have ftp’ed the code
• Used for virtual prototyping, dynamic simulation, robotics & computer animation