[metapost] turningnumber revisited

laurent at math.toronto.edu laurent at math.toronto.edu
Tue Jun 28 08:25:57 CEST 2011

Hello again Luigi, Bogo, Dan, and others

     Thanks for your thoughts.  Perhaps the the
following principles can clarify our discussion.

     There seem to be several sound principles that
should and can guide the implementation of primitives
on a graphics program. Here are some vaguely stated
desiderata that hopefully apply to "turningnumber"
in Metapost:

(1) Since the MetaPost primitive "turningnumber"
parallels a known mathematical invariant the "turning
number" of suitable cyclic plane paths, the main
properties of "turningnumber" should correspond as
exactly as possible to those of the mathematical

(2) The MetaPost program should issue a warning when
"turningnumber" fails, i.e. seems to be undefined
and/or to violate the properties of the mathematical
concept.  This should happen only 'exceptionally'.

(3) Metapost documentation should give a mathematical
definition of the invariant, including specification
of cases when the invariant is undefined (and why).
There should be a parallel description of the
implementing algorithms and of cases when
turningnumber can fail, although the mathematical
invariant "turning number" exists and obeys its
announced properties.

(4) The documentation should be clear. And as simple
as possible --- but as Einstein once quipped NOT

     Similar desidarata apply to the mathematical
"winding number" concept and its projected MetaPost
implementation "windingnumber". There, somewhat
miraculously, no puzzling cases have surfaced

     Interestingly, Nelson Beebe has recently recalled
for us an instance when Knuth went to enormous
lengths to help computer practice respect somewhat
similar principles.

  author =       "Donald E. Knuth",
  title =        "A Simple Program Whose Proof Isn't",
  crossref =     "Feijen:1990:BOB",
  chapter =      "27",
  pages =        "233--242",
  year =         "1990",

Notice that Knuth there regards adherence of an
algorithm/program to its specifications to be a
mathematical theorem worth proving. I have not been
so stringent in (1) -- (4). Nor was Knuth
with his turningnumber primitive in Metafont:)

Laurent S.

More information about the metapost mailing list