From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107265 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Re: METAPOST subpath rounding issue Date: Fri, 8 May 2020 14:58:08 +0200 Message-ID: <1B24BCDF-DBF8-4D69-A162-66DB44E8A6CE@rna.nl> References: <4D3E7ACE-B8F8-4CDC-9067-EDF6B87D445E@rna.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="===============0962100433704973699==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="5285"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri May 08 14:58:48 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jX2aT-00013j-N6 for gctc-ntg-context-518@m.gmane-mx.org; Fri, 08 May 2020 14:58:45 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2FF18183C11; Fri, 8 May 2020 14:58:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eFra2auFVCM9; Fri, 8 May 2020 14:58:13 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 377F6183C06; Fri, 8 May 2020 14:58:13 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2C099183C04 for ; Fri, 8 May 2020 14:58:12 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 57ZcogLQMYZc for ; Fri, 8 May 2020 14:58:11 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=213.125.118.53; helo=mail.rna.nl; envelope-from=gerben.wierda@rna.nl; receiver= Original-Received: from mail.rna.nl (mail.rna.nl [213.125.118.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 28DF2183BFF for ; Fri, 8 May 2020 14:58:11 +0200 (CEST) Original-Received: from hermione.rna.nl (hermione.rna.nl [192.168.2.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.rna.nl (Postfix) with ESMTPSA id 4B6EC3E4AE8F for ; Fri, 8 May 2020 14:58:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1588942689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=81n0yyUfOzyM1EphRVMiCwStHgPpMgebouneOw7xvFE=; b=CF0sWBKIccRYjlqp9gTCwYEUILUD6VFHb/TJKgOuReO2bVO2UHig4kjYY8YvudWvmISKsa AIodNpmrDfSuuNeRdMIpd10BDDGUzk5r753m0dXd7N1EzyjKDEgjsFdGGH0nV1O6qn10K9 eIlRzEvNQN6+pYm8aU3bDdvmJF1Rj/XGGJNxX+2cJGYD1uDWMdTHRS5LsIAwPesjK77N0U HwJctQOMkZhU2KGqy29e0KXw4L2yo5SlkLjc3t7cMcx1wLThCNZIvXB5i2f3Vs42bIGJF3 1AbQXjcR21JhodMeVb4RrTFk10rTIUeepVNKwNmghaTrOOeWuBmmInyu3ttHsQ== In-Reply-To: X-Mailer: Apple Mail (2.3445.104.14) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:107265 Archived-At: --===============0962100433704973699== Content-Type: multipart/alternative; boundary="Apple-Mail=_7345E5BE-1706-4582-A1A5-8D73222CB054" --Apple-Mail=_7345E5BE-1706-4582-A1A5-8D73222CB054 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 8 May 2020, at 00:46, ntg@scorecrow.com wrote: >=20 >=20 >=20 >> On 7 May 2020, at 20:28, Gerben Wierda wrote: >>=20 >> 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. >>=20 >> In very rare cases this crashes, because the subpath doesn=E2=80=99t = work as expected. >>=20 >> firstPart :=3D subpath (0,halfWayTime) of workingConn; >> secondPart :=3D subpath (halfWayTime,pathTimeLen) of = workingConn; >>=20 >> may sometimes result in something like this: >>=20 >> 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 >=20 >> 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) >>=20 >> 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: >>=20 >> metapost log > ! Paths don't touch; '&' will be changed to '..'. >> metapost log > =20 >>=20 >> Which means subpath doesn=E2=80=99t always exactly do what I expect = it to do (and many explanations, but not the official manual) state. = Again, this is rare. >>=20 >> I=E2=80=99ve done this to work around it but I wondered if there was = a better (reliable) solution >>=20 >> save cutFirstPart; path cutFirstPart; cutFirstPart :=3D = firstPart maxcutbefore fromPicOutline; >> save cutSecondPart; path cutSecondPart; cutSecondPart :=3D = 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 :=3D cutFirstPart--cutSecondPart; >> else: >> resultConn :=3D cutFirstPart & cutSecondPart; >> fi >=20 > A crude test of=20 >=20 > path pb; > pb:=3D(5.5cm,0cm)--(5.5cm,0cm)--(10.5cm,0cm); > draw pb; >=20 > gives no errors so why not just join using -- all the time and save = the test? Because the double exact points are also creating (different) problems = in my algorithm as they make the path have 'no direction' at that point = (direction is (0,0). G >=20 > -- > Bruce Horrocks > Hampshire, UK >=20 > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_7345E5BE-1706-4582-A1A5-8D73222CB054 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On 8 May 2020, at 00:46, ntg@scorecrow.com wrote:



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=E2=80=99t work as = expected.

     firstPart :=3D subpath = (0,halfWayTime) of workingConn;
     secondPart :=3D 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=E2=80=99t always = exactly do what I expect it to do (and many explanations, but not the = official manual) state. Again, this is rare.

I=E2=80=99ve done this to work around it but I wondered if = there was a better (reliable) solution

     save cutFirstPart; path = cutFirstPart; cutFirstPart :=3D firstPart maxcutbefore = fromPicOutline;
     save = cutSecondPart; path cutSecondPart; cutSecondPart :=3D 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 :=3D = cutFirstPart--cutSecondPart;
     else:
       resultConn :=3D = cutFirstPart & cutSecondPart;
     fi
A crude test of 

 path pb;
 pb:=3D(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?

Because the = double exact points are also creating (different) problems in my = algorithm as they make the path have 'no direction' at that point = (direction is (0,0).

G


--
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
_______________________________________________________________= ____________________

= --Apple-Mail=_7345E5BE-1706-4582-A1A5-8D73222CB054-- --===============0962100433704973699== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============0962100433704973699==--