CS 775: Advanced Computer Graphicsparagc/teaching/2019/cs775/lectures/05... · CS775: Lecture 5...
Transcript of CS 775: Advanced Computer Graphicsparagc/teaching/2019/cs775/lectures/05... · CS775: Lecture 5...
CS 775: Advanced Computer Graphics
Lecture 5 : Physically-Based Animation
CS775: Lecture 5
Physically-Based Animation● Given the state of a system,● Initial value problem
x= f (x , t)x x∼d xd t
x(t 0)=x0
The derivative function forms a vector field.
Start here
Follow the vectors.
http://www.pixar.com/companyinfo/research/pbm2001/
CS775: Lecture 5
Numerical SolutionsEuler’s method x(t 0+h)=x0+h x (t 0)
●Simplest method●Discrete stepsize●Bigger steps, bigger error
●Integral curves of 2D function are concentric circles.
●Drift caused by Euler’s method moves the particle on a spiral instead
f● ● Oscillates● Diverges
f=−k xh>1/kh>2/k
http://www.pixar.com/companyinfo/research/pbm2001/
CS775: Lecture 5
Numerical SolutionsEuler’s Method
x(t 0+h)=x0+h x (t 0)+h2
2 !x(t 0)+…+
hn
n!∂n x
∂ t n
Consider the Taylor series
Error in Euler’s method: O(h2)
h→h2
h→h2
ϵ→ ϵ4
ϵ
nsteps→2nsteps
For an interval t0 to t1
5
Explicit Euler - Stability● Let the derivative function be linear● Consider the x parallel to the largest eigenvector of A● Euler update● Solution● Stable when
● Real, negative eigenvalues● Imaginary eigenvalues
xn+1=xn+hλ xn
d xd t
=A x
d xd t
=λ x
xn=(1+hλ)n x0
|1+hλ|≤1⇒−1<1+hλ<1⇒h<2
|λ|
CS775: Lecture 5
Numerical SolutionsMid-point Method : Improving Euler
x(t 0+h)=x0+h x (t 0)+h2
2 !x(t 0)+O(h3
)
x=∂ f∂ xx=f ' f
f (x+Δ x)=f (x0)+Δ x f ' (x0)+O(Δ x2)
Now,
A Taylor series of the function f gives:
Substitute Δ x=h2f (x0)
x=f (x(t ))assuming
in the equation above, simplify, equations 1 and 2 give
x(t 0+h)=x0+h( f (x0+h2f (x0)))
- (1)
- (2)
CS775: Lecture 5
Numerical SolutionsMid-point Method
http://www.pixar.com/companyinfo/research/pbm2001/
a. Compute an Euler Step
b. Evaluate f at midpoint
c. Take a step using fmid
Δ x=h2f (x0)
f mid=f (x(t0)+Δ x2
)
x(t 0+h)=x(t 0)+h f mid
x(t 0+h)=x0+h( f (x0+h2f (x0)))
8
Midpoint Method - Stability● Midpoint update
● Let
● Then stable if
xn+1=(1+hλ+12(hλ)
2)xn
xn+1=xn+hλ xn+
12
xn+1=xn+hλ (xn+12hλ xn)
hλ=a+i b
(1+a+12(a2
−b2))
2
+(b+ab)2≤1
CS775: Lecture 5
Numerical SolutionsRunge-Kutta of Order 4 (RK4)
k1=h f (x0, t0)
k2=h f (x0+k1
2, t 0+
h2)
k3=h f (x0+k2
2, t0+
h2)
k4=h f (x0+k3 , t0+h)
x(t 0+h)=x0+16k1+
16k3+
16k 3+
16k4
O(h5) error
10
Runge-Kutta Stability● q-stage, pth-order Runge-Kutta evaluates the derivative function q times in
each iteration and its approximation of the next state is correct within O(hp+1).● RK4 is 4-stage, 4th-order
RK3 RK4
CS775: Lecture 5
Particle Systems● Motion of the particle is governed by Newton’s laws of
motion.● Phase space equation of motion
● Every particle stores its position, velocity, mass and has a force accumulator.
● A particle system is just a collection of particles.
[ x1, x2, x3, v1, v2, v3]=[v1, v2, v3, f 1/m , f 2/m, f 3/m ]
CS775: Lecture 5
Particle SystemsTypes of forces:● Unary forces – gravity, drag.
● n-ary forces – springs connecting a set of particles.
f=m g f=−k d v
f a=−[k s(|l|−r )+kd l⋅l|l| ] l|l| f b=−f a
http://www.pixar.com/companyinfo/research/pbm2001/
CS775: Lecture 5
Particle SystemsTypes of forces:
● Spatial interaction forces – attraction, repulsion in a neighbourhood.
● Lennard-Jones : Pair of neutral atoms or molecules
V LJ=4 ϵ [(σr )12
−(σr )
6
]
Lennard-Jones Potential
CS775: Lecture 5
Particle Systems
● Blender Fire, Boids
● Reeves, 1983: Particle Systems – A Technique for Modeling Fuzzy Objects
“Genesis Effect” from Start Trek 2: The Wrath of Khan Video Clip from “Particle Dreams” by Karl Sims
CS775: Lecture 5
Particle Fluids
Saket Patkar, Parag Chaudhuri, Wetting of Porous Solids, IEEE TVCG 2013
16
Stiff Systems
X (t)=[ x (t)y (t )] X (t)=ddt [ x (t)y (t )]=[ −x (t)−ky (t )]
● If we want to move a particle such that is always stays on the x-axis (particle on a wire), then we can model it as
● Use Euler’s method to update
● If |1-hk| > 1 then Euler’s method will not converge. ● For very large stiffness constant k, step size h is very small
Xnew=X0+h X (t0)=[ x (t)y (t)]+h [−x (t)−ky (t )]
Xnew=[ (1−h) x0
(1−hk) y0]
17
Implicit EulerExplicit Euler
Implicit Euler
Solving for such that , at time points back at
Xnew=X0+h f (X0)
Xnew f t 0+h X0
f (Xnew)=f (X0)+Δ X f ' (X0) where Δ X=Xnew−X0
Xnew=X0+h f (Xnew)
⇒Xnew=X0+h f (X0)+hΔ X f ' (X0)
and Δ X=( 1hI−f ' (X0))
−1
f (X0)f (X , t )= X (t)
f (X , t ) '=∂ f∂X
18
Implicit EulerSolving our stiff system with implicit Euler
Δ X=( 1hI−f ' (X0))
−1
f (X0)
f (X (t))=[ −x (t)−ky (t )]f (X (t)) '=[−1 0
0 −k ]
Δ X=[1+hh
0
01+khh
]−1
[ −x0
−ky0]=−[
hh+1
x0
h1+kh
ky0 ]
19
Implicit Euler – Step SizeLargest step size the implicit solver can take for our problem
limh→∞
Δ X=limh→∞
−[hh+1
x0
h1+kh
ky0 ]=−[
x0
1kky0]=−[ x0
y 0]
i.e., Xnew=X0+(−X0)=0
20
Implicit Euler - Stability● Implicit update
● Then the solver is stable if
xn+1=xn+hλ xn+1
⇒ xn=x0( 11−hλ )
n
1|1−hλ|
≤1 or |1−hλ|>1
21
Implicit Euler ● Correct Soln● Explicit Euler● Implicit Euler
● Implicit solver causes numerical
damping. This is not always desirable.● Stability over large step size does not imply accuracy.
x (h)=−k x (h)
x (0)=1
x (h)=e−hk
x (h)=1−hk
x (h)=1
1+hk
x
h
22
Trapezoidal Rule● Half explicit Euler, half implicit Euler
● Where is this stable?
xn+1=xn+h(12f (xn)+
12f (xn+1))