Fundamentals of Computer Animation Collision Detection and Response.

Slides:



Advertisements
Similar presentations
Real-Time Game Physics
Advertisements

Kinetics of Particles Impulse and Momentum.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Kinetics of Particles: Energy and Momentum Methods
Chapter 15: Kinetics of a Particle: Impulse and MomentumTextbook: Engineering Mechanics- STATICS and DYNAMICS- 11th Ed., R. C. Hibbeler and A. Gupta Course.
Chapter 7 - Giancoli Momentum and Impulse.
Computational Geometry & Collision detection
IMPACT Today’s Objectives: 1.Understand and analyze the mechanics of impact. 2.Analyze the motion of bodies undergoing a collision, in both central and.
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
UNC Chapel Hill S. Redon - M. C. Lin Rigid body dynamics II Solving the dynamics problems.
Collision Detection CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
7-6 Inelastic Collisions
Computer graphics & visualization Collision Detection – Narrow Phase.
Work Let us examine the work done by a torque applied to a system. This is a small amount of the total work done by a torque to move an object a small.
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Linear momentum and Collisions
Momentum, Impulse, And Collisions
Ch. 8 Momentum and its conservation
Collision handling: detection and response
CHAPTER 13 Kinetics of Particles: Energy and Momentum Methods.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Questions From Reading Activity? Big Idea(s):  The interactions of an object with other objects can be described by forces.  Interactions between.
Momentum and Its Conservation
Chapter 7 Linear Momentum. MFMcGraw-PHY 1401Chap07b- Linear Momentum: Revised 6/28/ Linear Momentum Definition of Momentum Impulse Conservation.
Chapter 17 PLANE MOTION OF RIGID BODIES: ENERGY AND MOMENTUM METHODS
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Linear Momentum Impulse & Collisions. What is momentum?  Momentum is a measure of how hard it is to stop or turn a moving object.  What characteristics.
DYNAMICS VECTOR MECHANICS FOR ENGINEERS: DYNAMICS Tenth Edition Ferdinand P. Beer E. Russell Johnston, Jr. Phillip J. Cornwell Lecture Notes: Brian P.
Collision Detection And Response Jae Chun KyungSoo Im Chau Vo Hoang Vu.
Computer Game Design and Development
Linear Momentum. Units of Momentum Momentum and Its Relation to Force Conservation of Momentum Collisions and Impulse Conservation of Energy and Momentum.
Let’s Bounce! or Physics of Collisions Part 1 Games Fundamentals © by Jarek Francik Kingston University, London
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Unit 2 Momentum and Impulse An Introduction to Momentum.
© 2014 Pearson Education, Inc. This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their.
Advanced Computer Graphics Rigid Body Simulation
Chapter 7 Linear Momentum
Today: (Ch. 7) Momentum and Impulse Conservation of Momentum Collision.
Definition of a System Energy of a System Momentum of a System
Definition of a System Energy of a System Momentum of a System
Chapter 13 Gravitation.
PHYS 1443 – Section 003 Lecture #18
Linear Kinetics of Human Movement
CHAPTER 4: Systems of Particles
PHYS 1443 – Section 003 Lecture #16
IMPACT Today’s Objectives: Students will be able to:
Chapter 4.2 Collision Detection and Resolution
IMPACT Today’s Objectives: Students will be able to:
Chapter 7 Linear Momentum.
Devil physics The baddest class on campus AP Physics
Impulse-Momentum Principle
1.
ENGINEERING MECHANICS
Chapter 13 Gravitation.
Motion in Real and Virtual Worlds
Collision Detection CSE169: Computer Animation
Chapter 11 Angular Momentum
Computer Animation Algorithms and Techniques
Chapter 7 Linear Momentum
AS-Level Maths: Mechanics 1 for Edexcel
Physics: Principles with Applications, 6th edition
Chapter 6 Momentum and Collisions
Collisions Chapter 4.
Energy Problems.
GPAT – Chapter 7 Physics.
Presentation transcript:

Fundamentals of Computer Animation Collision Detection and Response

So far, no interaction between rigid bodies Bodies in Collision Collisions and Contact Collision detection – determining if, when and where a collision occurs Collision response – calculating the state (velocity, …) after the collision

