29.11.2012 Views

MetaFun - Pragma ADE

MetaFun - Pragma ADE

MetaFun - Pragma ADE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Especially when a path results from a call to a macro, using parentheses around a path may help,<br />

as in the following example.<br />

def unitslant = origin -- origin shifted (1,1) enddef ;<br />

draw<br />

unitslant xscaled 5cm yscaled 1cm<br />

withpen pencircle scaled 1cm withcolor .625red ;<br />

draw<br />

(unitslant) xscaled 5cm yscaled 1cm<br />

withpen pencircle scaled 5mm withcolor .625yellow ;<br />

The next definition of unitslant is therefore better.<br />

def unitslant = (origin -- origin shifted (1,1)) enddef ;<br />

draw<br />

unitslant xscaled 5cm yscaled 1cm<br />

withpen pencircle scaled 5mm withcolor .625red ;<br />

An even better alternative is:<br />

path unitslant ; unitslant = origin -- origin shifted (1,1) ;<br />

draw<br />

unitslant xscaled 5cm yscaled 1cm<br />

withpen pencircle scaled 5mm withcolor .625yellow ;<br />

2.5 Curve construction<br />

Chapter 3 of the METAFONT book explains the mathematics behind the construction of curves. Both<br />

METAFONT and METAPOST implement Bézier curves. The fact that these curves are named after Pierre<br />

Bézier obscures the fact that the math behind them originates with Sergeĭ Bernshteĭn.<br />

The points on the curve are determined by the following formula:<br />

z(t) = (1 − t) 3 z1 + 3(1 − t) 2 tz2 + 3(1 − t)t 2 z3 + t 3 z4<br />

Curve construction A few more details<br />

75

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

Saved successfully!

Ooh no, something went wrong!