1 / 61

Interpolating values

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?

Download Presentation

Interpolating values

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interpolating values CSE 3541 Matt Boggus

  2. Problem: paths in grids or graphs are jagged

  3. Path smoothing

  4. Path smoothing example

  5. Problem statement • How can we construct smooth paths? • Define smooth in terms of geometry • What is the input? • Where does the input come from? • Pathfinding data • Animator specified

  6. Interpolation • Interpolation: The process of inserting in a series an intermediate number or quantity ascertained by calculation from those already known. • Examples • Computing midpoints • Curve fitting

  7. Interpolation terms • Order (of the polynomial) • Linear • Quadratic • Cubic • Dimensions • Bilinear (data in a 2D grid) • Trilinear (data in a 3D grid)

  8. Linear interpolation • Given two points, P0 and P1 in 2D • Parametric line equation: P = P0 + t (P1 – P0) ; OR X = P0.x + t (P1.x – P0.x) Y = P0.y + t (P1.y – P0.y) • t = 0  Beginning point P0 • t = 1 End point P1

  9. Linear interpolation • Rewrite the parametric equation P = (1-t)P0 + t P1 ; OR X = (1-t)P0.x + t P1.x Y = (1-t)P0.y + t P1.y • Formula is equivalent to a weighted average • t is the weight (or percent) applied to P1 • 1 – t is the weight (or percent) applied to P0 • t = 0.5  Midpoint between P0 and P1 = Pmid • t = 0.25  1st quartile = midpoint between P0 and Pmid • t = 0.75  3rdquartile = midpoint between Pmidand P1

  10. Bilinear interpolation process • Given 4 points (Q’s) • Interpolate in one dimension • Q11 and Q21 give R1 • Q12and Q22give R2 • Interpolate with the results • R1 and R2 give P

  11. Bilinear interpolation application • Resizing an image

  12. Bilinear vs. bicubic interpolation Higher order interpolation requires more sample points

  13. Curve fitting • Given a set of points • Smoothly (in time and space) move an object through the set of points • Example of additional temporal constraints • From 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

  14. Example Observations: • 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

  15. Solution steps 1. Construct a space curve that interpolates the given points with piecewise first order continuity p=P(u) 2. Construct an arc-length-parametric-value function for the curve u=U(s) s=S(t) 3. Construct time-arc-length function according to given constraints p=P(U(S(t)))

  16. Lab 5 See specification

  17. Choosing an interpolating function Tradeoffs and commonly chosen options Interpolation vs. approximation Polynomial complexity: cubic Continuity: first degree (tangential) Local vs. global control: local Information requirements: tangents needed?

  18. Interpolation vs. Approximation

  19. Polynomial complexity Low complexity reduced computational cost With a point of inflection, the curve can match arbitrary tangents at end points Therefore, choose a cubic polynomial

  20. Continuity orders C-1discontinuous C0continuous C1first derivative is continuous C2first and second derivatives are continuous

  21. Local vs. Global control

  22. Information requirements just the points tangents interior control points just beginning and ending tangents

  23. Curve Formulations • General solution • Lagrange Polynomial • Piecewise cubic polynomials • Catmull-Rom • Bezier

  24. Lagrange Polynomial See http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html for more details

  25. Lagrange Polynomial Written explicitly term by term is:

  26. Lagrange Polynomial Results are not always good for animation

  27. Polynomial curve formation • Given by the equation P(u) = au3 + bu2 + cu+ d • u is a parameter that varies from 0 to 1 • u = 0 is the first point on the curve • u = 1 is the last point on the curve • Remember this is a parametric equation! • a, b, c, and d are not scalar values, but vectors

  28. Polynomial curve formation P(u) = au3 + bu2 + cu+ d • The point P(u) = (x(u), y(u), z(u)) where x(u) = axu3 + bxu2 + cxu + dx y(u) = ayu3+ byu2+ cyu+ dy z(u) = azu3+ bzu2+ czu+ dz

  29. Polynomial Curve Formulation Matrix multiplication The point at “time” u Geometric information (i.e the points or tangents) Where u is a scalar value in [0,1] Coefficient matrix (given by which type of curve you are using)

  30. So how do we set a, b, c, and d?Or the matrices M and B?

  31. Catmull-Rom spline • Passes through control points • Tangent at each point pi is based on the previous and next points: (pi+1− pi−1) • Not properly defined at start and end • Use a toroidal mapping • Duplicate the first and last points

  32. Catmull-Rom spline derivation τ is a parameter for tension (most implementations set it to 0.5)

  33. Catmull-Rom spline derivation

  34. Catmull-Rom spline derivation • Use with cubic equation Note: - c values correspond to a, b, c, and d in the earlier cubic equation - c values are vectors

  35. Catmull-Rom spline derivation • Solve for ci in terms of control points

  36. Catmull-Rom matrix form • Set τ to 0.5 and put into matrix form

  37. Blended Parabolas/Catmull-Rom* Visual example * End conditions are handled differently (or assume curve starts at P1 and stops at Pn-2)

  38. Bezier Curve p1 • Find the point x on the curve as a function of parameter u: • x(u) p0 p2 p3

  39. de Casteljau Algorithm • Describe the curve as a recursive series of linear interpolations • Intuitive, but not the most efficient form

  40. de Casteljau Algorithm p1 • Cubic Bezier curve has four points(though the algorithm works with any number of points) p0 p2 p3

  41. de Casteljau Algorithm p1 q1 q0 p0 p2 q2 p3 Lerp = linear interpolation

  42. de Casteljau Algorithm q1 r0 q0 r1 q2

  43. de Casteljau Algorithm r0 • x r1

  44. Bezier Curve p1 • x p0 p2 p3

  45. Cubic Bezier Curve runs through Pi and Pi+3with starting tangent PiPi+1 and ending tangent Pi+2Pi+3

  46. Controlling Motion along p=P(u) Step 1. vary u from 0 to 1 create points on the curve p=P(u) But segments may not have equal length Step 2. Reparameterization by arc length u = U(s) where s is distance along the curve Step 3. Speed control for example, ease-in / ease-out s = ease(t) where t is time

  47. Reparameterizing by Arc Length Analytic Forward differencing Supersampling Adaptive approach Numerically Adaptive Gaussian

  48. Reparameterizing by Arc Length - supersample • Calculate a bunch of points at small increments in u • Compute summed linear distances as approximation to arc length • Build table of (parametric value, arc length) pairs • Notes • Often useful to normalize total distance to 1.0 • Often useful to normalize parametric value for multi-segment curve to 1.0

  49. Build table of approx. lengths

  50. Speed Control distance • Time-distance function • Ease-in Ease-out • Sinusoidal • Cubic polynomial • Constant acceleration • General distance-time functions time

More Related