Interpolating values

download Interpolating values

of 61

  • date post

  • Category


  • view

  • download


Embed Size (px)


Interpolating values. CSE 3541 Matt Boggus. Problem: paths in grids or graphs are jagged. Path smoothing. Path smoothing example. Problem statement. How can we construct smooth paths? Define smooth in terms of geometry What is the input? Where does the input come from? - PowerPoint PPT Presentation

Transcript of Interpolating values

Interpolating values

Interpolating valuesCSE 3541Matt BoggusProblem: paths in grids or graphs are jagged

Path smoothing

Path smoothing example

Problem statementHow can we construct smooth paths?Define smooth in terms of geometryWhat is the input?Where does the input come from?Pathfinding dataAnimator specified

InterpolationInterpolation: The process of inserting in a series an intermediate number or quantity ascertained by calculation from those already known.

ExamplesComputing midpointsCurve fittingInterpolation termsOrder (of the polynomial)LinearQuadraticCubicDimensionsBilinear (data in a 2D grid)Trilinear (data in a 3D grid)Linear interpolationGiven two points, P0 and P1 in 2DParametric line equation:P = P0 + t (P1 P0) ; ORX = P0.x + t (P1.x P0.x)Y = P0.y + t (P1.y P0.y)

t = 0 Beginning point P0t = 1 End point P1Linear interpolationRewrite the parametric equationP = (1-t)P0 + t P1 ; ORX = (1-t)P0.x + t P1.xY = (1-t)P0.y + t P1.y

Formula is equivalent to a weighted average t is the weight (or percent) applied to P11 t is the weight (or percent) applied to P0

t = 0.5 Midpoint between P0 and P1 = Pmidt = 0.25 1st quartile = midpoint between P0 and Pmidt = 0.75 3rd quartile = midpoint between Pmid and P1Bilinear interpolation process

Given 4 points (Qs)

Interpolate in one dimensionQ11 and Q21 give R1Q12 and Q22 give R2

Interpolate with the resultsR1 and R2 give PBilinear interpolation applicationResizing an image

Bilinear vs. bicubic interpolation

Higher order interpolation requires more sample pointsCurve fittingGiven a set of pointsSmoothly (in time and space) move an object through the set of points

Example of additional temporal constraintsFrom zero velocity at first point, smoothly accelerate until time t1, hold a constant velocity until time t2, then smoothly decelerate to a stop at the last point at time t3



Order of labels (A,B,C,D) is computed based on time values

Time differences do not have to correspond to space or distance

The last specified time is arbitrary

Solution steps1. Construct a space curve that interpolates the given points with piecewise first order continuity2. Construct an arc-length-parametric-value function for the curve3. Construct time-arc-length function according to given constraintsp=P(u)u=U(s)s=S(t)p=P(U(S(t)))Lab 5See specificationChoosing an interpolating functionTradeoffs and commonly chosen optionsInterpolation vs. approximation

Polynomial complexity: cubic

Continuity: first degree (tangential)

Local vs. global control: local

Information requirements: tangents needed?Interpolation vs. ApproximationPolynomial complexityLow complexity reduced computational costTherefore, choose a cubic polynomialWith a point of inflection, the curvecan match arbitrary tangents at end pointsContinuity orders

C-1 discontinuousC0 continuousC1 first derivative is continuousC2 first and second derivatives are continuousLocal vs. Global control

Information requirementsjust the pointstangentsinterior control pointsjust beginning and ending tangentsCurve FormulationsGeneral solutionLagrange Polynomial

Piecewise cubic polynomialsCatmull-RomBezier

Lagrange Polynomial

See for more detailsLagrange Polynomial

Written explicitly term by term is:

Lagrange PolynomialResults are not always good for animation

Polynomial curve formationGiven by the equationP(u) = au3 + bu2 + cu + du is a parameter that varies from 0 to 1u = 0 is the first point on the curveu = 1 is the last point on the curve

