[metapost] New numbersystems strange behaviour of arclength
Karel
horakk at math.cas.cz
Wed Mar 13 10:11:19 CET 2019
Unfortunately, I have almost no experience with other programming than
TeX and mpost:-(
if numbersystem="decimal":
numberprecision:=4;
fi;
gives much better result, but still not as good as scaled.
The computing takes much longer time, for numberprecision:=3 even longer.
Maybe some other member of the list could help?
Karel Horak
luigi scarso napsal(a):
>
>
> On Tue, Mar 12, 2019 at 7:03 PM Karel <horakk at math.cas.cz
> <mailto:horakk at math.cas.cz>> wrote:
>
> Dear Luigi,
>
> the following code
>
> beginfig(0);
> path s;
> s:=fullcircle scaled 30mm;
> for k=0 upto 18: draw origin--point(arctime ((k/36)*arclength s)
> of s)
> of s; endfor
> endfig;
> end
>
> gives very strange results when used with
> numbersystem=decimal or binary (mpost 2.00 for TeXlive 2019).
>
>
>
> if numbersystem="decimal":
> numberprecision:=8;
> fi;
> if numbersystem="binary":
> numberprecision:=8;
> fi;
> beginfig(0);
> path s;
> s:=fullcircle scaled 30mm;
> %tracingall;
> message "==> " & decimal(arclength s);
> for k=1 upto 1:
> message "==> " & decimal(arctime((1/1)*arclength s) of s);
> %%draw origin--point(arctime ((k/36)*arclength s) of s) of s;
> endfor
> endfig;
> end.
>
>
> In mp.w :
> static void mp_get_arc_time (MP mp, mp_number *ret, mp_knot h,
> mp_number arc0_orig)
> :
>
> if (q == h) {
> @<Update |t_tot| and |arc| to avoid going around the cyclic
> path too many times but set |arith_error:=true| and |goto
> done| on
> overflow@>;
>
> @ @<Update |t_tot| and |arc| to avoid going around the cyclic...@>=
> if (number_positive(arc)) {
>
> when q==h
> decimal arc = 0.000004
> scaled: arc = 0
> This gives
> if (number_positive(arc)) true for decimal and false for scaled, so we
> return with different times.
>
> I don't know if it's correct -- iirc this algorithm was designed for
> scaled so different using numbersystems can give different results --
> or if it's not robust even for scaled.
>
> Try for example with
> if numbersystem="decimal":
> numberprecision:=4;
> fi;
>
>
>
> --
> luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/metapost/attachments/20190313/38135d82/attachment.html>
More information about the metapost
mailing list