[metapost] turningnumber revisited
laurent at math.toronto.edu
laurent at math.toronto.edu
Thu Jun 30 08:00:23 CEST 2011
Hi all,
Jacko wrote <Tue, 28 Jun 2011 20:52:38 +0200 (CEST)>:
> Perhaps the built-in windingnumber function could
> have a global parameter determining the minimal
> distance (adequately to the engine precision), and
> in the case of emergency (unlike the turningnumber
> function) could return undefined result.
Agreed for the windingnumber function.
Some regions of instability for turningnumber are
necessary for turningnumber to vary as it does.
Indeed cyclic piecewise bezier cubic paths are a
connected and even contractible space; hence any
map of it to the integers that has no
discontinuities would be constant.
So I would tend to have turningnumber flag paths
that have loops that are 'almost' 'near cusps'.
Me> However, it seems to me likely that algorithms
> specially tailored to QUICKLY calculate winding
> number of piecewise QUADRATIC bezier paths will be
> advantageous for MetaPost's turningnumber primitive.
Jacko wrote <Tue, 28 Jun 2011 11:08:18 +0200 (CEST)>
> Don't understand... You'd need to _approximate_
> cubic path by quadratic ones which seems to be a rather
> cumbersome and complex task. Can it be done robustly?
Remember always that every linear or quadratic
bezier path is canonicly a cubic bezier path! No
approximation is involved.
I indicated that the wanted "turning number" of a
piecewise bezier path p with n bezier
segments is nothing more than a winding number
about the origin of a certain piecewise quadratic
path pp in the "velocity plane". This pp has
2n - 1 (or less) segments; it is a fairly
canonical derivative or velocity path of p. The
calculation is easy when p lies in my 05 June
class \C because the image of pp is then disjoint
from the origin.
But I am currently generalizing to allow p to
have "near cusps" and "near thorns"; they cause
pp to pass through the origin, or to pass
excessively near to the origin. Roughly speaking,
each such "perihelion" passage engenders a
correction term of \pm 180 degrees in the
established 'local' calculation of winding angles
on pp for the case when pp is disjoint from the
origin.
If all goes well, the extended calculation of
turningnumber will then have have the nice
sane properties properties I stated for my very
abstract extension of turning number from \C to
the huge class \D and none of the crazy ones of
current MF and MP.
Cheers
LS
More information about the metapost
mailing list