• Advertisement
  • entries
    503
  • comments
    1888
  • views
    334574

Algorithim Snippit

Sign in to follow this  

122 views

Not sure if this will help anyone,
but I recently needed to make use of Quadratic Interpolation, and had a hard time finding it on the web, so I reached back into a book I had and extracted it, here it is =)


float x=(2*(x2-x0)-4*(x1-x0))*(t*t)-((x2-x0)-4*(x1-x0))*t+x0;
float y=(2*(y2-y0)-4*(y1-y0))*(t*t)-((y2-y0)-4*(y1-y0))*t+y0;


this will give you some point(x,y) that flows between three control points(x0,y0,x1,y1,x2,y2) as t aproaches 1.0f

the value of t should be in the range of 0.0f and 1.0f

with 0 placing you at point0 and 1 placing you at point2

hope somone finds this useful =)
Sign in to follow this  


1 Comment


Recommended Comments

Don't forget the 3D version and 2D versions are the same where three points P°, P¹, and P² are the points on a path.

P = (2(P²-P°) - 4(P¹-P°))μ² - ((P²-P°) - 4(P¹-P°))μ + P°

Where P is a point of the interpolation between μ=0 and μ=1, remember that P=P¹ at μ=0.5

Blending a series of quadratics together can be used to form paths with more points, though caution must be used as this method may produce "kinky" transitions between paths. Also if the lengths of the blended paths are not equal the speed at which P progresses from path to path may vary.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement