Hi Hraban,
follow up on chat ...
\starttext
\startMPcode % {doublefun}
mfun_bend_tolerance := 0.002; % double : 131/65536
mfun_bend_tolerance := 0.02 ; % scaled
vardef iscurved(expr p, i, tolerance) =
save d, b, r ; boolean r ; r := true ;
d := (xpart precontrol i of p) - (xpart postcontrol (i-1)
of p) ;
b := abs((xpart postcontrol (i-1) of p) - (xpart point (i-1)
of p) - d);
if b <= tolerance :
b := abs((xpart point i of p) - (xpart precontrol i of p) - d) ;
if b <= tolerance :
d := (ypart precontrol i of p) - (ypart
postcontrol (i-1) of p) ;
b := abs((ypart postcontrol (i-1) of p) - (ypart point
(i-1) of p) - d) ;
if b <= tolerance :
b := abs((ypart point i of p) - (ypart precontrol i of
p) - d) ;
if b <= tolerance :
r := false ;
fi ;
fi ;
fi ;
fi ;
r
enddef ;
path p ; p := fullcircle scaled 10cm ;
path q ; q := fullsquare scaled 10cm ;
path r ; r := fullsquare scaled 10cm randomized 1cm ;
draw p ; draw q ; draw r ;
message(iscurved(p,2,0.02));
message(iscurved(q,2,0.02));
message(iscurved(r,2,0.02));
\stopMPcode
\stoptext
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________