You are on page 1of 68

Chapter 12:

Mechanics 2: Linear & Rotational Dynamics


Fletcher Dunn
Valve Software

Ian Parberry
University of North Texas

3D Math Primer for Graphics & Game Development

What You ll !ee in "his Chapter


"his chapter consi#ers the cause o$ motion% its orientation% an# ho& &e mi'ht 'o about simulatin' it on a computer( It is #i)i#e# into si* sections( !ection 12(1 'i)es an o)er)ie& o$ +e&ton s , la&s( !ection 12(2 tal-s about the cause o$ motion: the $orce( !ection 12(, intro#uces momentum( !ection 12(. loo-s at collisions an# impulse( !ection 12(/ is about rotational #ynamics( !ection 12(0 #iscusses #i'ital simulation o$ mechanics(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

Wor# Clou#

Chapter 11 +otes

,D Math Primer $or 1raphics & 1ame De)

!ection 12(1:

+e&ton s , La&s

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

!ir Isaac +e&ton


!ir Isaac +e&ton establishe# three simple la&s that pro)i#e a $rame&or-% &hich &e call Newtonian or classical mechanics( It #oesn t hol# at hi'h spee#s or small #istances% but it s 'oo# enou'h $or e)ery#ay li$e% an# )i#eo 'ames( 2Ima'e $rom Wi-ime#ia Commons(3

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

+e&ton s First La&

4)ery bo#y persists in its state o$ bein' at rest or o$ mo)in' uni$ormly strai'ht $or&ar#% e*cept inso$ar as it is compelle# to chan'e its state by $orce impresse#(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

+e&ton s !econ# La&


"he acceleration o$ a bo#y is proportional to 2an# in the same #irection as3 the net e*ternal $orce actin' on the bo#y% an# in)ersely proportional to the mass o$ the bo#y:
(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

"he Force
Force is a )ector( It has units li-e -'(m6sec2% also calle# a Newton( 7Duct tape is li-e the $orce( It has a li'ht si#e% a #ar- si#e% an# it hol#s the uni)erse to'ether(8 2Carl 9&an:i'3

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

Free <o#y Dia'ram


!tartin' &ith a representation o$ the ob=ect( 1( Dra& an# label all the $orces actin' on it( 2( !um those $orces 2usin' )ector a##ition3 to compute the net $orce( ,( >se +e&ton?s 2n# la& to compute the acceleration o$ the ob=ect( .( Inte'rate the acceleration to #etermine the motion o$ the ob=ect(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) @

Di$$erential 4Auations
When sol)in' problems analytically% this means sol)in' #i$$erential eAuations( We #on?t use any #i$$erential eAuations in this boo- because there are only a $e& simple cases that &e &ill loo- at analytically( +umerical metho#s o$ inte'ration must be use#( Later% &e e*amine 4uler inte'ration% &hich is the most simple metho# ima'inable% but also the one use# by most realBtime ri'i# bo#y simulators(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) 1C

Inertial Re$erence Frames


"his only &or-s in a re$erence $rame that is not acceleratin'( You ha)e to in)ent $ictional $orces to e*plain &hy ob=ects are not acceleratin' accor#in' to +e&ton s 1st an# 2n# la&s( D robot in a $allin' ele)ator is in a noninertial $rame( Ee must in)ent a $ictitious up&ar# $orce to counteract 'ra)ity to e*plain &hy his herrin' san#&ich #oesn t $all(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

11

"o a passin' alien &ho is not acceleratin'% +e&ton s la&s &or- =ust $ine% an# there is no nee# to in)ent a $ictional $orce(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) 12

+e&ton s "hir# La&

"o e)ery action there is al&ays an eAual an# opposite reaction( Fr% the $orces o$ t&o bo#ies on each other are al&ays eAual an# are #irecte# in opposite #irections(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

1,

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

1.

4*ample
"here are $our $orces here( 1( Moe pushin' the bo*( 2( "he bo* pushin' Moe( ,( Moe pushin' the 4arth( .( "he 4arth pushin' Moe( +ote that an# cancel out(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

1/

ConseAuence o$ +e&ton s ,r# La&


Ds lon' as the internal $orces cancel out% &e are =usti$ie# in representin' a comple* bo#y by a sin'le point or particle( "his is calle# rigi !o y ynamics(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

10

!ection 12(2:

!ome !imple Force La&s

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

15

1ra)ity in the Real Worl#


+e&ton s La& o$ >ni)ersal 1ra)itation: &here is the ma'nitu#e o$ the $orce% an# are the masses o$ the t&o ob=ects% an# is the #istance bet&een their centers o$ mass% an# (

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

1;

Gi#eo 1ame 1ra)ity


% &here (

"his is not physically accurate% but then a'ain% neither is bein' able to =ump t&o or three times your o&n hei'ht% steer in mi#air% or #ouble =ump( When it comes to =umpin' in )i#eo 'ames% reality is not =ust o)errate#% it?s completely i'nore#( It =ust #oesn?t $eel ri'ht(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

1@

Gi#eo 1ame 1ra)ity


In most $irstBperson shooters% &hen you =ump% you are 'i)en an initial burst o$ up&ar# )elocity% an# then your position is simulate# =ust li-e e)ery other airborne ob=ect in the &orl#( In most thir#Bperson 'ames your character &ill sprin' up almost instantaneously an# reach a ma*imum hei'ht )ery Auic-ly( In many 'ames the character &ill ho)er there% then slam bac- #o&n on the 'roun# as Auic-ly as it rose up% perhaps lea)in' a crater behin#(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

2C

Gi#eo 1ame 1ra)ity


!imulatin' a =ump mechanic usin' a )alue o$ may be e)en &orse% because most players e*pect a =ump to ta-e a certain amount o$ time but also e*pect to be capable o$ =umpin' to unrealistic hei'hts(

When realB&orl# 'ra)ity is use# to attain these hei'hts% the player is in the air too lon'% an# it $eels 7$loaty8( Many arca#e racin' 'ames increase 'ra)ity to 'et the car bac- on the 'roun# Auic-ly( "he player &ants to be in $ull control a'ain as Auic-ly as possible% an# &aitin' $or realB&orl# 'ra)ity to 'et them bac- #o&n usually ta-es too lon'( "here are other racin' 'ames that use a )alue o$ 'ra)ity that is less than the real &orl# )alue% to $acilitate unrealistic =umps at realistic )ehicle spee#s(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

21

Gi#eo 1ame 1ra)ity


"here are also reasons to $i##le &ith 'ra)ity $or nonBplayerBcharacter ob=ects as &ell( !ometimes realB&orl# 'ra)ity can create an 7ob=ects ma#e o$ styro$oam8 $eelin'% so 'ra)ity is increase# to 'et an ob=ect to tip o)er an# come to rest more Auic-ly( In other situations% an arti$icially lo& )alue o$ 'ra)ity can ma-e a lar'e ob=ect seem e)en more massi)e 2especially &hen accompanie# by the ri'ht soun# e$$ects3% because acceleration on 4arth is constant an# is one o$ a $e& cues humans instincti)ely use to establish an absolute scale $or ob=ects in the #istance(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

22

Realism )ersus 4ntertainment


What 7$eels ri'htH is a sub=ecti)e matter( It is base# more on player e*pectation than physical reality( In the en#% &hat matters most in a )i#eo 'ame is not &hat?s 'oin' on in the CP> or e)en on the screen% but &hat is 'oin' on in the player?s min#( "he human min# is hi'hly susceptible to su''estion( "he Auest $or realism shoul# ne)er be an en# unto itsel$( D success$ul )i#eo 'ame &ill harness realism only &here it ser)es the ultimate 'oal% &hich is entertainment(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

2,

Friction
"he stan#ar# #ry $riction mo#el is sometimes calle# "o#lom! friction( CharlesBDu'ustin #e Coulomb 215,0B1;C03( 2Ima'e $rom Wi-ime#ia Commons(3
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) 2.

!tatic Friction
When an ob=ect is at rest on top o$ another ob=ect% a certain amount o$ $orce is reAuire# to 'et it unstuc- an# set it in motion( I$ any less $orce is applie#% the $orce o$ $riction &ill push bac- &ith a counteractin' $orce up to some ma*imum amount( "his is calle# static friction(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) 2/

