From: ntg@scorecrow.com
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: METAPOST subpath rounding issue
Date: Thu, 7 May 2020 23:46:30 +0100 [thread overview]
Message-ID: <D2FA66B7-82B8-41C9-BC13-D797C0F93B9B@scorecrow.com> (raw)
In-Reply-To: <4D3E7ACE-B8F8-4CDC-9067-EDF6B87D445E@rna.nl>
> On 7 May 2020, at 20:28, Gerben Wierda <gerben.wierda@rna.nl> wrote:
>
> I have a METAPOST algorithm that splits a path at a certain time in two, does something with both ends (not the ends where they were split) and then rejoins them.
>
> In very rare cases this crashes, because the subpath doesn’t work as expected.
>
> firstPart := subpath (0,halfWayTime) of workingConn;
> secondPart := subpath (halfWayTime,pathTimeLen) of workingConn;
>
> may sometimes result in something like this:
>
> metapost log > >> Path at line 0:
> metapost log > (273,-427)..controls (259.50666666666666,-427) and (246.01333333333335,-427)
> metapost log > ..(232.52000000000001,-427)
> metapost log >
> metapost log > >> Path at line 0:
> metapost log > (232.51999999999998,-427)..controls (161.68000000000001,-427) and (90.840000000
> metapost log > 000003,-427)
> metapost log > ..(20,-427)
>
> As can be seen in these (rare) cases the two calls to subpath result in a different point resulting from both. so, when I later try to rejoin them with & it fails:
>
> metapost log > ! Paths don't touch; '&' will be changed to '..'.
> metapost log > <to be read again>
>
> Which means subpath doesn’t always exactly do what I expect it to do (and many explanations, but not the official manual) state. Again, this is rare.
>
> I’ve done this to work around it but I wondered if there was a better (reliable) solution
>
> save cutFirstPart; path cutFirstPart; cutFirstPart := firstPart maxcutbefore fromPicOutline;
> save cutSecondPart; path cutSecondPart; cutSecondPart := secondPart maxcutafter toPicOutline;
> if ((xpart point 0 of cutSecondPart) <> (xpart point infinity of cutFirstPart))
> or ((ypart point 0 of cutSecondPart) <> (ypart point infinity of cutFirstPart)):
> resultConn := cutFirstPart--cutSecondPart;
> else:
> resultConn := cutFirstPart & cutSecondPart;
> fi
A crude test of
path pb;
pb:=(5.5cm,0cm)--(5.5cm,0cm)--(10.5cm,0cm);
draw pb;
gives no errors so why not just join using -- all the time and save the test?
--
Bruce Horrocks
Hampshire, UK
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2020-05-07 22:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 19:28 Gerben Wierda
2020-05-07 22:46 ` ntg [this message]
2020-05-08 12:58 ` Gerben Wierda
2020-05-09 21:53 ` Bruce Horrocks
2020-05-09 22:01 ` Bruce Horrocks
2020-05-10 18:17 ` Gerben Wierda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D2FA66B7-82B8-41C9-BC13-D797C0F93B9B@scorecrow.com \
--to=ntg@scorecrow.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).