Created
May 30, 2017 20:00
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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