Home AN3D: Interpolate position
Post
Cancel

AN3D: Interpolate position

Lien de la note Hackmd

Site du prof

Animation in Computer Graphics

2 main ways to describe animation

  1. Kinematics
  2. Dynamics

Ways to genre animation

  1. Descriptive animation
  2. Motion tracking
  3. Procedural generation
  4. Physically based simulation
  5. Leaning-based synthesis

Descriptive Animation

ProsCons
Full control on the resultMay introduce un-physical effects

History of CG Animation

First production of animated films (Disney)

Principle of Key Framing:

Key framing in CG

  • Create manually a set of key frames
  • Interpolate positions

Production pipeline: Interpolate position

  • Given a set of key positions (pos + time), we want to find an interpolating space-time curve

  • Input: (pi,ti)

Linear Interpolation

ProsCons
SimpleNon smooth trajectory
Constant speed between keyframesGenerates straight segments

Smooth curve

  • αi polynomial basis function of degree d

Which polynomial/degree choose ?

Lagrange polynomial interpolation

Degree of polynomial: N1

Comparison

Spline

How to choose the polynomial

  • Sufficiently high degree to be smooth
  • Sufficiently low degree to avoid oscillations

Hermite interpolation

Interpolating curve

Initial problem: set of multiple keyframes position+time

2 solutions:

  • Set explicitely derivatives for each keyframe - teadious
  • Compute automatically plausible derivatives from surrounding samples - often used

Cardinal spline:

Set:

di=μpi+1pi1ti+1ti1
  • μ curve tension [0,2]
  • μ=1 is commonly used
    • Catmull Rom Spline

Wrap-up algorithm

Compute p(t) as a cubic spline interpolation

  • Given keyframes (pi,ti)i[0,N1]
  • Given time t[t1,tN2]

  1. find i such that t[ti,ti+1]
  2. Compute di=μpi+1pi1ti+1ti1 and di+1=μpi+2piti+2ti
  3. Compute p(t)=(2s33s2+1)pi+(s32s2+s)di+(2s3+3s3)pi+1+(s3s2)di+1
    • with s=ttiti+1ti

Limitation of cubic curve interpolation

  • Only C1, but not C2 at junctions: curvature/acceleration discontinuity
  • Non-constant peed along each polynomial

Curve editing

  • Animation software (Maya, 3DSMax, Blender, etc) always come with a curve editor
  • Artists can manually ajust their position, time, and derivatives on curve editor
    • One curve for each scalar parameter
      • position (x,t,z)
      • scaling (sx,sy,sz)
      • rotation/quaternion
  • Can also use a wrapper function w to change time p(t)=f(w(t))

Usage of keyframes interpolation

Multi-target blending

Interpolate between multiple key poses

  • Interesting for facial animation

  • Per-vertez formulation pi(t)=kNposes

Blend shapes

pi(t)=bi0+kNposesωk(t)(bkibi0)

Physically-based simulation

When physically based simulation is needed

  • Accurate dynamics
  • Teadious to model by hand or procedurally
    • Multiple interacting elements
    • Complex animated geometry

Material model

  • Elasticity
    • Purely elastic models don’t loose energy when deformed
  • Plasiticity
    • Ductile material: can allow large amout of plastic deformation without breaking (plastic)
    • Brittle - Opposite (glass)
  • Viscosity
    • Resistance to flow (usually for fluid, ex:honey)

In reality

  • Elasto-plastic materials
    • Allow elastic behavior for small deformation, and plastic at larger one
  • Visco-elastic materials
    • Elastic properties with delay

Rigid spheres

System modeling

Particles modeling the center of hard spheres

  • Spheres can collide with surrounding obstacles
  • Spheres can collide with each others

System: N particles with position pi, speed vi, mass mi, modeling a sphere of radius ri

  • initial conditions: pi(0)=pi0,vi(0)=vi0

Forces: Fi=

vk+1=vk+hgpk+1=pj+hvk+1

Collision with a plane

Plane P: parameterized using a point a and its normal n

{pR3P(p1)n=0}

  • Sphere above plane: (pi1)n>ri
  • Sphere in collision: (pia)nri

1
2
3
4
5
6
for (int i = 0; i < N; ++i) {
    float detection = dot(p[i]-a, n);
    if (detection <= r[i]) {
        // ... collision response
    }
}

Collision response with plane

What should we do when a collision is detected ?

On peut changer la vitesse

v{vnvn+vrvtcomposante normale: (vn)=vncomposante tangente: vvnn

Result

Les boules tombent en-dessous du plan

Comment on contre ca ?

Si ma sphere est dans le sol, on s’arrange pour qu’elle ne soit pas dans le sol On la “repousse” pour qu’elle soit en contact avec la surface

Collision response with a plane: position

Three possibilities:

  1. Correct position in projecting on the constraint
    • Pros: simple to implement
    • Cons: Physically incorrect position
  2. Approximate the correct position
  3. Go backward in time to find exact instant of collision
    • Continuouse collision detectino
    • Pros: physically correct
    • Cons: Computationally heavy

Result

Ca marche !

pinew=pi+dn

Collision between speheres

Given 1 spheres (p1,v1,r2,m2),(p2,v2,r2,m2)

Collision when

p1p2r1+r2

What will happen with speeds ?

v1v1new,v2v2new

Notion of impulse

An impulse J is the integrted force over time

J=t1t2F(t)dt

For a particle with a constant mass

t1t2F(t)dt=t1t2ma(t)dt

2 spheres in collision

J’ecris pas ca vous etes fous

Summary

  1. Detect collision p1p2r1+r2
  2. if collision (relative speed>ϵ)
    • Elastic collision (bouncing) v1/2=αv1/2±βJm1/2
    • If static contact (relative speed ϵ)
      • Friction v1/2=μv1/2,μ[0,1]
      • Avoids jittering
  3. Correct position (project on contact surface)
    • p=p+d2u
    • d=r1+r2p1p2: collision depth
    • For small impacts, can use position based dynamics
      • vnew=(pnewpprev)δt

Note on collision stack

Optimiser ne pas avoir a simuler les spheres sur le sol et immobiles

  • Faire des graphes des solides et les traiter comme des solides rigides

Modeling elastic shapes with particles

Spring structure

How to model spring connectivity ?

  • Structutal springs
    • 1-ring neighbors springs ( mesh edges)
    • Pros: limit elongation/contraction
    • Cons: Allows shearing, and bending
    • Add extra springs connectivity
  • Shearing springs
    • Diagonal links
  • Bending springs
    • 2-ring neighborhood

Cloth simulation

Mass-spring cloth simulation

  • Particles are sampled on a N×N grid
    • Each particle has a mass m
  • Set structural, shearing and bending springs

Forces

  • On each particle: gravity + drag + spring forces

Fi(p,v,t)=migμvi(t)facteur d'attenuation+jνiKij(pj(t)pi(t)Lij0)pi(t)pi(t)pj(t)pi(t)

  • νi: neighborhood of particle i
  • Lij0: rest length of spring ij

Associated ODE

i{pi(t)=vi(t)vi(t)=Fi(p,v,t)
This post is licensed under CC BY 4.0 by the author.