This is a guest post from my friend Łukasz Izdebski Ph.D.
Intro
It’s been a while since my last guest post on Adam’s blog, but I’m back with something short and practical—think of it as an epilogue to this earlier post on Bézier curves in animation. The last post focused on the theory and mathematics behind Bézier curves. What it lacked was a practical perspective—an opportunity to see the implementation in action. I wanted to share with you a simple library that I have created. Its purpose is to directly represent cubic Bézier Curves as Easing Functions.
Library
The library is designed with C++20 and newer standards in mind, taking advantage of modern language features for clarity and performance. If needed, support for earlier versions of C++ can be added to ensure broader compatibility.
Self-contained C++ library in single header file. No external dependencies other than standard C and C++ library.
The entire concept is encapsulated in a single template class: EasingCubicBezier
. This class handles the interpolation of parameters used in the keyframe method. The interpolation of parameters follows the same principles as standard Bézier curve evaluation. The constructor takes the X and Y coordinates of the 4 control points of the cubic Bézier curve.
Once instantiated, you can call the evaluate function with a parameter t , which should lie between x0 (the X coordinate of the first control point, representing the start time of the frame) and x3 (the X coordinate of the fourth control point, representing the end time).
function with a parameter , which should lie between x0 (the X coordinate of the first control point, representing the start time of the frame) and x3 (the X coordinate of the fourth control point, representing the end time). The function returns the interpolated value at time t, based on the shape of the Bézier curve.
... continue reading