[metapost] quadratic bezier paths ?
laurent at math.toronto.edu
laurent at math.toronto.edu
Wed Apr 29 08:21:26 CEST 2009
*** quadratic bezier paths ?
Hi all,
Jacko has proposed that linear paths be somehow known as linear to
metapost (=MP). What are the motivations? I'm not sure I could
guess Jacko's.
Actually, I would go at least one step further:- make quadratic
bezier curves known to MP. One motivation might be to
facilitate conversions between type1 fonts based on cubic bezier
curves and truetype fonts based on quadratic bezier curves.
Then one would have
(where A,B,C,D,...,Z are points and t, u are numerics):
** point = 0-bezier path at a point, say A
** linear path = 1-bezier path, A---D = A controls B and C .. D
where B = (2/3)*A + (1/3)*D and
C = (1/3)*A + (2/3)*D
I will use the symbol " --- ", which is (hopefully) foreign to MP.
** parabolic path = 2-bezier path, with quadratic control vector
that I denote A---B---C (the MP notation is given below).
** cubic path = 3-bezier path, A---B---C---D, which is
A .. controls B and C .. D in MP notation.
More generally, a degree n (parametrized) bezier path p(t),
0 =< t = <1, involves a sequence of n+1 control points, say p =
A0---A2---A3---...---An, and its parametric form is
p(t) = \Sum \{ B_i(t)*Ai | 0\leq i \leq n \} where B_i(t) is the
i-th Bernstein polynomial. (I use TeX notation here.)
Every degree n bezier path can be naturally 'coerced' (with no
change of parametrization!) to become formally a degree n+1 bezier path.
For example by coercing the quadratic path A---B---C we get the
cubic bezier path A---A'---C'---C where
A' = (2/3)*A + (1/3)B and C' = (2/3)*B + (1/3)C.
In greater generality, if we coerce to degree n+1 a given
degree n bezier path A0---A2---A3---...---An, the new n+2 control
points turn out to be the points at times the multiples of n/(n+1)
on the composite piecewise linear path A0--A2--A3--...--An of MP
parameter length n.
At degrees >3 one has a level of generality that Knuth was
happy not to use. On the other hand I believe he was somewhat
miffed to have passed over quadratic beziers in his MF vision ---
he later conceded that many of the corresponding algorithithms are
more convenient.
Laurent S.
More information about the metapost
mailing list