Skip to content

Instantly share code, notes, and snippets.

@jonnyhopper
Created May 30, 2017 20:00
Show Gist options
  • Save jonnyhopper/12385b1a35358edabb36442e60fee68d to your computer and use it in GitHub Desktop.
Save jonnyhopper/12385b1a35358edabb36442e60fee68d to your computer and use it in GitHub Desktop.
How to make a quadratic bezier curve in like 4 lines, less if you put it all on one line and don't write the comments
// Assuming you have a 2d or 3d point datatype
// and a value t in 0..1, which is your point on the curve
point bezier_points[3] = { ... };
point q0 = lerp( t, bezier_points[0], bezier_points[1] );
point q1 = lerp( t, bezier_points[1], bezier_points[2] );
point b = lerp( t, q0, q1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment