Try   HackMD

AN3D: Interpolate position

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

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Descriptive Animation

The artist/an algorithm fully describes the motion and deformation

Pros Cons
Full control on the result May introduce un-physical effects

History of CG Animation

First production of animated films (Disney)

Principle

  • Animator in chief: create key frames
  • Assistants: fill the in between (secondary drawings)

Principle of Key Framing:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • Input:
    (pi,ti)

Linear Interpolation

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Pros Cons
Simple Non smooth trajectory
Constant speed between keyframes Generates straight segments

Smooth curve

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • αi
    polynomial basis function of degree
    d

Which polynomial/degree choose ?

Lagrange polynomial interpolation

Interpolate all points at once

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Degree of polynomial:

N1

Known solution: Lagrange polynomial

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Comparison

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

En pratique, on n'utilise jamais cette interpolation

Spline

Idea

  • Define each part a polynomial
  • Smooth junctions between them

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

How to choose the polynomial

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

In Graphics, cubic polynomials are often used

Allow up to

C2 junctions

Hermite interpolation

Cubic curve interpolationg points and derivatives at extermities

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Wrap-up algorithm

Compute

p(t) as a cubic spline interpolation

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

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  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))

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Usage of keyframes interpolation

Interpolate every vertex of multiple meshes

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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

{pR3]mathcalP(p1)n=0}

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

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

On decompose la vitesse selon 2 composantes: la tangente et la normale

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

Collision response = Update speed

Result

Applying collision response on speed only

Les boules tombent en-dessous du plan

Quand notre sphere rebondit, il est possible qu'une partie passe au travers du plan, donc on considere en collision, donc on inverse sa vitesse, donc en collision, etc

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

Result in a sudden change of speed (momentum) in a discrete case

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 mass systems

  • Particles: samples on shape
  • Springs: link closed-by particles in the reference shape

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)