[metapost] degree =<3 bezier paths describing an interval
laurent at math.toronto.edu
laurent at math.toronto.edu
Sun May 3 08:41:58 CEST 2009
Dan's comments under thread the "quadratic bezier
paths" are helpful. It is a pity that Knuth & Hobby
have already defined a binary op " --- " albeit just
as a macro in plain.mf (that is reiterated in
plain.mp). Provided it is not already widely used in
MP practice (there is no mention of it in MP doc)
perhaps the way is open to privately "re def" it as I
suggested, namely as a universal notation for bezier
curves of degrees 1,2,3. And beyond if one wants; but
Knuth doesn't want. Recall that MP and PS treat all
their bezier curves as degree 3 (possibly degenerate)
and use uniform degree 3 notations. In short
my "---" is provisionally an admissible heresy.
> Maybe -- is better [than my --- ].
Certainly -- is OK for degree 1. Indeed path
p := A -- B does give a linear
parametrization to the linear segment [A,B] from A
to B, ie the segment is traversed from A to
B, at constant speed. This A -- B is identical
(as path-with-paametrization expressed
in my terminology) to all of these:
the 1-bezier path A --- B
OR the 2-bezier path A --- .5(A+B) --- B
OR the 3-bezier path A --- A' --- B' --- B
where A' = (2/3)A + (1/3)B
and B' = (1/3)A + (2/3)B
By A -- B -- C -- D we all mean the 3-piece
linear path passing through arbitrary A,B,C,D with
parameter interval [0,3].
By A --- B --- C --- D, I have always meant the
bezier degree =< 3 path which MP denotes by
A .. controls B and C .. D. Its parameter interval
is [0,1], and the parametrization is genericly
nowhere linear, even when B and C lie on [A,B].
Jacko is claiming that, in certain circumstances,
the very special bezier curve
A .. controls A and B .. B == A---A---B---B
describing the linear segment from A to B is a
helpful substitute for A -- B == A --- B. I partly
agree (expect much more on this someday). But at the
same time, this practice would be a bit dangerous for
programmers less expert than Jacko, because the
parametrization here is highly nonlinear (ie very
cubic!). The danger arises from the fact that many MF
and MP path operations depend strongly on the
parametrization. Some key examples:- let p and q be
bezier paths and t,u numeric; then
p intersectiontimes q
point t of p
subpath (t,u) of p
direction t of p
arctime t of p
obviously depend importantly on the parametrization.
Happily, all bezier paths of degree =<3 that do
not lie in a line have UNIQUE bezier parametrization.
This is revealed by the asymptotic behavior as
parameter tends to infinity (after analytic
continuation). In other words, the MP bezier images
NOT lying within a line admit a unique bezier
But what are the bezier parametrizations for MP
bezier images that do lie in a line? Such an image
is a line interval that I denote [A,B]. If A=B the
parametrization is of course constant and so unique.
Suppose now that A\neq B. One can then proceed case
by case. To begin I describe the parametrizations by
MP bezier paths p: [0,1] --> [A,B] with p(0)=A and
p(1)=B. They form a 2-parameter family
A---A'---B'---B with A' and B' varying in the line of
[A,B] in such a way that the bezier time derivative
vanishes (if at all) only at times whose image points
lie in [A,B]. Note that, if the derivative vanishes
at two times, then the corresponding open subinterval
of [A,B] is traversed 3 times! One could be much more
specific about which A' and B' occur. Also, I am
leaving as an exercise the cases where [A,B] is
bigger than [p(0),p(1)].
Among the above MP beziers one can note a
1-parameter family of quadratic parametrizations,
namely A---C---B with C varying in the line of [A,B].
Beware that A---C---C---B is never A---C---B
and is never quadratic, as the degree raising recipe
at the end of my last posting reveals.
Mojca asked (backchannel) for more
explanation of my description of bezier paths using
control points and my heretic binary operation --- .
Hopefully the above will help both him and others.
I will have to return to the questions raised by
Jacko and Dan; the above is just a warm-up.
More information about the metapost