04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 7-27. Interpolating a Bézier curve within a convex hull<br />

There’s nothing new in the last sketch, but I hope it illustrates how the convex hull (the<br />

shape defined by the three initial points) dictates the placement <strong>and</strong> shape of the curve.<br />

You can use this same sketch to approximate a cubic Bézier curve as well, with four initial<br />

points instead of three. You’ll remember that cubic curves can contain an inflection point<br />

in the curve, or a change in direction, as shown in Figure 7-28. To generate this image,<br />

simply make the following changes to the values in the last sketch, <strong>and</strong> rerun it:<br />

int startingPoints = 4;<br />

bezier[0] = new Point(200, 700);<br />

bezier[1] = new Point(100, 50);<br />

bezier[2] = new Point(1100, 750);<br />

bezier[3] = new Point(1000, 100);<br />

CURVES<br />

277<br />

7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!