Remember this is a parametric equation!a, b, c, and d are not scalar values, but vectorsPolynomial curve formationP(u) = au3 + bu2 + cu + d

The point P(u) = (x(u), y(u), z(u)) wherex(u) = axu3 + bxu2 + cxu + dxy(u) = ayu3 + byu2 + cyu + dyz(u) = azu3 + bzu2 + czu + dz

Polynomial Curve FormulationMatrix multiplication

Geometric information (i.e the points or tangents)Coefficient matrix (given by which type of curve you are using)Where u is a scalar value in [0,1]The point at time uSo how do we set a, b, c, and d?Or the matrices M and B?Catmull-Rom splinePasses through control points

Tangent at each point pi is based on the previous and next points: (pi+1 pi1)Not properly defined at start and endUse a toroidal mappingDuplicate the first and last pointsCatmull-Rom spline derivation is a parameter for tension (most implementations set it to 0.5)

Catmull-Rom spline derivation

Catmull-Rom spline derivationUse with cubic equation

Note:- c values correspond to a, b, c, and d in the earlier cubic equation- c values are vectorsCatmull-Rom spline derivationSolve for ci in terms of control points

Catmull-Rom matrix formSet to 0.5 and put into matrix form

Blended Parabolas/Catmull-Rom*Visual example

* End conditions are handled differently(or assume curve starts at P1 and stops at Pn-2)Bezier Curvep0p1p2p3Find the point x on the curve as a function of parameter u:x(u)de Casteljau AlgorithmDescribe the curve as a recursive series of linear interpolations

Intuitive, but not the most efficient formde Casteljau Algorithmp0p1p2p3Cubic Bezier curve has four points (though the algorithm works with any number of points)de Casteljau Algorithmp0q0p1p2p3q2q1

Lerp = linear interpolationde Casteljau Algorithmq0q2q1r1r0

de Casteljau Algorithmr1xr0

Bezier Curvexp0p1p2p3Cubic Bezier

Curve runs through Pi and Pi+3 with starting tangent PiPi+1 and ending tangent Pi+2Pi+3 Controlling Motion along p=P(u) Step 2. Reparameterization by arc lengthu = U(s) where s is distance along the curvep=P(u)But segments may nothave equal lengthStep 1. vary u from 0 to 1create points on the curveStep 3. Speed controls = ease(t) where t is timefor example, ease-in / ease-outReparameterizing by Arc LengthAnalyticForward differencingSupersamplingAdaptive approachNumericallyAdaptive Gaussian

Reparameterizing by Arc Length - supersampleCalculate a bunch of points at small increments in uCompute summed linear distances as approximation to arc lengthBuild table of (parametric value, arc length) pairsNotesOften useful to normalize total distance to 1.0Often useful to normalize parametric value for multi-segment curve to 1.0indexuArc Length (s)00.000.00010.050.08020.100.150


.........201.001.000Build table of approx. lengthsSpeed ControlTime-distance functionEase-in Ease-outSinusoidalCubic polynomialConstant accelerationGeneral distance-time functionstimedistanceTime Distance Functions = S(t)st the global time variableSEase-in/Ease-out Functions = S(t)stS0. distance and time to 1.0 to facilitate reuseEase-in: Sinusoidal

Ease-in: Single Cubic

Ease-in: Constant Acceleration

Ease-in: Constant Acceleration

Ease-in: Constant Acceleration

Ease-in: Constant Acceleration

Motion on a curve solution steps1. Construct a space curve that interpolates the given points with piecewise first order continuity2. Construct an arc-length-parametric-value function for the curve3. Construct time-arc-length function according to given constraintsp=P(u)u=U(s)s=S(t)p=P(U(S(t)))Arbitrary Speed ControlAnimators can work in:Distance-time space curvesVelocity-time space curvesAcceleration-time space curvesSet time-distance constraintsReferencesImages from