[metapost] workaround for turningnumber bug
Werner LEMBERG
wl at gnu.org
Fri Feb 4 00:50:28 CET 2005
> \gamma(t) = K0 + K1 t + K2 t^2 + K3 t^3
>
> K0 = P
> K1 = 3 (P+ - P)
> K2 = 3 (Q- - 2P+ + P)
> K3 = Q - 3 Q- + 3 P+ - P
>
> The conditions for self-intersection are given by the existence of
> solutions in [0,1] of the equation
>
> (*) (K2 x K3)^2 t^2 +
> (K1 x K3)(K2 x K3) t +
> (K1 x K3)^2 - (K1 x K2)(K2 x K3) = 0
>
> The required conditions are (a-e) above, which I have not been able
> to simplify in any sensible way. IMHO it's easier to just solve (*)
> (if (a) is verified) and then check manually if the solutions are
> both between 0 and 1.
Your formulae are very useful, thanks! What about the following: We
either have two different solutions (a real self-intersection) or a
double-solution (a cusp) in (*):
+ +
---------+---------+---------
+ +
+
+ +
+ +
+ +
--------------+--------------
The first derivate of (*), set to zero, gives the point where the
tangent is parallel to the x axis, and this point must be in the
interval ]0,1[, between the two solutions. After some simple math we
have the constraint
K1 x K3
0 < - ------- < 2
K2 x K3
as a quick first test whether a self-intersection does exist.
Werner
More information about the metapost
mailing list