🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Algorithim Snippit

posted in A Keyboard and the Truth for project 96 Mill
Published April 06, 2005
Advertisement
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 =)
Previous Entry And Another...
Next Entry More Like Metal?
0 likes 1 comments

Comments

noaktree
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.
April 06, 2005 08:08 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement