Interaction and Normals Intro to Programming in 3D Applications Lecture 20 Collision handling detection & response detection response Particle-plane collision detection Polyhedron-polyhedron collision detection overlap of Bounding volumes Vertex inside polyhedron test Concave case Convex case Edge-face intersection test kinematic response Penalty method Impulse force of collision Collision Detection • One part of the physics generally necessary in today’s • game environments Basics – – – – – – Ray-Polygon Intersection Object motion vector is the ray Wall or other object is the polygon(s) Simple to implement Polygon-Polygon Intersection Can be expensive to calculate • Separate from Collision Response Ray Basics • Segment-Plane Intersection – Intersect movement segment with plane of polygon – Segment is defined by start and end points • Intersection Point – Find the exact 3D location of the intersection • Point in Polygon Check – Easy for simple polygons • Calculate dot product of edge normals to vector • Fast, Minimum Storage Ray-Triangle Intersection (best) – http://www.acm.org/jgt/papers/MollerTrumbore97/ – More difficult for concave polygons • Sum angles between vectors to vertices • Divide polygon into quadrants, sum edge crossings • Scanline +/- • If the point is in the polygon the movement vector went through the surface and we have a collision Collision detection: point-plane E( p) ax by cz d N p d E ( p) 0 N E ( p) 0 E ( p) 0 Collision detection: time of impact 2 options Consider collision at next time step Compute fractional time at which collision actually occurred Tradeoff: accuracy v. complexity Intersection Testing • General goals: given two objects with current • • and previous orientations specified, determine if, where, and when the two objects intersect Alternative: given two objects with only current orientations, determine if they intersect Sometimes, we need to find all intersections. Other times, we just want the first one. Sometimes, we just need to know if the two objects intersect and don’t need the actual intersection data. Primitives • We often deal with various different ‘primitives’ • that we describe our geometry with. Objects are constructed from these primitives Examples – – – – – Triangles Spheres Cylinders AABB = axis aligned bounding box OBB = oriented bounding box • At the heart of the intersection testing are various primitive-primitive tests Particle Collisions • mainly be concerned with the problem of testing • • • if particles collide with solid objects A particle can be treated as a line segment from it’s previous position to it’s current position If we are colliding against static objects, then we just need to test if the line segment intersects the object Colliding against moving objects requires some additional modifications that we will also look at Segment vs. Triangle • Does segment ab intersect triangle v0v1v2 ? a v2 v0 •x v1 b Segment vs. Triangle • First, compute signed distances of a and b to plane d a a v 0 n n a d b b v 0 n da x • v0 • Reject if both are above or both are below triangle • Otherwise, find intersection point x d ab d ba x d a db db b Segment vs. Triangle • Is point x inside the triangle? (x-v0)·((v2-v0)×n) > 0 • Test all 3 edges v2 v2-v0 x-v0 v0 •x v1 (v2-v0)×n Faster Way • Reduce to 2D: remove smallest dimension v2 • Compute barycentric coordinates • x' =x-v0 e1=v1-v0 β e2=v2-v0 v0 α=(x'×e2)/(e1×e2) α β=(x'×e1)/(e1×e2) Reject if α<0, β<0 or α+β >1 x v1 Segment vs. Mesh • To test a line segment against a mesh of • • triangles, simply test the segment against each triangle Sometimes, we are interested in only the ‘first’ hit along the segment from a to b. Other times, we want all intersections. Still other times, we just need any intersection. Testing against lots of triangles in a large mesh can be time consuming. We will look at ways to optimize this later Segment vs. Moving Mesh • M0 is the object’s matrix at time t0 • M1 is the matrix at time t1 • Compute delta matrix: • • M1=M0·MΔ MΔ= M0-1·M1 Transform a by MΔ a'=a·MΔ Test segment a'b against object with matrix M1 Triangle vs. Triangle • Given two triangles: T1 (u0u1u2) and T2 (v0v1v2) v2 u2 v0 T2 u0 T1 u1 v1 Triangle vs. Triangle Step 1: Compute plane equations n2=(v1-v0)×(v2-v0) v2 d2=-n2·v0 v2-v0 n v0 v1-v0 v1 Triangle vs. Triangle • Step 2: Compute signed distances of T1 vertices to • • plane of T2: di=n2·ui+d2 (i=0,1,2) Reject if all di<0 or all di>0 Repeat for vertices of T2 against plane of T1 u0 d0 Triangle vs. Triangle • Step 3: Find intersection points • Step 4: Determine if segment pq is inside triangle or intersects triangle edge p q Mesh vs. Mesh • Geometry: points, edges, faces • Collisions: p2p, p2e, p2f, e2e, e2f, f2f • Relevant ones: p2f, e2e (point to face & edge to edge) • Multiple simultaneous collisions Sphere-Sphere Intersection • Two objects are said to have collided if their bounding • • spheres intersect. To determine if two spheres intersect, simply calculate the distance between the centers of the two spheres. If the distance is greater than the sum of the two sphere radii, they don’t intersect. Otherwise they intersect. r1 r2 d = r1 + r2 d > r1 + r2 Sphere-Plane Intersection • Sometimes, it’s necessary to find the • intersection between a sphere and a plane, for example, the bounding sphere of an object with a wall (or slope). Given that the equation of the plane is n.p = k (where n is the unit normal of the plane, p is any point on the plane, and k is a number) – Then, given the center coordinates C of the sphere, and the radius r of the sphere, • The sphere and the plane intersect if |(n.C) – k| < r Dot Product • Let U and V be vectors such that U = (Ux, Uy, • • Uz), and V = (Vx, Vy, Vz) Then, the dot product U.V = UxVx + UyVy + UzVz U.V is also equal to |U||V| cos q where q is the angle between U and V. U q V Collision of Fast-Moving Objects • We need a different method to detect collision of fast• • • moving, and often small, objects. Example, a bullet is fired, and we want to see if it intersects a wall. However, if we examine every time frame, because the bullet moves very fast, even though at some point in time it intersects the wall, we may only sample it in front of the wall and behind it, but on at the point of intersection. Therefore, we need to consider the path of the bullet, and determine if that path intersects the wall. We use a line to represent the path of the bullet. We then test for line-object intersection. We consider: – Line-Sphere intersection, and – Line-Triangle intersection Line-Sphere Intersection • Let a point on a line be X(t) = P + tD – Here X(t) is a function of t, and gives the point on the line, P is the starting point of the line, and D is a unit vector in the direction of the line. • Let a point on a sphere satisfy | X – C | = r – Here, X is a point on the sphere, C is the center of the sphere, and r is the radius of the sphere. Line-Sphere Intersection • Suppose the line and sphere intersect at point X, then | P + tD – C |2 – r2 = 0 – Let M = P – C. Then, | tD + M |2 – r2 = 0 – Expanding, t2 + 2D.Mt + | M |2 – r2 = 0 • See Note 1 on next page – Solving for t, t = -D.M +/- sqrt((D.M)2 – ( | M |2 – r2 )) • See Note 2 on next page – The discriminant d is (D.M)2 – ( | M |2 – r2 ) • If d > 0, the line and sphere intersect at two points. • If d = 0, the line and sphere intersect at one point. • If d < 0, the line and sphere don’t intersect. – If (d>0) or (d=0), we can solve for t. Assuming that P is the position of the fast-moving object at the beginning of the game loop, and D is the vector that it will travel during a game loop, then the objects intersect during this game loop if 0<t<1. Notes on Line-Sphere Intersection Note 1 |a+b|2 = |a|2 + |b|2 + 2a.b a+b b by Note 2 Let A, B and C be coefficients of the quadratic equation: Ax2 + Bx + C = 0 ay a ax bx Proof: |a+b|2 = (ax+bx)2 + (ay+by)2 = ax2 + 2axbx + bx2 + ay2+ 2ayby + by2 But, |a|2 = ax2 + ay2 and |b|2 = bx2 + by2 Therefore, |a+b|2 = |a|2 + |b|2 + 2(axbx + ayby) |a+b|2 = |a|2 + |b|2 + 2a.b Then, x = -B +/- sqrt(B2-4AC) 2A Line-Triangle Intersection • Once again, let a point on a line be X(t) = P + tD • Let a triangle be defined by its three corner points P0, P1 and P2. • Strategy: – First, find the intersection between the line and the plane containing the triangle. – Then, find out if this point is within the triangle Line-Triangle Intersection The Plane Containing the Triangle Equation of a plane: A point p on the plane will satisfy the equation p.n = k where n is the normal of the plane. Step 1: Find the normal n of the plane Let edge e0 be P1 – P0. Let edge e1 be P2 – P1. Then n = e0 x e1 In other words, the normal of the plane is the cross product of two edges. Step 2: Find k k = P0.n Line-Triangle Intersection Line-Plane Intersection 1. Substitute equation of the line into equation of the plane. (P + tD) . n = k 2. Find t. Re-arranging, t = (k – P.n)/(D.n) 3. Substitute t back to get intersection point. Intersection point R = P + tD. Line-Triangle Intersection Check if point is within triangle Remember that the cross product of consecutive vectors going counter-clockwise will always be of the same sign. P2 e2 P0 R is inside the triangle if it is always to the left side of each edge. e1 R e0 P1 Therefore, Point R is inside the triangle if: (e0 x (R – P0)) . n > 0 and (e1 x (R – P1)) . n > 0 and (e2 x (R – P2)) . n > 0 Speeding up Collision Detection • Spatial subdivision method • Divide the space into different regions. • At each step, determine which region each object is in. • Only test objects in the same region for collision. Collision detection: polyhedra Order tests according to computational complexity and power of detection 1. test bounding volumes for overlap 2. test for vertex of one object inside of other object 3. test for edge of one object intersecting face of other object Collision detection: bounding volumes Don’t do vertex/edge intersection testing if there’s no chance of an intersection between the polyhedra Want a simple test to remove easy cases Tradeoff complexity of test with power to reject non-intersecting polyhedra (goodness of fit of bounding volume) Bounding Spheres Compute bounding sphere of vertices Compute in object space and transform with object 1.Find min/max pair of points in each dimension 2. use maximally separated pair – use to create initial bounding sphere (midpoint is center) 3. for each vertex adjust sphere to include point Bounding Boxes Axis-aligned (AABB): use min/max in each dimension Oriented (OBB): e.g., use AABB in object space and transform with object. Vertex is inside of OBB if on inside of 6 planar equations Bounding Slabs For better fit bounding polyhedron: use arbitrary (user-specified) collection of bounding plane-pairs Is a vertex between each pair? d 2 N P d1 Convex Hull Best fit convex polyhedron to concave polyhedron but takes some (one-time) computation 1. Find highest vertex, V1 2. Find remaining vertex that minimizes angle with horizontal plane through point. Call edge L 3. Form plane with this edge and horizontal line perpendicular to L at V1 4. Find remaining vertex that for triangle that minimizes angle with this plane. Add this triangle to convex hull, mark edges as unmatched 5. For each unmatched edge, find remaining vertex that minimizes angle with the plane of the edge’s triangle Collision detection: polyhedra 1. test bounding volumes for overlap 2. test for vertex of one object inside of other object 3. test for edge of one object intersecting face of other obje Collision detection: polyhedra Intersection = NO For each vertex, V, of object A if (V is inside of B) intersection = YES For each vertex, V, of object B if (V is inside of A) intersection = YES A vertex is inside a convex polyhedron if it’s on the ‘inside’ side of all faces A vertex is inside a cancave polyhedron if a semi-infinite ray from the vertex intersects an odd number of faces Collision detection: polyhedra Edge intersection face test Finds ALL polyhedral intersections But is most expensive test If vertices of edges are on opposite side of plane of face Calculate intersection of edge with plane Test vertex for inside face (2D test in plane of face) Collision detection: swept volume Time & relative direction of travel sweeps out a volume Only tractable in simple cases (e.g. linear translation) If part of an object is in the volume, it was intersected by object Laws of Motion • First law simplified into the sentence "A body • • continues to maintain its state of rest or of uniform motion unless acted upon by an external unbalanced force." This law is known as the law of inertia. Second law is often stated as "F = ma: the net force on an object is equal to the mass of the object multiplied by its acceleration." Third law Whenever a particle A exerts a force on another particle B, B simultaneously exerts a force on A with the same magnitude in the opposite direction. This law is often simplified as "To every action there is an equal and opposite reaction." Linear Momentum and Collisions Linear momentum is defined as: p = mv Momentum is given by mass times velocity. Momentum is a vector. The units of momentum are (no special unit): [p] = kg·m/s Since p is a vector, we can also consider the components of momentum: px = mvx py = mvy pz = mvz Note: momentum is “large” if m and/or v is large. (define large, meaning hard for you to stop). • Name an object with large momentum but • small velocity. Name an object with large momentum but small mass Recall that F ma and v a t mv p F t t Another way of writing Newton’s Second Law is F = Dp/Dt= rate of change of momentum This form is valid even if the mass is changing. This form is valid even in Relativity and Quantum Mechanics. Impulse We can rewrite F = Dp/Dt as: FDt = Dp I = FDt is known as the impulse. The impulse of the force acting on an object equals the change in the momentum of that object. If there are no external forces on a system, then the total momentum of that system is constant. This is known as: The Principle of Conservation of Momentum In that case, pi = pf. Conservation of Momentum • In the absence of external forces, the total momentum of a given system remains constant. A 90 kg hockey player traveling with a velocity of 6 m/s collides head-on with an 80 kg player traveling a 7 m/s. If the two players entangle and continue traveling together as a unit following the collision, what is their combined velocity? Known: m1= 90 kg m2=80 kg v1= 6 m/s v2= -7 m/s m1v1 + m2v2 = (m1 + m2) (v) (90 kg) (6 m/s) + (80 kg) (-7 m/s) = (90 kg + 80 kg) (v) 540 kg m/s – 560 kg m/s = (170 kg) (v) - 20 kg m/s = (170 kg) (v) v = 0.12 m/s in the direction of the 80 kg player’s original direction of travel Conservation of Momentum and Newton’s Third Law • Consider a system consisting of just the two masses m1 • • • • • • • • and m2. Mass m1 exerts a force F21 on mass m2. Mass m2 exerts a force F12 on mass m1. Force on m1 = rate of change of momentum of m1 – F12 =Dp1 / Dt Force on m2 = rate of change of momentum of m2 – F21 =Dp2 / Dt Dp1 / Dt + Dp2 / Dt = F12 + F21 = 0 (Newton’s Third Law). D(p1+p2 )/ Dt = 0 Rate of change of total momentum is zero. Total Momentum does not change if net external force is zero – Composite objects can be treated like point particles Internal vs. External Forces Here the system is just the box and table. Any forces between those two objects are internal. Example: The normal forces between the table and the box are internal forces. Internal forces on the system sum to zero. system External forces do not necessarily sum to zero. Something outside the circle is pushing or pulling something inside the circle. Example: gravity is an external force. Impulse and Bouncing • Impulses are greater • when bouncing takes place. The impulse required to bring an object to a stop and then throw it back again is greater than the impulse required to bring an object to a stop. The Forces Equal and Opposite More About Impulse: F-t The Graph • Impulse is a vector • • • quantity The magnitude of the impulse is equal to the area under the force-time curve Dimensions of impulse are M L / T Impulse is not a property of the particle, but a measure of the change in momentum of the particle Impulse • If your car runs into a brick wall and you come to rest along with the car, there is a significant change in momentum. If you are wearing a seat belt or if the car has an air bag, your change in momentum occurs over a relatively long time interval. If you stop because you hit the dashboard, your change in momentum occurs over a very short time interval. Impulse • The impulse can also • • be found by using the time averaged force I = F Dt This would give the same impulse as the time-varying force does Recoil • Recoil is the term that describes the backward movement of an object that has propelled another object forward. In the nuclear decay example, the vn’ would be the recoil velocity. Conservation of Momentum, Archer Example • The archer is standing • on a frictionless surface (ice) Approaches: – Newton’s Second Law – no information about F or a – Energy approach – no information about work or energy – Momentum – yes Archer Example, 2 • Let the system be the archer with bow (particle • • • 1) and the arrow (particle 2) There are no external forces in the x-direction, so it is isolated in terms of momentum in the xdirection Total momentum before releasing the arrow is 0 The total momentum after releasing the arrow is p1f + p2f = 0 Archer Example, final • The archer will move in the opposite direction of the arrow after the release – Agrees with Newton’s Third Law • Because the archer is much more massive than the arrow, his acceleration and velocity will be much smaller than those of the arrow Overview: Collisions – Characteristics • We use the term collision to represent an event • • during which two particles come close to each other and interact by means of forces The time interval during which the velocity changes from its initial to final values is assumed to be short The interaction force is assumed to be much greater than any external forces present – This means the impulse approximation can be used What goes on during the collision? Force on m2 =F(12) Force on m1 =F(21) Collisions In general, a “collision” is an interaction in which • two objects strike one another • the net external impulse is zero or negligibly small (momentum is conserved) Examples: car crash; billiard balls Collisions can involve more than 2 objects Consider two particles: v2 v1 m1 m2 1 1 V1 2 2 V2 What about conservation of energy? The total energy of an isolated system is conserved, but the total kinetic energy may change. • elastic collisions: K is conserved • inelastic collisions: K is not conserved • perfectly inelastic: objects stick together after colliding Collisions – Example 1 • Collisions may be the • result of direct contact The impulsive forces may vary in time in complicated ways – This force is internal to the system • Momentum is conserved Perfectly Inelastic Collisions After a perfectly inelastic collision the two objects stick together and move with the same final velocity: pi = pf m1 v1,i + m2 v2,i = (m1+ m2)vf This gives the maximum possible loss of kinetic energy. In non-relativistic collisions, the total mass is conserved From the conservation of momentum: v1,i v1,f v2,i v2,f pi = pf m1v1,i + m2v2,i = m1v1,f + m2v2,f Perfectly Inelastic Collisions • Since the objects • stick together, they share the same velocity after the collision m1v1i + m2v2i = (m1 + m2) vf Elastic Collisions Kinetic energy is conserved and momentum is conserved: pi = pf m1 v1,i m2 v 2,i m1 v1, f m2 v 2, f Ki = Kf 1 1 1 1 2 2 2 m1v1,i m2v2,i m1v1, f m2 v22, f 2 2 2 2 Elastic Collisions • Both momentum and kinetic energy are conserved m1v1i m2 v 2i m1v1 f m2 v 2 f 1 1 2 m1v1i m2 v 22i 2 2 1 1 2 m1v1 f m2 v 22 f 2 2 Elastic Collisions in 1dimension Kinetic energy is conserved in addition to momentum: m1v1,i m2 v2,i m1v1, f m2 v2, f pi = pf m1 v1,i v1, f m2 v2, f v2,i 1 1 1 1 m1v12,i m2 v22,i m1v12, f m2 v22, f 2 2 2 2 Ki = Kf m1 v12,i v12, f m2 v22, f v22,i m1 v1,i v1, f v1,i v1, f m2 v2, f v2,i v2, f v2,i Divide : v 1, i v1, f v2, f v2,i v1,i v2,i v2, f v1, f Relative velocity of approach before collision = relative velocity of separation after collision ***Inelastic head-on collision between a car and a truck… A 3000-kg truck moving with a velocity of 20 m/s rearends a 1000-kg parked car. The impact causes the 1000-kg car to be set in motion at 15 m/s. Are the two vehicles stuck together after the collision? ***The animation below portrays the elastic collision between a 1000-kg car and a 3000-kg truck. Two Dimensional Collisions Do you know how to play pool? Rebound • When objects/bodies separate (move apart) after a collision or impact occurs. • Angle of incidence and angle of reflection/rebound measured with respect to the vertical. • Coefficient of elasticity/restitution refers to the degree (amount) of recoil/bounce that objects have. The greater the bounce the greater the coefficient (value between 0 and 1) with 0 signifying a completely inelastic object and 1 signifying a completely elastic object. • Affected by temperature and rebounding surface. Heat causes balls to bounce more while artificial turf also will cause a greater bounce. Angle of Reflection/Rebound Incidence Rebound A 3.00-kg steel ball strikes a wall with a speed of 10.0 m/s at an angle of 60.0° with the surface. It bounces off with the same speed and angle (Fig. P9.9). If the ball is in contact with the wall for 0.200 s, what is the average force exerted on the ball by the wall? Two-Dimensional Collisions • The momentum is conserved in all directions • Use subscripts for – identifying the object – indicating initial or final values – the velocity components • If the collision is elastic, use conservation of kinetic energy as a second equation – Remember, the simpler equation can only be used for one-dimensional situations Two-Dimensional Collision, example • Particle 1 is moving at • • velocity v1i and particle 2 is at rest In the x-direction, the initial momentum is m1v1i In the y-direction, the initial momentum is 0 Two-Dimensional Collision, example cont • After the collision, the • momentum in the xdirection is m1v1f cos q + m2v2f cos f After the collision, the momentum in the ydirection is m1v1f sin q + m2v2f sin f Two-Dimensional Collision Example • Before the collision, • the car has the total momentum in the xdirection and the van has the total momentum in the ydirection After the collision, both have x- and ycomponents Elastic Collisions Involving an Angle • Momentum is conserved in both the xdirection and in the y-direction. • Before: v 1 x v 1 cos 1 positive v 1y v 1 sin 1 negative v 2 x v 2 cos 2 positive v 2 y v 2 sin 2 positive Elastic Collisions Involving an Angle • After: v1x ' v1 ' cos θ 3 positive v1y ' v1 ' sin θ 3 positive v 2 x ' v 2 ' cos θ 4 positive v 2 y ' v 2 ' sin θ 4 negative Elastic Collisions Involving an Angle • Directions for the velocities before and after the collision must include the positive or negative sign. • The direction of the x-components for v1 and v2 do not change and therefore remain positive. • The directions of the y-components for v1 and v2 do change and therefore one velocity is positive and the other velocity is negative. Elastic Collisions Involving an Angle • px before = px after m1 v1x m2 v 2 x m1 v1x 'm2 v 2 x ' • py before = py after m1 v1y m2 v 2 y m1 v1y 'm2 v 2 y ' • Velocity after collision: 2 v1 ' v1x ' v1 y ' 2 v 2 ' v 2 x '2 v 2 y ' 2 Elastic Collisions • Perfectly elastic collisions do not have to be head-on. • Particles can divide or break apart. • Example: nuclear decay (nucleus of an element emits an alpha particle and becomes a different element with less mass) Elastic Collisions mn v n mn mp v n 'mp v p • • • • • mn = mass of nucleus mp = mass of alpha particle vn = velocity of nucleus before event vn’ = velocity of nucleus after event vp = velocity of particle after event Head-on and Glancing Collisions • Head-on collisions occur when all of the motion, before and after the collision, is along one straight line. • Glancing collisions involve an angle. • A vector diagram can be used to represent the momentum for a glancing collision. Vector Diagrams • Use the three vectors and construct a triangle. Vector Diagrams mB v B m A v A • sin 115 sin30 mB v B sin 115 Use the appropriate mB v B ' expression to determine the sin 35 unknown variable. mR v R mB v B ' sin 30 sin 35 Vector Diagrams • Total vector momentum is conserved. You • • could break each momentum vector into an x and y component. px before = px after py before = py after You would use the x and y components to determine the resultant momentum for the object in question Resultant momentum = 2 px py 2 Vector Diagrams • Right triangle trigonometry can be used to solve this type of problem: Vector Diagrams • Pythagorean theorem: ma va 2 mb vb ma mb v T 2 2 • If the angle for the direction in which the cars go in after the collision is known, you can use sin, cos, or tan to determine the unknown quantity. Example: determine final velocity vT if the angle is 25°. ma v a sin 25 ma m b v T mb v b cos 25 ma m b v T Vector Diagrams • To determine the angle at which the cars go off together after the impact: 1 ma va θ tan mb v b Special Condition • When a moving ball strikes a stationary ball of equal mass in a glancing collision, the two balls move away from each other at right angles. • ma = mb • va = 0 m/s Special Condition • Use the three vectors to construct a triangle. Special Condition mB v B m A v A • Use the sin 90 sin 50 appropriate mB v B mB v B ' expression to determine the sin 90 sin 40 m A v A ' mB v B ' sin 50 sin 40 unknown variable. Elastic Collision Example • Example: mass 1 and mass 2 collide • and bounce off of each other Momentum equation: m1 v1 m2 v 2 m1 v1'm2 v 2 ' • Kinetic energy equation: 0.5 m1 v12 0.5 m2 v22 0.5 m1 v1' 2 0.5 m2 v2 ' 2 v1 and v2 = velocities before collision v1 and v2 = velocities after collision • Velocities are + or – to indicate directions. Elastic Collision Example • Working with kinetic energy: 0.5 m1 v12 0.5 m2 v22 0.5 m1 v1'2 0.5 m2 v2 '2 • 0.5 cancels out. m1 v12 m2 v 22 m1 v1'2 m2 v 2 '2 m1 v12 m1 v1'2 m2 v 2 '2 m2 v 22 m1 2 v1 2 v1' 2 m v ' v 2 2 v 2 ' v 2 m1 2 m2 v1 v1'2 2 2 2 2 Elastic Collision Example • The velocity terms are perfect squares and can be factored: a2-b2 = (a – b)·(a + b) v 2 ' v 2 v 2 ' v 2 m1 m 2 v1 v1 ' v1 v1 ' • We will use this equation later. Elastic Collision Example • Momentum equation: m1 v1 m2 v 2 m1 v1'm2 v 2 ' m1 v1 m1 v1' m2 v 2 'm2 v 2 m1 v1 v1' m2 v 2 'v 2 v 2 'v 2 m1 m2 v1 v1' Elastic Collision Example • Both the kinetic energy and momentum • equations have been solved for the ratio of m1/m2. Set m1/m2 for kinetic energy equal to m1/m2 for momentum: v 2 'v 2 v 2 ' v 2 v 2 'v 2 v1 v1' v1 v1' v1 v1' Elastic Collision Example • Get all the v1 terms together and all the v2 terms together: v 2 'v 2 v 2 ' v 2 v1 v1' v1 v1' v 2 ' v 2 v1 v1 ' • Cancel the like terms: v 2 ' v 2 v1 v1' Elastic Collision Example • Rearrange to get the initial and final velocities back together on the same side of the equation: v 2 v1 v1'v 2 ' • This equation can be solved for one of the two unknowns, then substituted back into the conservation of momentum equation. Collision response: kinematic v(ti 1 ) v(ti ) N v(ti ) k ( N v(ti )) v(ti ) N v(ti ) v(ti ) N N v(ti ) v(ti ) (1 k ) N v(ti ) k – damping factor =1 indicates no energy loss Negate component of velocity in direction of normal No forces involved! Collision response – penalty method Collision reaction Coefficient of restitution v(ti 1 ) v(ti ) N v(ti ) k ( N v(ti )) v(ti ) N v(ti ) N v(ti ) N v(ti ) v(ti ) (1 k ) N v(ti ) k – coefficient of restitution But now want to add angular velocity contribution to separation velocity Impulse response A (t ) x A (t ) vB (t ) B (t ) xB (t ) v A (t ) How to compute the collision response of two rotating rigid objects? Impulse response Given Separation velocity is to be negative of colliding velocity Compute Impulse force that produces sum of linear and angular velocities that produce desired separation velocity Rigid body simulation Impulse force Separation velocity vrel vrel j ft A (t ) x A (t ) vB (t ) pA pB xB (t ) v A (t ) B (t ) Update linear and angular velocities as a result of impulse force A (t ) vA vA vB vB jn MA jn MB 1 A A I A (t )(rA jn) B B I B 1 (t )(rB jn) x A (t ) vB (t ) pA pB xB (t ) v A (t ) B (t ) Velocities of points of contact A (t ) x A (t ) rA pA pB rA p A x A (t ) rB p B x B (t ) A (t ) p B (t )) n vrel ( p A (t ) v A (t ) A (t ) rA p B (t ) v B (t ) B (t ) rB p vB (t ) rB xB (t ) v A (t ) B (t )