Collision Detection nd Bouncing Mike Biley mjb@cs.oregonstte.edu collision-bouncing.pptx
Collisions re Hndled in Two Prts 1. Detecting the collision 2. Hndling the physics of the collision
If You re Lucky, You Cn Detect the Collision Directly (i.e., s closed-form solution) We need to nswer the question: Wht will cuse the bll to stop flying freely through the ir? XLEFT (x,y) (vx,vy) XRIGHT The nswer is it will hit wll or the floor. From our rules of physics, the next bounce will hppen t one of the solutions to these equtions: XRIGHT RADIUS x v x t XLEFT RADIUS x v x t 1 YBOTTOM RADIUS y vyt gt 2 2 YBOTTOM Note: g < 0.
If You re Lucky, You Cn Compute the Collision Directly The next bounce will hppen t one of the solutions to these equtions: XRIGHT RADIUS x v x t t 1 XRIGHT RADIUS x v x XLEFT RADIUS x v x t t 2 XLEFT RADIUS x v x 1 YBOTTOM RADIUS y vyt gt 2 2 1 2 ( ) 0 2 gt vyt y YBOTTOM RADIUS t, t 3 4 2 y y v v 2 g( y YBOTTOM RADIUS) g How do you know which of the 4 t vlues is the one tht you should use?
In the Generl Cse, there re Two Types of Collision Detection 1. Discrete A B 2. Continuous A B A
Detecting Collisions Between Two Objects 1. Do s mny fst rejections s you cn 2. Do hierrchicl fst rejections 3. Discrete: compre ll edges of Object A ginst ll fces of Object B 3. Continuous: crete pseudo-edges by connecting respective points in Object A cross the time step, then compre ll these pseudo-edges of Object A ginst ll fces of Object B
Try to Simplify the Intersection Test Brek the Scene into Grid Discrete: You only hve to do intersection tests ginst objects tht live in the sme grid squre.
Try to Simplify the Intersection Test-- A Bounding Sphere
Try to Simplify the Intersection Test- Bounding Spheres R 2 R 1 C 2 C 1 2 These spheres overlp if: Distnce(C 1,C 2 ) < R 1 +R 2 1 To void the squre root: Distnce 2 (C 1,C 2 ) < (R 1 +R 2 ) 2
Try to Simplify the Intersection Test-- A Bounding Box Ymx Xmin Xmx Ymin
Try to Simplify the Intersection Test- Bounding Boxes Quickly compre two objects by fitting ech with bounding box nd then compring the two bounding boxes. 1 2 2 1 These boxes do not overlp if: Xmx 1 < Xmin 2 Ymx 1 < Ymin 2 Xmx 2 < Xmin 1 Ymx 2 < Ymin 1 2 1 These boxes do overlp if: Xmx 1 > Xmin 2 && Ymx 1 > Ymin 2 && Xmx 2 > Xmin 1 && Ymx 2 > Ymin 1
Try to Simplify the Intersection Test- -- Two Types of Bounding Boxes Axis-Aligned Bounding Box (AABB) Check for overlp by looking for overlp in just X, then just Y, then just Z Arbitrry-Oriented Bounding Box (AOBB) This is tighter fit round the object, but the overlp comprison is more involved
A Hierrchy of Bounding Boxes
Discrete -- You Cn Esily Tell if Point is Inside Convex Polyhedron Assume tht ll surfce normls point outwrds (usul convention). Use the Distnce-from--Point-to--Plne formul for ech fce of the polyhedron. If ll distnces re negtive, the point is inside the convex polyhedron Wht if the polyhedron is not convex? Put Convex Hull round the polyhedron nd test ginst tht. If the point is not inside the convex hull, then it is not inside the polyhedron either. If it is inside the convex hull, then more detiled nlysis is needed.
P d Distnce from Point to Plne nˆ Q The eqution of the plne is: x,y,z Q,Q,Q (n,n,n ) 0 which expnds out to become the more fmilir Ax + By + Cz + D = 0 x y z x y z The distnce from the point P to the plne is bsed on the plne eqution: d PQ nˆ The dot product is nswering the question How much of (P-Q) is in the norml direction?. Note tht this gives signed distnce. If d > 0., then P is on the sme side of the plne s the norml.
Discrete nd Continuous Compring n Edge on Object A ginst Fce on Object B P 1 nˆ Q P The eqution of the line segment is: P (1 tp ) tp 0 1 If point P wnts to be point in the plne, then: P,P,P Q,Q,Q (n,n,n ) 0 x y z x y z x y z If we substitute the prmetric expression for P into the plne eqution, then the only thing we don t know in tht eqution is t. Knowing t* will let us compute the (x,y,z) of the ctul intersection using the line eqution. If t* hs zero in the denomintor, then tht tells us tht t*=, nd the line must be prllel to the plne. This gives us the point of intersection with the infinite plne. We would now use the method covered few slides go to see if P lies inside the tringle in question. P 0
Is Point inside Tringle? n S Let: n ( RQ) ( S Q) Q P R n ( RQ) ( PQ) q n ( SR) ( PR) r n ( QS) ( PS) s If ( nn ),( nn ), nd( nn ) q r s re ll positive, then P is inside the tringle QRS
If Find Discrete Interference Do binry serch cross the time step until you find the time of collision
If Find Continuous Interference Connect ll points cross time nd look for the minimum t in n intersection with the boundry
The Physics of Collisions -- Definitions Line of Impct If the objects velocities re prllel to the Line of Impct, this is Direct Impct If the objects velocities re perpendiculr to the Line of Impct, this is Tngentil Impct A combintion of the two is clled n Oblique Impct Direct Impct Tngentil Impct Oblique Impct (both direct nd tngentil)
The Physics of Collisions Fundmentl Quntities The momentum of n object is defined s its mss multiplied by its velocity: Momentum mv The energy of n object is defined s one hlf of its mss multiplied by its velocity squred: Energy 1 2 mv 2
The Physics of Collisions Conservtion of Momentum In collision, the totl momentum fter the impct is equl to the totl momentum before the impct. Alwys. b mv mv mv mv b b b b where the primes refer to velocities fter the impct This is referred to s the Conservtion of Momentum Lw Momentum is lwys conserved through ny collision
Conservtion of Momentum s Explined by Newton s Crdle http://www.grnd-illusions.com/ctlog/newtons_crdle.html And, of course, where would ny topic be without kittens? http://dsc.discovery.com/videos/mythbusters-newtons-crne-crdle/ http://www.buzzfeed.com/koolnewsblog/cts-for-the-love-of-physics-1dgl
The Physics of Collisions Coefficient of Restitution In collision, energy is conserved in the entire system, but not necessrily in the form of velocities. (It cn become permnent deformtion, het, light, etc..) This loss of velocity is expressed s the Coefficient of Restitution (COR). The COR, e, is how much less the reltive velocities of the objects re fter impct thn they were before impct: b v v e( v v ) b b (the negtive sign is there to indicte the bounce )
The Physics of Collisions Combining Momentum nd Restitution Lws b Strting with these two equtions: mv mv mvmv b b b b v v e( v v ) b b Tret the two initil velocities s inputs nd solve for the two resulting velocities. This gives: v v b mv mv em( v v) b b b b m m mv mv em( v v) b b b m m b b
The Physics of Collisions with Immoveble Objects To tret the cse of mss b being n immoveble object, such s the ground or solid wll, solve for the resulting velocities tking the limit: lim m b v mv mv em( v v) b b b b m m b mv mv b b emb( vb v) lim mb m mb m mb m mb 0 v e( v v ) b b lim mb Since mss b is immoveble, its velocity is zero, so tht s post-collision velocity is: v ev
Collisions Experimentlly Determining the Coefficient of Restitution Velocities re hrd to mesure live, but distnces re not. So, drop the object from height h, nd mesure its bounce to height h : v Before the bounce: After the bounce: gh 2 2 0 v 2gh 2 2 2 0 2 v 2gh v 2gh v e v e v 2gh v 2gh h h
Collisions Some Coefficients of Restitution of Blls Bounced on Concrete Surfce Bll Mteril CoR rnge golf bll 0.858 tennis bll 0.712 billird bll 0.804 hnd bll 0.752 wooden bll 0.603 steel bll bering 0.597 glss mrble 0.658 bll of rubber bnds 0.828 hollow, hrd plstic bll 0.688 http://hypertextbook.com/fcts/2006/restitution.shtml
The Physics of Collisions Totlly Plstic Collisions v v b mv mv em( v v) b b b b m m mv mv em( v v) b b b m m b b If e=0, then the two objects stick together nd end up with the sme resulting velocity: v v b mv b b m mv m b
One of my Jury Duties: Two vehicles collide. One is very dmged, the other hrdly t ll. Wht hppened? Who s right? Very dmged B 25 mph Hrdly dmged A 0 mph vb evb 11.2(1.3) v 4.9 m/ sec m m 3 b mv b b emv b 11.2(1.3* 2) v b 1.5 m/ sec m m 3 v = 0. mph v b = 25 mph = 11.2 m/sec m = 2.0 m b = 1.0 e =.30 b How much velocity chnge did ech cr undergo? (Δv is n pproximte mesure of dmge.) Δv = 4.9 0. = 4.9 m/sec = 11.0 mph Δv b = 1.5 11.2 = 9.7 m/sec = 21.7 mph
The Physics of Collisions Totlly Elstic Collisions Wht hppens when e=1? The two fundmentl equtions re mv mv mv mv b b b b v v e( v v ) ( v v ) b b b Rerrnging: m v v m v v b b b v v v v b b
The Physics of Collisions Elstic Collisions m v v m v v b b b v v v v b b Then, multiplying the two together gives: Or: mv mv mv mv 2 2 2 2 b b b b 1 1 1 1 mv mv mv mv 2 2 2 2 2 2 2 2 b b b b This shows tht energy is conserved when the Coefficient of Restitution is 1.0
The Physics of Collisions Oblique Impcts Oblique Impcts re then hndled by using vector mth to determine the direct nd tngentil velocity components with respect to the Line of Impct. b The direct components re chnged using the equtions we just derived. The tngentil components re left unchnged. (This ssumes no friction.) The new components re then combined to produce the resulting velocity vectors.
Voxeliztion nother wy to do Collision Detection? Rndy Ruwendl