• 12
• 14
• 13
• 10
• 11
• entries
503
1888
• views
334574

# Algorithim Snippit

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

## 1 Comment

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.

## Create an account

Register a new account