160 likes | 325 Views
Simulation and Animation. Collision Detection – Narrow Phase. Collision Detection. Contact . Where do bodies hit each other ? Bodies described by polyhedra Rigid bodies 2 cases : Vertex/Face example : cube on table , 4 Vertex/Face contacts for 4 cube vertices
E N D
Simulation and Animation Collision Detection – Narrow Phase
Contact • Where do bodieshiteachother? • Bodiesdescribedbypolyhedra • Rigid bodies • 2 cases: • Vertex/Faceexample: cube on table, 4 Vertex/Face contactsfor 4 cubevertices • Edge/Edge:example: cubeprotrudesovertable, 2 Vertex/Face contactsand 2 Edge/Edge contactswithdeskedge
Contact • Describingthecontact: • Involvedbodies • Contactpoint in worldcoordinates • Collision normal • Face normal in caseof Vertex/Face contact • Cross productbetweenedgevectors in caseof Edge/Edge contact
Contact • Discretizationproblem • Contactdetectionatsimulation time step • Collisionhastoconsidertime constraints 4D problem Contactoccurs, but mightbemissed due to fix time discretizationofsimulation t t + 1
Contact • Basic algorithmsforcollisiondetection • Detectingcollisionoccurence • Detectingpointofcontact • Modelling a response • Most common in games: • Broad/Narrowphasealgorithms • Broadphase: rejectobjectsthatcannotcollide • Bsp-Trees, Boundingvolumehiearchies, separatingaxes • Narrowphase: Applyaccuratecollisiondetection • Polyhedron/Polyhedron, closestfeatures
Contact • Narrowphasecollisiondetection • (Convex) polyhedron/polyhedrontest • Anyvertexofeitherobjectiscontained in theotherone v: vertex, u: vertex on face, n: outwardfacing normal • Penetration betweenedgesandfaces • Ifshortestdistancebetweenedgepointschangessign • Computeintersectionpointsbetweenedgesand infinite planes • Sortintervalsandtesttheirpointsasabove • Check forexactlyalignedobjects
Narrow Phase between triangles Step 1: Compute plane equations
Narrow Phase between triangles Step 2: Computevertex-to-plane distances andlookforsignchange also computeviceversadistances
Narrow Phase between triangles • Narrowphasecollisiondetectionbetweentriangles • Test foroverlappingintervalsalong plane-plane intersection L L L=O+tD D=N1×N2
Narrow Phase between triangles V0,1 V2,1 pv,1,1=D∙(V1,1-O) d0,1 L t2 t1 K0,1 K1,1 π1 d1,1 pv,0,1=D∙(V0,1-O) V1,1 π2
Optimizations • Interval shift does not influence overlap avoid computation of O and replace by • Projection of L onto an arbitrary axis does not influence overlap
Contact • Narrowphasecollisiondetectionbetweentriangles • Based on axial projections • Triangleshavenormals N, M andedges Ei, Fj • Compute plane equation p0,p1 oftriangle0,1 • Ifbothtrianglesare parallel - reject • Ifbothtrianglesarecoplanar – 2D (overlap/in-out)-test • Computedistancesofverticesof1,0 to p0,p1 • If all distanceshave same sign - reject • General case: intersectionis a line L (o+td, d=NxM) • Computeprojectionsofverticesonto L: (d·(v-o)) • Computeprojectionsofverticesonto p0,p1 • Computeintervalsfromsimilarityobservation
Contact • Space-Time constraints • Consider time discretization, e.g. bounding spheres • Size of smallest sphere determined by time step of simulation and maximal velocity • Spheres are taken from smaller object • Collisions between dynamic and static objects • Consider velocity of moving objects • Predict first collision within given time interval • Only if collision occurs, tree model has to be processed recursively
Contact • Dynamicallymovingsphereand plane • Sphereofradius r andcenter C(t) = C(0) + t V • Plane equation: NX=d • Check forcollision in time interval t [0,tmax] • Distance(center, plane): |NC(t)-d| • First time ofcontact: |NC(T)-d| = r • T<0: spheremovesaway • T>0: sphere will intersectatposition C(T)
Contact • Dynamicallymoving box and plane • Project box half-sizesonto normal lineof plane • Take projectedvalueasradiusof a sphere • Applysphere-plane testfromabove • Findingintersectionpointismorecomplex • Depends on box orientation - face, lineorvertex