Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer graphics & visualization Collision Detection – Narrow Phase.

Similar presentations


Presentation on theme: "Computer graphics & visualization Collision Detection – Narrow Phase."— Presentation transcript:

1 computer graphics & visualization Collision Detection – Narrow Phase

2 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Collision Detection Broad Phase Narrow Phase Detection

3 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group 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 – Edge/Edge: example: cube protrudes over table, 2 Vertex/Face contacts and 2 Edge/Edge contacts with desk edge

4 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Describing the contact: – Involved bodies – Contact point in world coordinates – Collision normal Face normal in case of Vertex/Face contact Cross product between edge vectors in case of Edge/Edge contact

5 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Discretization problem – Contact detection at simulation time step – Collision has to consider time constraints  4D problem t t + 1 Contact occurs, but might be missed due to fix time discretization of simulation

6 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Basic algorithms for collision detection – Detecting collision occurence – Detecting point of contact – Modelling a response Most common in games: – Broad/Narrow phase algorithms Broad phase: reject objects that cannot collide – Bsp-Trees, Bounding volume hiearchies, separating axes Narrow phase: Apply accurate collision detection – Polyhedron/Polyhedron, closest features

7 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Narrow phase collision detection – (Convex) polyhedron/polyhedron test Any vertex of either object is contained in the other one v: vertex, u: vertex on face, n: outward facing normal Penetration between edges and faces – If shortest distance between edge points changes sign – Compute intersection points between edges and infinite planes – Sort intervals and test their points as above Check for exactly aligned objects

8 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Narrow Phase between triangles Step 1: Compute plane equations

9 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Narrow Phase between triangles Step 2:Compute vertex-to-plane distances and look for sign change also compute vice versa distances

10 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Narrow Phase between triangles Narrow phase collision detection between triangles – Test for overlapping intervals along plane-plane intersection LL L=O+tD 12 D=N 1 ×N 2

11 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Narrow Phase between triangles t1t1 t2t2 K 0,1 K 1,1 V 1,1 V 0,1 V 2,1 π1π1 π2π2 L p v,1,1 =D∙(V 1,1 -O) p v,0,1 =D∙(V 0,1 -O) d 0,1 d 1,1

12 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group 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

13 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Narrow phase collision detection between triangles – Based on axial projections – Triangles have normals N, M and edges E i, F j – Compute plane equation p0,p1 of triangle  0,  1 If both triangles are parallel - reject If both triangles are coplanar – 2D (overlap/in-out)-test – Compute distances of vertices of  1,  0 to p0,p1 If all distances have same sign - reject – General case: intersection is a line L (o+td, d=NxM) Compute projections of vertices onto L: (d·(v-o)) Compute projections of vertices onto p0,p1 Compute intervals from similarity observation

14 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group 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

15 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Dynamically moving sphere and plane – Sphere of radius r and center C(t) = C(0) + t V – Plane equation: N  X=d – Check for collision in time interval t  [0,t max ] – Distance(center, plane): |N  C(t)-d| – First time of contact: |N  C(T)-d| = r T<0: sphere moves away T>0: sphere will intersect at position C(T)

16 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Dynamically moving box and plane – Project box half-sizes onto normal line of plane – Take projected value as radius of a sphere – Apply sphere-plane test from above – Finding intersection point is more complex Depends on box orientation - face, line or vertex

17 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Two dynamically moving objects – Consider either object to be static – Subtract velocity of that object from velocity of other object – Apply collision determination as above Re-add velocity to adjust point of intersection

18 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Response modeling – Translation to resolve contact – Computing new velocities Consider impulses with/without friction – Atomic reaction Translation of the object due to collision with a face – Accumulation of all reactions

19 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Does contact exist? Velocity of a point of a rigid body: Relative velocity of both bodies a and b (along normals): 3 cases: – v rel < 0: collision – v rel > 0: contact resolved – v rel = 0: contact at rest

20 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Carry over impulse J (instant. force F  t) during collision – Direct change of velocity and angular velocity – Change of momentum (translational movement) and thus velocity: – Change of angular momentum (rotational movement) and thus angular velocity: Contact point

21 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Momentum along normals Velocities before and after collision Coefficient of restitution 

22 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Velocities of contact points: Linear velocities and angular velocity

23 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Algorithm (see Parent: Computer Animation) Compute V a,V b ; V rel = n · (V a - V b ); If(V rel >  ) compute j; J = j · n; p a += J; p b -=J; // considered by the dynamics L a += r a x J; L b -= r b x J; // simulator else if (V rel < -  ) resting contact else objects move away from each other

24 computer graphics & visualization Simulation and Animation – SS 07 Jens Krüger – Computer Graphics and Visualization Group Contact Constraints: – Friction: kinetic friction work opposite to the direction of movement – Resting contact No penetration (inter-penetration) Repulsive contact forces Possibility to separate bodies


Download ppt "Computer graphics & visualization Collision Detection – Narrow Phase."

Similar presentations


Ads by Google