!tatic Friction
"he $ollo&in' eAuation is a 'oo# appro*imation $or the ma*imum ma'nitu#e o$ static $riction: (
is a constant calle# the coefficient of static friction that #epen#s on the type o$ sur$aces rubbin' to'ether( Iust loo- it up in a table( is the ma'nitu#e o$ the normal $orce(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) 20

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

25

"he +ormal Force


"he normal force is the $orce actin' perpen#icular to the sur$aces that pre)ent them $rom o)erlappin'( For e*ample% &hen an ob=ect 2such as a bo&l o$ petunias3 is restin' on top o$ another ob=ect 2such as a table3% the normal $orce is the $orce reAuire# to counteract 'ra)ity( It is the $orce reAuire# to counteract the component o$ 'ra)ity that acts perpen#icular to the sur$aces(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

2;

+ormal an# Lateral Components


I$ the table is at an incline% then &e can separate 'ra)ity into a normal component an# a lateral component( Insi#e a computer% &e #escribe the orientation o$ the table &ith a normal )ector% an# use the #ot pro#uct to separate 'ra)ity into the relati)e an# normal components( !ince the bo&l an# the table #o not accelerate relati)e to each other% &e -no& that the normal $orce o$ the table pushin' a'ainst the bo&l must be e*actly eAual to the normal component o$ the $orce o$ 'ra)ity pullin' the bo&l to&ar#s the table(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

2@

+ot !li#in'

Fn the <rin-

!li#in'

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,C

Jinetic Friction
Fnce static $riction is o)ercome an# the ob=ect is mo)in'% $riction continues to push a'ainst the relati)e motion o$ the t&o sur$aces( "his is calle# $inetic friction( "he ma'nitu#e -inetic $riction is 'enerally less than that o$ static $riction( It s compute# the same &ay o$ static $riction: (

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,1

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,2

Coulomb s La& o$ Friction


"he #irection o$ the $orce o$ -inetic $riction is al&ays oppose# to the relati)e motion o$ the sur$aces( Ds &e sai# earlier% the coe$$icient o$ -inetic $riction is usually less than the coe$$icient o$ static $riction( "hus% i$ &e increase the an'le o$ the table slo&ly so that static $riction is =ust o)ercome% the petunias &ill be'in to accelerate( Coulomb?s primary contribution to the theory% sometimes calle# "o#lom!%s law of friction% &as that the $orce o$ -inetic $riction #oes not #epen# on the relati)e )elocities o$ the sur$aces(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,,

!prin' Forces
4)en i$ you #on?t see )ery many actual sprin's in a )i#eo 'ame% there are li-ely )ery many )irtual sprin's at &or-( !prin's e*hibit a 'eneral beha)ior that is )ery use$ul $or en$orcin' constraints% $or e*ample% pre)entin' ob=ects $rom o)erlappin'% cloth ren#erin'% an# ra'B #oll character animation(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) ,.

Control !ystems
"here are t&o types o$ sprin' motion% ampe oscillation an# #n ampe oscillation( D )irtual sprin' 2o$ten in the $orm o$ a sprin'B#amper system3 is a type o$ control system( "here are certain a#)anta'es to be ha# &hen the physical nature o$ the problem is #roppe# an# &e thin- o$ it purely in mathematical terms( In#ee#% many times the problem &as ne)er really physical to be'in &ith% an# &as only recast in physical terms so that the sprin'B#amper apparatus coul# be applie#(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) ,/

"he Rest Len'th


Consi#er a sprin' &ith one en# $i*e# an# the other en# $ree to mo)e in one #imension( When the sprin' is at eAuilibrium &ith no e*ternal $orces on it% it has a natural len'th% calle# the rest length( I$ &e stretch the sprin'% then it &ill pull bac- to try to re'ain its rest len'th( Li-e&ise% i$ &e compress the sprin'% it &ill push bac-(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,0

Rest len'th Compress !tretc h

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,5

