A typical problem which arises in designing an object is that of connecting a sequence of points by a smooth curve. For example in designing a car body engineers may have determined several points on the body and the designer must connect them with an esthetically pleasing curve. Computer graphics and type face design offer similar challenges. A spline is the mathematical term for a curve which passes through a sequence of given points and which has some presrcibed nice property between neighbouring points and . One of the simplest such proeprties is that of being quadratic; so a quadratic spline for a sequence of points is a function f which has different definitions on each of the intervals such that on each of these intervak the function is quadratic. It is als required that at each of the points the transition from ne defitnion to the other is smooth -- namely the tangent from both the left and right have the same slope.
Write a procedure -- TwoPointSpline -- which, when given the inputs (m, P1, P2), will find a quadratic function passing through the two points P1 and P2 and having slope m at the first point P1. Using this procedure find a quadratic spline through the points (1,1), (2,2), (4, 5/2), (5,0) and having slope -2 at the point (1,1). Using the knowledge you have gained in this exercise, write aprocedure that will find a quadratic spline through any given sequence of points with a given slope at the first point. Test your procedure on a sequence of 10 points.
So far, only splines of points forming a function have been discussed, However, it is also possible to create more general curves with splines. Consider the quadratic parametric curve defined by: . Given two points, p1 and p2 in the plane as well as two slopes m1 and m2 and an interval [u.v], define a general procedure which will define a curve such that