Date post: | 02-Jun-2018 |
Category: |
Documents |
Upload: | holly-williams |
View: | 224 times |
Download: | 0 times |
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 1/51
Collision Detection
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 2/51
Essential Math for G
Collisions
• Up to this point, objects just pass
through each other
• Two parts to handling collisions
Collision detection – uses computational
geometry techniques (useful in other ways,
too Collision response – modifying physical
simulation
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 3/51
Essential Math for G
Computational !eometry
• "lgorithms for sol#ing geometric
problems
• $bject intersections
• $bject pro%imity
• &ath planning
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 4/51
Essential Math for G
Distance Testing
• Useful for computing intersection
between simple objects
• 'g sphere intersection boils down to
point)point distance test
• *ust co#er a few e%amples
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 5/51
Essential Math for G
&oint)&oint Distance
• Compute length of #ector between two
points P 0 and P 1, or
2
10
2
10
2
1010 )()()(),dist( z z y y x x P P −+−+−=
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 6/51
Essential Math for G
+ine)&oint Distance
• +ine defined by point P and #ector v
• rea- #ector w = Q – P into w⊥ and w||
• w|| = (w • v) v
• ||w⊥||2 = ||w||2 – ||w||||2
^
^ ^
v
Q
P
w
w||
w⊥
^
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 7/51
Essential Math for G
+ine)&oint Distance
• .inal formula/
• 0f v isn1t normali2ed/
)ˆ(),ˆ,dist( vwwv
−•=Q P
•−•=vv
v
wwv ),,dist( Q P
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 8/51
Essential Math for G
+ine)+ine Distance
• .rom http://www.geometryalgorithms.com
• 3ector wc perpendicular to u and v or
• Two equations
• Two un-nowns
P 0
u
Q0
v
P ( sc)
Q(t c)
wc0
0
)()(
=•
=•
−=
c
c
ccc t Q s P
wv
wu
w
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 9/51
Essential Math for G
+ine)+ine Distance
.inal equations/
)(
)(
)()()(
)()()(
00
00
20
2
0
QPv
QPu
vv
vu
uu
vQ
uP
−•=
−•=
•=
•=
•=
⋅−−+=
⋅−−+=
e
d c
b
a
bacbd aet Q
baccd be s P
c
c
P0
u
Q0
v
P(sc)
Q(tc)
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 10/51
Essential Math for G
4egment)4egment Distance
• Determine closest point between lines
• 0f lies on both segments, done
• $therwise clamp against nearest
endpoint and recompute
• 4ee references for details
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 11/51
Essential Math for G
ounding $bjects
• Detecting intersections with comple%
objects e%pensi#e
• &ro#ide simple object that surrounds
them to cheaply cull out ob#ious cases
• Use for collision, rendering, pic-ing
• Co#er in increasing order of comple%ity
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 12/51
Essential Math for G
ounding 4phere
• Tightest sphere that surrounds model
• .or each point, compute distance from
center, sa#e ma% for radius
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 13/51
Essential Math for G
ounding 4phere (Cont5d
• 6hat to use for center7
+ocal origin of model
Centroid (a#erage of all points
Center of bounding bo%
• 6ant a good fit to cull as much as
possible
• +inear programming gi#es smallest fit
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 14/51
Essential Math for G
4phere)4phere Collision
• Compute distance d between centers
• 0f d < r 1 + r 2, colliding
• 8ote/ d 2 is not necessarily < r 12 + r 22
want d 2 < (r 1 + r 2)2
d r 1
r 2
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 15/51
Essential Math for G
ounding o%
• Tightest bo% that surrounds model
• Compare points to min9ma% #ertices
• 0f element less9greater, set element in
min9ma%
(min %, min y
(ma% %, ma% y
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 16/51
Essential Math for G
"%is)"ligned ounding o%
• o% edges aligned to world a%es
• :ecalc when object changes orientation
• Collision chec-s are cheaper though
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 17/51
Essential Math for G
"%is)"ligned o%)o%
Collision• Compare % #alues in min,ma% #ertices
• 0f min; < ma%= or min= < ma%;, no
collision (separating plane
• $therwise chec- y and 2 directions
min= ma%= min; ma%;
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 18/51
Essential Math for G
$bject)$riented ounding o%
• o% edges aligned with local object
coordinate system
• >uch tighter, but collision calcs costly
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 19/51
Essential Math for G
$ Collision
• 0dea/ determine if separating plane
between bo%es e%ists
• &roject bo% e%tent onto plane #ector,test against projection btwn centers
•!
"•!a•!
a "
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 20/51
Essential Math for G
$ Collision
• To ensure ma%imum e%tents, ta-e dot
product using only absolute #alues
• Chec- against a%es for both bo%es, plus
cross products of all a%es
• 4ee !ottschal- for more details
|||||| z z y y x x vavava ++
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 21/51
Essential Math for G
Capsule
• Cylinder with hemispheres on ends
• $ne way to compute
Calc bounding bo%
Use long a%is for length
8e%t largest width for radius
r r
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 22/51
Essential Math for G
Capsule
• Compact
$nly store radius, endpoints of line
segment
• $riented shape w9faster test than $
• Test path collision
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 23/51
Essential Math for G
Capsule)Capsule Collision
• ?ey/ swept sphere a%is is line segment
with surrounding radius
• Compute distance between linesegments
• 0f less than r 1 + r 2, collide
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 24/51
Essential Math for G
Ca#eat
• >ath assumes infinite precision
• .loating point is not to be trusted
• &recision worse farther from @
• Use epsilons
• Careful of operation order
• :e)use computed results
• >ore on floating point on website
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 25/51
Essential Math for G
6hich To Use7
• "s many as necessary
• 4tart with cheap tests, mo#e up the list
4phere
4wept 4phere
o%
• >ay not need them all
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 26/51
Essential Math for G
:ecap
• 4phere )) cheap, not a good fit
• "" )) still cheap, but must recalc and
not a tight fit
• 4wept 4phere )) oriented, cheaper than
$ but generally not as good a fit
• $ )) somewhat costly, but a better fit
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 27/51
Essential Math for G
Collision Detection
• 8aA#e/ n2 chec-sB
• Two part process
road phase
• Cull out non)colliding pairs
8arrow phase
• Determine penetration and contact pointsbetween pairs
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 28/51
Essential Math for G
road &hase
• $b#ious steps
$nly chec- each pair once
• .lag object if collisions already chec-ed
$nly chec- mo#ing objects
• Chec- against other mo#ing and static
Chec- rough bounding object first• "" or sphere
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 29/51
Essential Math for G
ierarchical 4ystems
• Can brea- model into hierarchy and
build bounds for each le#el of hierarchy
• .iner le#el of detection
• Test top le#el, cull out lots of lower
le#els
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 30/51
Essential Math for G
ierarchical 4ystems
• Can use scene graph to maintain
bounding information
• &ropagate transforms down to children
• &ropagate bound changes up to root
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 31/51
Essential Math for G
4patial 4ubdi#ision
• rea- world into separate areas
• $nly chec- your area and neighbors
• 4implest/ uniform
4labs
!rid
3o%els
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 32/51
Essential Math for G
4weep and &rune
• 4tore sorted x e%tents of objects
• 4weep from min x to ma% x
• "s object min #alue comes up, ma-e
acti#e, test against acti#e objects
• Can e%tend to more dimensions
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 33/51
Essential Math for G
4patial 4ubdi#ision
• $ther methods/
uadtrees, octrees
4& trees, k d)trees
:oom)portal
• Choice depends on your game type,
rendering engine, memory a#ailable,etc
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 34/51
Essential Math for G
Temporal Coherence
• $bjects nearby generally stay nearby
• Chec- those first
• Can ta-e memory to store information
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 35/51
Essential Math for G
8arrow &hase
• a#e culled object pairs
• 8eed to find
Contact point
8ormal
&enetration (if any
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 36/51
Essential Math for G
Contact :egion
• Two objects interpenetrate, ha#e one
(or more regions
• " bit messy to deal with
• >any try to a#oid interpenetration
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 37/51
Essential Math for G
Contact .eatures
• .aceted objects collide at pair of
contact features
• $nly consider ')' and .)3 pairs
• 0nfinite possibilities for normals for
others
• Can generally con#ert to ')' and .)3
• '%/ 3)3, pic- neighboring face for one
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 38/51
Essential Math for G
Contact .eatures
• .or ')'/
&oint is intersection of edges
8ormal is cross product of edge #ectors
• .or .)3/
&oint is #erte% location
8ormal is face normal
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 39/51
Essential Math for G
Contact &oints
• Can ha#e multiple contact points
'%/ two conca#e objects
• 4tore as part of collision detection
• Collate as part of collision resolution
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 40/51
Essential Math for G
'%ample/ 4pheres
• Difference between centers gi#es
normal n (after you normali2e
• &enetration distance p is
p = (r 1+r 2) # ||c2#c1||
1 2
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 41/51
Essential Math for G
'%ample/ 4pheres
• Collision point/ a#erage of penetration
distance along e%tended normal
• 0f touching, where normal crosses sphere
v = $(c1 + r 1n + c2 # r 2n)^ ^
1
2
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 42/51
Essential Math for G
+in)Canny
• .or con#e% objects
• 'asy to understand, hard to implement
• Closest features generally same from
frame to frame
• Trac- between frames
• >odify by wal-ing along object
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 43/51
Essential Math for G
+in)Canny
• .rame @
• .rame =
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 44/51
Essential Math for G
!*?
• .or Con#e% $bjects
• ard to understand, easy to implement
• .inds point in Configuration 4pace
$bstacle closest to origin Corresponds
to contact point
• 0terati#ely finds points by successi#e
refinement of simplices
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 45/51
Essential Math for G
!*?
• C4$
• 4imple% :efinement
A
B
A-B
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 46/51
Essential Math for G
>issing Collision
• 0f time step is too large for object speed,
two objects may pass right through
each other without being detected(tunneling
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 47/51
Essential Math for G
>issing Collision
• $ne solution/ slice time inter#al
• 4imulate between slices
• 4ame problem, just reduced frequency
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 48/51
Essential Math for G
>issing Collision
• "nother solution/ use swept #olumes
• 0f #olumes collide, may collide in frame• 6ith more wor- can determine time)of)impact
(T$0, if any
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 49/51
Essential Math for G
:ecap
• Collision detection comple%
• Combo of math and computing
• rea- into two phases/ broad and
narrow
• e careful of tunneling
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 50/51
Essential Math for G
:eferences
• &reparata, .ranco & and >ichael 0an 4hamos,
Computational Geometry: An Introduction, 4pringer)
3erlag, 8ew Eor-, =FGH
• $5:our-e, *oseph, Computational Geometry in C ,Cambridge Uni#ersity &ress, 8ew Eor-, =FFI
• 'berly, Da#id , 3D Game Engine Design, >organ
?aufmann, 4an .rancisco, ;@@=
• !ottschal-, 4tephan, >ing +in and Dinesh >anocha,
J$)Tree/ " ierarchical 4tructure for :apid
0nterference Detection,K SIGGRAPH !"#
8/10/2019 Collision Detectionn
http://slidepdf.com/reader/full/collision-detectionn 51/51
:eferences
• 3an den ergen, !ino, Collision Detection in
Interacti$e 3D En$ironments, >organ
?aufmann, 4an .rancisco, ;@@L• 'berly, Da#id , Game P%ysics, >organ
?aufmann, 4an .rancisco, ;@@L
• 'ricson, Christer, Real&'ime Collision
Detection, >organ ?aufmann, 4an .rancisco,;@@I