# [metapost] "ProfileBezier.mp"

Larry Siebenmann laurent at math.toronto.edu
Fri Mar 4 06:06:25 CET 2005

```
Hi all,

List members have recently learned a lot about bezier
inflexions and loops. But, to the uninitiated mp user, it is
not obvious that a bezier cubic curve F(t) (when extended for
all times t) almost always has one of two characteristic
shapes "loop" or "inflexions" and even bears a perfectly
*canonical* coordinate system.

Certainly this is not something prominently mentioned in the
metafont book, and it may indeed be of no significance to the
casual mp user. But I do suspect that Knuth and Hobby knew
this well in building metafont and metapost (=mp). And I hope
that artists and programmers interested getting the most out
of bezier cibics can also somehow exploit this understanding.

I have therefore built a prototype bezier cubic
analyser "ProfileBezier.mp". It profiles graphically the
global behavour of (almost) any bezier cubic, and writes out
in ASCII form it's (oriented) affine and metric invariants.
I'll perhaps put it on CTAN since it is too bulky to post

http://topo.math.u-psud.fr/~lcs/mp/ProfileBezier/

Only only about 90 percent of random examples are
successfully analysed.  This can be attributed to the
practical limits of precision of the software and hardware
involved -- since in principle 99.99999... percent of bezier
cubics are of these two types.  On the other hand, it is
visually obvious that even among examples that are
successfully analysed many are "on the way" to some degenarate
form. Ideally one probably should go on to somehow analyse
degeneration. But although the fully degenarated forms are
familiar to highschool students, I do not yet see a good way
to analyse the degeneration as seen in practice.

Nevertheless, viewing examples, even random ones, is **good
fun**. Enjoy!

Cheers

Laurent S.

PS.  Here is a extract of documentation for looking at the
color coded graphics output. The derivative parabolic curve,
F'(t), is heplpful in doing the analysis, so I profile it in
parallel with the cubic F(t).

"Loop_Legend.txt":

| GENERIC LEGEND for curve type "loop"
|
| Read this explanation or its companion
| "Inflex_Legend.txt" to interpret metapost figures
| produced by the metapost file "BezierProfile.mp". This
| is the text to read when the cubic curve turns out to be
| of type "loop" as reported in the file
| "BezierProfileReport.txt". The technical terms in quotes
| below mostly refer to language used in
| "BezierProfile.mp".
|
| UPPER HALF
|
| The upper half of the figure shows the given cubic
| bezier curve (really a convenient translate of
| it).
|
|  -- the originally given bezier curve segment from
| time 0 to time 1 is in blue and runs from a blue
| point to a red point.
|
|  -- its sequence of 4 control points are joined by
| three blue line segments forming the "control
| trilateral".
|
| The curve is extrapolated if necessary in light gray to
| reveal key affine features.
|
|  -- two small black points indicate end of
| the extrapolated curve.
|
|  -- a black point indicates the (affine covariant)
| cubic origin "cubic_ori" on the (extended) bezier curve.
|
|  -- the black line segment tangent to the cubic
| there lies on the (affine covariant) "cubic_axis".
| It is parallel to the asymtotic direction of the
| cubic curve.
|
|  -- the transverse black line through "cubic_ori" is
| the (affine covariant) "cubic_coaxis"; its direction
| (and orientation) is that of the second derivative
| at "cubic_ori".
|
| This "cubic_coaxis" is thus oriented to enter the
| convex hull of the extrapolated curve at "cubic_ori".
|
| The orientation of "cubic_axis" is chosen by
| convention so that the angle from "cubic_axis" to
| "cubic_coaxis" is positive (counterclockwise).
|
|  -- the (affine covariant) double point closing the loop
| lies on the cubic coaxis; it is marked in green.
|
|  -- the two points on the curve where it runs parallel
| with the cubic coaxis are also marked in green.
|
| The unique affine linear reflexion fixing the
| "cubic_coaxis" pointwise (as mirror) and respecting
| "cubic_axis" exchanges these two points and also (by
| construction) the two extremities of the extrapolated
| cubic bezier segment.
|
|
| LOWER HALF
|
| The parabola described by the first time
| derivative curve  F'(t)  of the bezier segment
| F(t)  occupies the lower half of the figure.
| As above, it runs from a blue point at
| time t=0 to a red point at time t=1.
|
| The three control points of F'(t) are joined in sequence
| by two linear segments that form the "control bilareral"
| of F'(t), marked in blue.
|
| The origin "ori" marked as a big light blue point
| together with the parabolic path F'(t) constitute the
| "hodograph" of F(t); it determines F(t) -- the origin
| playing a highly significant role!  More precisely, the
| hodigraph determines, by integration with respect to
| time, the curve F(t), up to an arbitrary translation;
| and reciprocally, F(t) determines the hodograph by time
| derivation, with no ambiguity. Corresponding elements in
| the upper and lower half figures bear the same color
| coding.
|
| This origin "ori" lies *inside* the parabola in the
| present "loop" case; and the line on the origin parallel
| to "parab_coaxis" cuts the parabola at the two times of
| parallelism with this coaxis;  these two points are in
| green.
|
| The parabola axis "parab_axis" is the line (in black) on
| the origin "ori"; it is parallel to the axis direction
| of the parabola, and also to the cubic axis.
|
| The parabola origin  "parab_ori" in black is the point
| of intersection of "parab_axis" with the parabola.
|
| The parabolic coaxis "parab_coaxis" is the line (in
| black) on "parab_ori", which is tangent there to the
| parabola. It is parallel to "cubic_coaxis".

----------------

```