Reticulating Splines

This is a challenge exercise. It is not compulsory, and may be completed individually or with your lab partner.

Heads up! Make sure you’ve done The Image ADT and Drawing on an Image before attempting this exercise.

Make sure you’ve got an unchanged copy of Image.h.

Download Image.h, or copy it into your current directory on a CSE system by running

$ cp /web/cs1511/17s2/week09/files/Image.h .

Don’t change Image.h! If you do, weasels will eat your phone system.

A Bézier curve is a parametric curve bounded and shaped by a set of control points. A Bézier curve of order 2 has three control points, and is a parametric parabola; a Bézier curve of order 3 has four control points, and is a parametric cubic.

A curve won’t escape from the bounding box, the closed shape of the control points. For an order-3 Bézier curve, that’s usually a quadrilateral.

A sequence of Bézier curves where the end-point of one is the start-point of another forms a spline, and the points where they join are called knots.

a Bézier spline

If the series of control points are collinear – that is, a line can be drawn through them and through the knot – the knots have continuity.

a Bézier spline

Bézier curves and splines are drawing primitives, and are especially important in vector graphics, like the very characters you’re reading now.

A Bézier curve is parametric, and the function for an order-3 Bézier curve is, for control points , , , , and for all real values from 0 to 1,

For each , the actual coördinate is the combination of values and of values.

For this exercise, take your existing Image.c and extend it with the following function:

To run some simple automated tests:

$ 1511 autotest imageDrawing3

To run Styl-o-matic:

$ 1511 stylomatic Image.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk09_imageDrawing3

Or, if you are working from home, upload the relevant file(s) to the wk09_imageDrawing3 activity on Give Online.