# How do splines work?

I've been beginning to work with different kinds of splines (e.g. Bezier, Hermite, B-splines) in some of my work with computer graphics and I am trying to get a grasp of how they work (mathematically and programmatically). I know that generally (at least for cubic splines), you will have 4 control points that influence the position of points along an interpolated line. For example, with Bezier curves (as far as I understand), there can be two end points where the line will begin and terminate and two control points that influence the direction of the line.

I've been programming Bezier, Hermite, and B-Splines (in javascript on an html5 canvas) and what I don't understand is how to choose these 4 points in order to see a specific curve rendered on the screen. So far, I have only been able to render at least part of a curve by randomly playing around with different numbers for each point.

This is one of the many questions I have about the inner workings of splines so could someone provide an overview on how they work and how they can be programmed (most of the examples online are more theoretical and rather unspecific)?

• The Wikipedia article on Bézier curves has great animated diagrams illustrating how they're formed (check the section "Constructing Bézier Curves"). In general for splines, the first and last points are the endpoints of the spline, and the line from each endpoint to the control point before/after it defines the tangent at that endpoint (ie. Which way the spline is sloping when it reaches that point) – DMGregory Nov 11 '15 at 14:17