Computer Animation 8-Collisions SS 13

16
Computer Animation 8-Collisions SS 13 Prof. Dr. Charles A. Wüthrich, Fakultät Medien, Medieninformatik Bauhaus-Universität Weimar caw AT medien.uni-weimar.de

Transcript of Computer Animation 8-Collisions SS 13

Page 1: Computer Animation 8-Collisions SS 13

Computer Animation8-Collisions

SS 13

Prof. Dr. Charles A. Wüthrich,Fakultät Medien, MedieninformatikBauhaus-Universität Weimarcaw AT medien.uni-weimar.de

Page 2: Computer Animation 8-Collisions SS 13

Collisions

• When objects start to move,they actually collide

• Two issues must be addressed:– Detecting collision– Computing appropriate

response• Detecting collision: two main

approaches– Penalty method: calculate the

reaction after collision hasoccurred

• when more particles involved,assume they collided at sameinstant

• Imprecise but often acceptable

– Back up time to first instantof collision and computeappropriate response

• By heavy no of collisions,quite time consuming

• Computing the appropriateresponse to collision(depends on physics anddistribution of mass of theobject)– Kinematic response– Penalty method: introduce a

nonphysical force to restorenon penetration butcompute it at time ofcollision

– Calculation of impulse force

Page 3: Computer Animation 8-Collisions SS 13

Kinematic response

• A simple case is a particle movingat constant velocity and impacting aplane

• Questions:– When is the impact?– How does it bounce off?

• Use plane equationE(p): ax+by+cz+d

• If normals correct, then– If E(p)=0 then p plane point– If E(p)>0 then p above plane– If E(p)<0 then below plane

• The particle moves with equations: p(ti)=p(ti-1)+t ⋅ vave(t)

• When E(p(ti)) switches to ≤0then we had a collision

• Now the component of thevelocity parallel to the normal tothe plane is negated

• Some damping factor N isaddedv(ti+1)=v(ti)-v(ti)N-kv(ti)N=v(ti)-(1+k)v(ti)N

E(p)>0

E(p)=0

E(p)<0

Page 4: Computer Animation 8-Collisions SS 13

Penalty method

• Here we construct a reaction tothe collision

• A spring with zero rest length isattached at the instant ofcollision

• The closest point on the surfaceto the penetrating point is usedas attachment point

• The spring obeys Hooke‘s law:F=-kd

• The approach needs to assignarbitrary masses and constant,and therefore is not ideal

• Moreover, for fast movingpoints it might take a fewsteps to push back the obj

• For polyhedra, it might alsogenerate torque

p(ti)

p(ti+1)

d force

Page 5: Computer Animation 8-Collisions SS 13

Polyhedras colliding

• Shape can be complicated forcomplex objects

• Thus, collisions can be testedbefore on bounding boxes

• Or by adding hierarchical boundingboxes

• Testing a point to be inside apolyhedron is not easy

• But for a polyhedron one needs totest all vertices for the two objects

• And each point has to be testedagainst all the planes of the faces ofthe polyhedron

• This works only for convexpolyhedra

• For concave polyhedra, one canuse a similar method to the point inpolygon test

• Construct a semi-infinite ray fromthe point towards the polyhedron,and check no of intersections

– If they are even, then the point isoutside

– If they are odd, then it lies inside• Of course correct counting double

points has to be done• In some cases, for solids of simple

shape and moving with an easymovement, the volume of it can beswept along its trajectory

Page 6: Computer Animation 8-Collisions SS 13

Impulse force of collision

• To do accurate computations,time has to be backed to theinstant of collision

• Then the exact reaction can becomputed

• If a collision appeared betweenti and ti+1, then– recursive bisection of the time

step between these twotimepoints will eventually yeldthe exact time of the impact

– Alternatively, a linearapproximation of the velocitycan be used to simplify thecalculations

• At the time of the impact, thenormal component of the pointvelocity can be modified toreflect the bounce

• This normal can be multiplied bya scalar to model the degree ofelasticity of the impact

• This scalar is called coefficientof restitution

Page 7: Computer Animation 8-Collisions SS 13

Impulse forces

• Once the simulation is backedup to the time of the collision,the reaction can be computed

• By working back from thedesired change in velocity, therequired change in momentumcan be deduced

• This equation uses the a newterm, the impulse, expressed inunits of momentumJ=FΔt=MaΔt=MΔv= Δ(Mv)=ΔP

• J can be seen as a large forceacting in a short time interval

• This allows computing the newmomentum

• To characterize elasticity, thecoeff. of restitution, ε iscomputed (0≤ε≤1)

• The velocities along the normalbefore and after the impact arerelated by v+

rel=-εv-rel

Page 8: Computer Animation 8-Collisions SS 13

Impulse forces