Eoo-e s La&
Robert Eoo-e 210,/ K15C,3( 2Ima'e $rom Wi-ime#ia Commons(3 "he ma'nitu#e o$ the restorati)e $orce is proportional to the #istance $rom the rest len'th 2pro)i#e# the $orce #oes not e*cee# the elastic limit o$ the material use# to construct the sprin'3(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,;

Eoo-e s La&
Where is the spring constant that #escribes ho& sti$$ the sprin' is% is the sprin' s rest len'th% an# is the len'th that the sprin' has been stretche# or compresse# to(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

,@

Re&ritin' Eoo-e s La&


"hin's 'et easier i$ &e a#opt a re$erence $rame &here the position * L C #esi'nates the rest position% in &hich the sprin' has its rest len'th an# there are no restorati)e $orces(
Let !ince contains both the sprin' constant an# the mass o$ the particle % it measures the sprin'?s ability to accelerate a particle at its en#(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) .C

Re&ritin' Eoo-e s La&


With those notational chan'es% &e can re&rite Eoo-e s La& as % &here is acceleration as a $unction o$ time an# is position as a $unction o$ time( "his is calle# a ifferential e&#ation% since it is an eAuation in both position an# its secon# #eri)ati)e% acceleration (

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

.1

!ol)in' Di$$erential 4Auations


We #on t ha)e the tools to sol)e 'eneral #i$$erential eAuations% but this one is not too har#( I$ &e 'rab a sprin' an# e*perimentally 'raph the position o$ its en# as a $unction o$ time a$ter compression% &e 'et a 'raph li-e this:

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

.2

!ol)in' Fur Di$$erential 4Auation


"his $unction ou'ht to loo- $amiliar to you: it?s the 'raph o$ the cosine $unction( Let?s see &hat happens i$ &e =ust try as our position $unction( Di$$erentiatin' t&ice to 'et the )elocity an# acceleration $unctions% &e 'et:

&hich is close% but &e?re missin' the $actor o$ (


Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) .,

Does MatterM
"o un#erstan# &here shoul# appear in % consi#er &hat happens to the 'raph o$ &hen &e chan'e the )alue o$ ( In other &or#s% &e repeat our physical e*periment an# )ary the sti$$ness o$ the sprin'( "he result is that lar'er )alues o$ 2sti$$er sprin's3 result in a 'raph that is hori:ontally compresse#: the $reAuency o$ oscillation is increase#( Li-e&ise% smaller )alues o$ J cause the sprin' to oscillate more slo&ly% an# the 'raph is e*pan#e#(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

..

Eo& Much Does MatterM


Furthermore% &e obser)e that the $reAuency is proportional to the sAuare root o$ ( For e*ample% &hen &e increase by a $actor o$ $our% the $reAuency #oubles( "his 'i)es us a hint as to &here shoul# appear% since all &e are #oin' is scalin' the time a*is(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

./

Dn'ular FreAuency
"he Auantity is calle# the ang#lar fre&#ency an# comes up o$ten enou'h that &e $in# it help$ul to intro#uce the notation L an# &e can &rite the solution as

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

.0

"hree More De'rees o$ Free#om


"here are some #e'rees o$ $ree#om inherent in the motion o$ the sprin' that &e ha)e not accounte# $or( 1( We are not accountin' $or the ma*imum #isplacement% -no&n as the amplit# e o$ the oscillations an# #enote# ( Fur eAuation al&ays has an amplitu#e o$ 1( 2( We are assumin' that % meanin' the sprin' &as initially stretche# to the ma*imum #isplacement an# release# &ith :ero initial )elocity( Eo&e)er% in 'eneral% &e coul# ha)e pulle# it to #isplacement an# then 'i)en it a sho)e so it has initial )elocity (

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

.5

"he "hree are "&o


It &oul# appear that &e ha)e three more )ariables that nee# to be accounte# $or in our eAuation i$ it is 'oin' to be completely 'eneral(

Ds it turns out% the three )ariables &e ha)e =ust #iscusse# 2the amplitu#e% initial position% an# initial )elocity3 are interrelate#( I$ &e pic- any t&o% the )alue $or the thir# is $i*e#( We?ll -eep as is% but &e?ll replace an# &ith the phase offset % &hich #escribes &here in the cycle the sprin' is at ( D#=ustments to the phase o$$set ha)e the simple e$$ect o$ shi$tin' the 'raph hori:ontally on the time a*is(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

.;

!imple Earmonic Motion


