Search code examples
openglsvgbeziercurves

joining points with smooth curves in opengl


I have a list of points say

a, b, c and d

that I want to join like

a - b - c - d.

Right now I'm just taking two points at a time and drawing a line between them. But the result is sharp corners. So I thought of joining them with curves so that corners are smooth. I read about Bezier curves to draw curves but that requires additional control points to draw the curve. I also couldn't get how to join multiple points in a row using curves. Is there some way of doing that or something that can I can do or work on to make this possible?

I am using both opengl and SVG to output the result.


Solution

  • Catmull-Rom splines are perhaps the easiest way to join up points with curves without needing additional control points (well you need a couple of extra points at the beginning and end, but you can trivially make those up like e=d+(d-c)). This looks like a good primer: https://www.mvps.org/directx/articles/catmull/

    I find it can be difficult to get aesthetically pleasing curves when the points are very unevenly spaced though.