Curve Editor

December 2023
  • C++

Overview

This is a simple, interactive demo for creating and editing various types of splines. There are three types of splines: Linear, Bezier, and Hermite splines. Base points can be edited, added and removed, and for Bezier and Hermite splines, control points can be move around.

Video Demo

Breakdown

Linear

Linear splines are very simple to implement. Given some base positions and some ordering of these points, you just "connect the dots" and draw in strait lines between the positions.
Screenshot 1
Linear Spline

Bezier

Three different methods for making the Bezier splines were implemented: Catmul-Rom Splines, De Casteljau's algorithm, and the Matrix Method. They all will give the same result, but in different ways.

Catmull-Rom splines are a way of concatonating piecewise Bezier curves by creating specific control points to ensure C1 continuity along the spline. For each inputted position in our sequence two control points are created (except for the ends), one infront and one behind. These control points ensure that the slope going into the base point matches the slope leaving the base point. We get this slope by calculating the backwards difference with the previous point.

De Casteljau's Method is a recursive process for creating Bézier curves by breaking them into smaller and smaller linear interpolations between control points. At each step, points are blended based on the curve parameter, eventually converging on a single point on the curve.

Matrix Method formulates Bézier curves using linear algebra to streamline the computation process. Control points are combined with a pre-defined basis matrix, which encodes the blending weights for the curve.

Bez 1
Catmul-Rom
Bez 2
De Casteljau's
Bez 2
Matrix Method/figcaption>

Hermite

Hermite splines are a type of cubic interpolating spline that allow precise control over the shape of the curve by specifying not just the points the curve passes through but also the tangents at those points. For each segment of the spline, the curve is defined between two endpoints, with tangents controlling the slope at those points. This means that Hermite splines are C2 continuous.

The curve for a Hermite spline segment is constructed using a blend of four basis functions. These functions are weighted combinations of the two endpoints and their tangents, ensuring the curve smoothly transitions between segments. The general form of the curve is:

\[ C(t) = h_1(t)P_0 + h_2(t)P_1 + h_3(t)T_0 + h_4(t)T_1 \]

Here, \( P_0 \) and \( P_1 \) are the endpoints of the curve segment, \( T_0 \) and \( T_1 \) are the tangents at those endpoints, and \( h_1(t) \), \( h_2(t) \), \( h_3(t) \), and \( h_4(t) \) are the Hermite basis functions. These basis functions determine how the endpoints and tangents influence the shape of the curve as the parameter \( t \) progresses from 0 to 1.

hermite 1
Hermite Spline