D##in' these t&o )ariables% &e arri)e at the 'eneral solution% the eAuations o$ simple harmonic oscillation:

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

.@

Dampin' Forces
!o $ar% &e ha)e been stu#yin' a physically none*istent situation in &hich the sprin' &ill oscillate $ore)er( In reality% there are usually at least t&o more interestin' $orces% riving force an# friction( "he riving force is an e*ternal $orce% that acts as the input to the system an# causes the motion to be'in( 'riction &e ha)e alrea#y met( "he 'eneral term use# to #escribe any e$$ect that ten#s to re#uce the amplitu#e o$ an oscillatory system is amping% an# &e call oscillation &here the amplitu#e #ecays o)er time ampe oscillation( Dampin' $orces are use$ul in )i#eo 'ames% so let?s #iscuss them in more #etail(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

/C

Dampin' Force
"he #ampin' $orce is simply % &here in#icates the instantaneous ma'nitu#e an# #irection o$ the #ampin' $orce% is the instantaneous )elocity% an# is a constant that #escribes physical con#itions such as the )iscosity% rou'hness% etc(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

/1

Nualitati)e Fbser)ations
"he #ampin' $orce has an e*tremely simple $orm% but thin's 'et interestin' &hen &e stu#y motion o)er time( Nualitati)ely% &e can ma-e some basic pre#ictions about ho& #ampe# oscillation o$ a sprin' &oul# #i$$er $rom un#ampe# oscillation o$ the same sprin'( "he more ob)ious pre#iction is that &e &oul# e*pect the amplitu#e o$ oscillation to #ecay o)er time( Li-e the $orce o$ $riction% #ampin' remo)es ener'y $rom the system( "he secon# obser)ation is only sli'htly less ob)ious: !ince #ampin' in 'eneral slo&s the )elocity o$ the mass on the en# o$ the sprin'% &e &oul# e*pect the $reAuency o$ oscillation to be re#uce# compare# to un#ampe# oscillation( "hose t&o intuiti)e pre#ictions turn out to be correct% althou'h% o$ course% to be more speci$ic &e &ill nee# to analy:e the math(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) /2

Earmonic Motion &ith Dampin' Forces


Combinin' the restorati)e an# #ampin' $orces% the net $orce can be &ritten as ( "o #eri)e the eAuation o$ motion% &e &ill nee# accelerations% not $orces( Dpplyin' +e&ton?s !econ# La& an# #i)i#in' both si#es by the mass% &e ha)e:
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) /,

!prin'BDamper !ystems in Gi#eo 1ames


!prin'B#amper systems are use# in )i#eo 'ames as control systems( D control system ta-es as input a $unction o$ time that represents some tar'et )alue( For e*ample: 1( Camera co#e mi'ht compute a #esire# camera position base# on the player?s position each $rameO 2( DI co#e mi'ht #etermine an e*act tar'etin' an'le $or an enemyO ,( We may ha)e a #esire# player character )elocity base# on the instantaneous amount o$ control stic- #e$lectionO .( We mi'ht ha)e a #esire# screenBspace position $or some hi'hli'ht e$$ect% base# on the currently selecte# choice in a menu(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

/.

"he !et Point


"he current )alue o$ the input si'nal is -no&n as the set point in control system terminolo'y( "he set point is essentially the rest position o$ the sprin'% an# the input si'nal is li-e somebo#y ta-in' the other en# o$ the sprin' an# yan-in' it aroun#( It is similar to a #ri)in' $orce% but &e are 'i)en a $unction #escribin' a position rather than a $orce or acceleration(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

//

What Does a Control !ystem DoM


"he =ob o$ any control system is to ta-e this input si'nal an# pro#uce an output si'nal( >sin' our e*amples $rom 2 sli#es a'o% the output si'nal mi'ht be 2respecti)ely3: 1( "he camera position to use $or each $rame 2( "he animate# tar'etin' an'le the enemy &ill use to aim the &eapon% ,( "he player character )elocity( .( "he screenBspace position o$ the hi'hli'ht(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) /0

+o Ier-s Dllo&e#
For many control systems% the actual position an# set point are not use#O rather% only the error is nee#e#( F$ course% an ob)ious Auestion is% i$ &e -no& the #esire# )alue% &hy #on?t &e =ust use that #irectlyM <ecause it?s too =er-y( In the same &ay that the shoc-s an# sprin's on a car #on?t =ust pass alon' the ele)ation o$ the roa# #irectly to the car% a control system in a )i#eo 'ame is o$ten #esi'ne# to smooth out the bumps cause# by su##en state chan'es that mi'ht ma-e the camera snap to a ne& position or the player =er- into motion(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

/5

PD Controllers
"he camera or screenBspace hi'hli'ht are nonphysical e*amples in &hich the Auantity o$ mass is not really appropriate an# is #roppe#( <ut the #i$$erential eAuations are still the same% an# they ha)e the same solution( !trippe# o$ the sprin' metaphor% &e are le$t &ith &hat is -no&n as a PD controller( "he P stan#s $or proportional% an# this is the sprin' part o$ the controller% since it is proportional to the current error( "he #amper is the D part% &hich stan#s $or #eri)ati)e% because the action o$ the #amper at any 'i)en instant is proportional to the #eri)ati)e 2the )elocity3(
Chapter 12 +otes ,D Math Primer $or 1raphics & 1ame De) /;

Don t Rein)ent the Wheel 2Fr the !prin'3


PD controllers 2an# their more robust cousin% the PID controller% &here the I stan#s $or inte'ral an# is use# to remo)e stea#yBstate error3 are broa#ly applicable tools( "hey ha)e been stan#ar# en'ineerin' tools $or #eca#es 2centuriesM3 an# are &ell un#erstoo#( +e)ertheless% they are one o$ the most $reAuently rein)ente# &heels in )i#eo 'ame pro'rammin'(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

/@

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

0C

"unin'
Di$$erent cars ha)e suspensions that are tune# #i$$erentlyO sports cars are ti'hter an# the cars retirees li-e to #ri)e are smoother( In the same &ay% &e tune our control systems to 'et the response &e li-e(

+otice that the co#e uses the an# $rom our earlier eAuations( Eo&e)er% most people #on?t $in# those to be the most intuiti)e #ials to ha)e $or t&ea-in'( Instea#% the #ampin' ratio an# $reAuency o$ oscillation are use# $or the #esi'ner inter$ace% &hile an# are compute# as #eri)e# Auantities( "o tune the $reAuency% &e mi'ht a#=ust either the #ampe# or un#ampe# )ersion% usin' either an'ular $reAuency or simply Eert:O the units an# absolute )alue are o$ten not important because the )alue that $eels 'oo# &ill be #etermine# e*perimentally any&ay(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

01

Dlternati)es an# 1enerali:ations


"he secon#Bor#er systems &e ha)e #escribe# here are certainly not the only type o$ control system% nor e)en the simplest% but they #o beha)e nicely un#er a )ery broa# set o$ circumstances an# are easy to implement an# tune(

Dnother commonly use# control system is a simple $irst or#er la'% % un#er &hich the error #ecays e*ponentially( "his is similar to a critically #ampe# secon#Bor#er system% but &ith a bit =er-ier response to a su##en chan'e in the set point( Dnother common techniAue is to chase the set point at a $i*e# )elocity( D $ilter is another broa# class o$ control system in &hich the output is compute# by ta-in' some linear combination o$ set points or )alues on pre)ious $rames(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

02

!ection 12(,:

Momentum

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

0,

Moe s <o*
!uppose Moe?s bo* has mass % an# at a certain instant &e obser)e it mo)in' &ith a )elocity (

Comin' in late to the story% &e cannot tell &hat ma'nitu#e o$ $orces &ere use# to achie)e that motion% or ho& lon' the $orces &ere applie#% or &hat the history o$ the bo*?s )elocity &as(

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

0.

!ection 12(.:

Impulsi)e Forces an# Collisions

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

0/

!ection 12(/:

Rotational Dynamics

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

00

!ection 12(0:

RealB"ime Ri'i# <o#y !imulators

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

05

"hat conclu#es Chapter 12( +e*t% Chapter 1,:

Cur)es in ,D

Chapter 12 +otes

,D Math Primer $or 1raphics & 1ame De)

0;

You might also like