• Assume that the collisions of thetwo objects A and B has beendetected at t

• Each obj Ob has position of masscenter xOb(t), lin. velocity vOb(t) andang. velocity ωOb(t)

• At the point of intersection, thenormal to the surface of contact isdetermined (note, it can be asurface, but also a point)

• Let rA and rB be the relativepositions of the contact points WRTthe center of mass

• Relative velocities of the contactpoints WRT center of mass and thevelocities of the contct points arecomputed as

• rA=pA-xA(t)rB=pB-xB(t)vrel=(pA°(t)-pB°(t))pA°(t)=vA(t)+ωA(t)×rApB°(t)=vB(t)+ωB(t)×rB

pApB

ωA(t)

ωB(t)

xB(t)

xA(t)

vA(t)

vB(t)

Page 9: Computer Animation 8-Collisions SS 13

Impulse forces

• Linear and angular velocities ofthe objects before the collisionvob

- ωob- are updated vob

+ ωob+

vA+=vA

-+jn/MA vB

+=vB-+jn/MB

ωA+=ωA

- +IA-1(t)(rA×j⋅n) ωB

+=ωB- +IB-1(t)(rB×j⋅n)

where the impulse J is a vectorquantity in the direction of thenormal J= j⋅n

• To find the impulse, thedifference between thevelocities of the contact pointsafter collision in the direction ofthe normal to the surface ofcollision is formed

• vrel+=n ⋅(p°A

+(t)-p°B+(t))

vrel+=n ⋅(vA

+(t)+ ωA(t)×rA - vB(t)+ωB(t)×rB)

• Substituting previous equationsone obtains

• Contact between two objects isdefined by the point on eachinvolved and the normal to thesurface of contact

• If the collision occurs, the eq.above is used to compute themagnitude of the impulse

• The impulse is then used toscale the contact normal, andupdate linear and angularmomenta

BBBAAABA

rel

rnrtIrnrtInMM

vj!!+!!"++

"+#=

##

+

)))((()))(((11))1((

11

$

Page 10: Computer Animation 8-Collisions SS 13

Friction

• An object resting on anotherone has a resting contact with it

• This apples a force due togravity which applies to bothobjects and can bedecomposed along thedirections parallel FPa to theresting surface and FNperpendicular to it

• The static friction force isproportional to FN: Fs=µsFN

• Once the object is moving, thereis a kinetic friction taking place.This friction creates a force,opposite to the direction oftravel, and again proportional tothe normal Fk=µkFN

Page 11: Computer Animation 8-Collisions SS 13

Resting contact

• It is difficult to compute forces due to the resting contact• For each contact point, there is a force normal to the surface of contact• All these forces have to be computed for all objects involved in resting

contact• For each contact point, a torque is also generated on it.• If bodies have to rest, all those forces and torques have to be zero• Solutions to this problem include quadratic programming, and are

beyond the scope of this course

Page 12: Computer Animation 8-Collisions SS 13

Constraints

• One problem occuring in animation is the fact that variables arenot free.

• Constraints are usually set on objects and limit the field of theindependent variables.

• There are two types of constraints:– hard constraints: strictly enforced– soft constraints: the system only attempts to satisfy them

Page 13: Computer Animation 8-Collisions SS 13

Flexible objects

• To simulate elastic objects,Spring-mass-damper model ismost used approach

• Springs: work with Hooke‘s law:the force applied isFi,j=-Fj,i=ks(di,j(t)-leni,j)vi,jwhere– dij distance between the two

points– lenij rest length of the spring– ks spring constant– vij unit vector from point i to

point j

• The flexible model is modelled as anet of points with mass and springsand dampers between them

• A damper can impart a force in thedirection opposite to the velocity ofthe spring length and proportional tothat velocity Fd

i=-kd vi(t)• One can also introduce angular

dampers and springs between faces• Additional internal springs have

often to be added to add stability tothe system

Page 14: Computer Animation 8-Collisions SS 13

Virtual springs

• Induce forces that do not directly model physical elements• For example, in the penalty method• Sometimes one can use a proportional derivative controller

which controls that a certain variable and speed is close to thedesired value

• For example, this is used to keep the object close to the desiredspeed

• A virtual spring is added to keep things as desired

Page 15: Computer Animation 8-Collisions SS 13

Energy minimization

• One can use energy to control the motion of the objects• Energy constraints can be used to pin objects together, to

restore the shape of an object, to minimize the curvature of apath or trajectory

• Energy constraints induce restoring forces on the system

Page 16: Computer Animation 8-Collisions SS 13

Charles A. Wüthrich

+++ Ende - The end - Finis - Fin - Fine +++ Ende - The end - Finis - Fin - Fine +++

End

Cop

yrig

ht (c

) 198

8 IL

M