Bézier Curves

A Bézier Curve editor with upto 9 points.

The complete code can be found here

Overview

This simple editor was made in C++ using SFML as a rendering library with imgui for the simple UI to control stuff like:

Live Demo

This demo shows a Bézier Curve with 7 control points with one start and end point each. The intermediate points which are used to Lerp to achieve the final curve are also shown.

Some Explanation

The simplest Bézier Curve is the cubic Bézier which can be made by using 3 points. Lets call them A, B and C. We Linearly Interpolate between A and B and B and C. Then we also Lerp between the points we get from the previous Lerps. This final point creates a simple cubic curve with a single control point (point B).


Point A = ( 1, 1 );
Point B = ( 2, 2 );
Point C = ( 3, 1 );

Point D = Lerp( A, B, t );
Point E = Lerp( B, C, t );

Point F = Lerp( D, E, t );
				

This F point, represented by the Blue Circle in the below video, gives us the final curve where t goes form [0-1].