What should we do when there is a collision? Collisions and Contact

Restart the simulation at the time of the collision Rolling Back the Simulation Collision time can be found by bisection, etc.

Ray-Scene Intersection

Types of Geometry Points Lines, Rays and Line Segments Spheres, Cylinders and Cones Cubes, rectilinear boxes - Axis aligned or arbitrarily aligned –AABB: Axis aligned bounding box –OBB: Oriented bounding box k-dops – shapes bounded by planes at fixed orientations Convex, manifold meshes – any mesh can be triangulated –Concave meshes can be broken into convex chunks, by hand Triangle soup More general curved surfaces, but not used (often) in games 8-dop AABB OBB

Ray-Sphere Intersection

Ray-Sphere Intersection I

Ray-Sphere Intersection II

Ray-Sphere Intersection

Ray-Triangle Intersection

Ray-Plane Intersection

Ray-Triangle I Intersection

Ray-Triangle II Intersection

Other Ray-Primitive Intersections

Intersection Tests: How About Object-Object ? We’ll cover: –Spheres –Oriented Boxes –Capsules –Lozenges –Cylinders –Ellipsoids –Triangles But first let’s check some basic issues on collision/response…

Exploit coherency through witnessing Collision Detection Speed up with bounding boxes, grids, hierarchies, etc. separating plane Two convex objects are non-penetrating iff there exists a separating plane between them First find a separating plane and see if it is still valid after the next simulation step

Collision Detection

Conditions for collision Collision Detection separatingcontactcolliding

Collision Detection and Response Collision Detection –Moving Sphere - Plane –Moving Sphere - Moving Sphere Physically Based Modeling –Collision Response –Moving Under Gravity Using Euler Equations

Ray-Plane Intersection

Sphere-Sphere Collision A sphere is represented using its center and its radius d Intersection if d is less than the sum of their two radius

How About 2 MOVING spheres? Their paths cross in-between but this is not enough to prove that an intersection occurred (they could pass at a different time) nor can the collision point be determined. 2 spheres move during a time step from one point to another

How About 2 MOVING spheres? Sliced time step up into smaller pieces. Move the spheres according to that sliced time step using its velocity, and check for collisions. If at any point collision is found (which means the spheres have already penetrated each other) then –Take the previous position as the intersection point –(we could start interpolating between these points to find the exact intersection position, but that is mostly not required). The smaller the time steps, the more slices we use the more accurate the method is. As an example lets say the time step is 1 and our slices are 3. We would check the two balls for collision at time 0, 0.33, 0.66, 1.

Sphere-Plane Collision Determine the exact collision point between a particle and a plane. The start position of the ray is the position of the particle and the direction of the ray is its velocity (speed and direction).

Sphere-Plane Collision Each sphere has a radius, take the center of the sphere as the particle and offset the surface along the normal of each plane of interest. Our actual primitives of interest are the ones represented by continuous lines, but the collision testing is done with the offset primitives (represented with dotted lines). In essence we perform the intersection test with a little offset plane.

Sphere-Plane Collision Using this little trick the ball does not penetrate the surface if an intersection is determined with its center. Otherwise we get the situation where the sphere penetrates the surface. This happens because we determine the intersection between its center and the primitives.

Exact Collision Time We move the sphere (according to its velocity), calculate its new position and find the distance between the start and end point. To calculate the exact time we solve the following simple equation: Tc= Dsc*T / Dst –Dst  distance between start - end point –Dsc  the distance between start - collision point –T  the time step as T

The Collision Point The returned time Tc is a fraction of the whole time step, so if the time step was 1 sec, and we found an intersection exactly in the middle of the distance, the calculated collision time would be 0.5 sec. this is interpreted as "0.5 sec after the start there is an intersection". Now the intersection point can be calculated by just multiplying Tc with the current velocity and adding it to the start point. Collision point = Start + Velocity*Tc This is the collision point on the offset primitive, to find the collision point on the real primitive we add to that point the reverse of the normal at that point (which is also returned by the intersection routines) by the radius of the sphere.

Collision Response

Collision Response  Sphere approaching a Plane What kind of response? Totally elastic! No kinetic energy is lost  response is “perfectly bouncy”

“Perfectly Bouncy” Response

Soft Body Collision Collision Force is applied to prevent interpenetration

Soft Body Collision Collision Apply forces and change the velocity

Harder Collision Collision Higher force over a shorter time

Rigid Body Collision Collision Impulsive force produces a discontinuous velocity

How to “Suggest” Sphere “Deformation”? k, in [0,1]  coefficient of restitution

Using Coefficient of Restitution: As k gets smaller  more and more energy is lost  less and less bouncy

Using Coefficient of Restitution: As k gets smaller  more and more energy is lost  less and less bouncy

U1 and U2  velocity vectors of the two spheres at the time of impact X_Axis  vector which joins the 2 centers of the spheres U1x, U2x  projected vectors of the velocity vectors U1,U2 onto the axis (X_Axis) vector U1y and U2y are the projected vectors of the velocity vectors U1,U2 onto the axis which is perpendicular to the X_Axis Collisions Between Spheres (1)

a) Find X_Axis X_Axis = (center2 - center1); Unify X_Axis, X_Axis.unit(); b) Find Projections U1x= X_Axis * (X_Axis dot U1) U1y= U1 - U1x U2x =-X_Axis * (-X_Axis dot U2) U2y =U2 - U2x c) Find New Velocities (U1x * M1)+(U2x*M2)-(U1x-U2x)*M2 V1x= M1+M2 (U1x * M1)+(U2x*M2)-(U2x-U1x)*M1 V2x= M1+M2 d) Find The Final Velocities V1y=U1y V2y=U2y V1=V1x+V1y V2=V2x+V2y M1, M2 is the mass of the two spheres V1,V2 are the new velocities after the impact, V1x, V1y, V2x, V2y are the projections of the velocity vectors onto the X_Axis.

Moving Under Gravity All the computations are going to be performed using time steps. This means that the whole simulation is advanced in certain time steps during which all the movement, collision and response tests are performed. As an example we can advanced a simulation 2 sec. on each frame. Based on Euler equations, the velocity and position at each new time step is computed as follows: Velocity_New = Velovity_Old + Acceleration*TimeStep Position_New = Position_Old + Velocity_New*TimeStep

Moving Under Gravity Velocity_New = Velovity_Old + Acceleration*TimeStep Position_New = Position_Old + Velocity_New*TimeStep Now the objects are moved and tested against collision using this new velocity. The Acceleration for each object is determined by accumulating the forces which are acted upon it and divide by its mass according to this equation: Force = mass * acceleration But in our case the only force the objects get is the gravity, which can be represented right away as a vector indicating acceleration. In our case something negative in the Y direction like (0,-0.5,0).

At the beginning of each time step Calculate the new velocity of each sphere Move them testing for collisions. If a collision occurs during a time step (say after 0.5 sec with a time step equal to 1 sec.): Advance the object to this position Compute the reflection (new velocity vector) Move the object for the remaining time (which is 0.5 in our example) testing again for collisions during this time. This procedure gets repeated until the time step is completed.

Collisions Between Spheres (2) Spheres of equal size and weight. For now let’s ignore the rotation and do not consider friction The sphere collision will behave exactly like a particle at the sphere's center of mass.

Setup + Terminology Ball A is moving at a speed of 20 feet per second and collides with ball B at a 40 degree angle. Impact  a collision between two rigid bodies, which occurs in a very short time and during which the two bodies exert relatively large forces on each other Impulsive force  the force between these two bodies during the collision (symbolized by j) Line of collision  The common normal to the surfaces of the bodies in contact

New velocity along the line of collision: Impulsive force between the bodies? The impulse acts on both bodies at the same time The forces exerted by two particles on each other are equal in magnitude and opposite in direction. Since the impulse forces are equal and opposite, momentum is therefore conserved before and after the collision. –Momentum of a rigid body is mass times velocity (mv).

We need to derive the impulse force directly. The impulse force creates a change in momentum of the two bodies with the following relationship:

We need to derive the impulse force directly. The impulse force creates a change in momentum of the two bodies with the following relationship: The impulse equation for a general body that does not rotate. Chris Hecker "Physics, Part 3: Collision Response,"Physics, Part 3: Collision Response Behind the Screen, Game Developer, February/March 1997

k, in [0,1]  coefficient of restitution