From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107257 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: METAPOST subpath rounding issue Date: Thu, 7 May 2020 21:28:40 +0200 Message-ID: <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="===============1166560812776153716==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="50092"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu May 07 21:29:08 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 1jWmCh-000Cqy-Vv for gctc-ntg-context-518@m.gmane-mx.org; Thu, 07 May 2020 21:29:08 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 27FAC183B98; Thu, 7 May 2020 21:28:46 +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 PbbK7FploYbl; Thu, 7 May 2020 21:28:43 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 70D9F183BA5; Thu, 7 May 2020 21:28:43 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3B792183B98 for ; Thu, 7 May 2020 21:28:42 +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 QP1wMU3sfxje for ; Thu, 7 May 2020 21:28:41 +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 86AD2183B15 for ; Thu, 7 May 2020 21:28:41 +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 0C7323E3EA9D for ; Thu, 7 May 2020 21:28:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1588879721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=a3k7CWwEa7qWkq+anxuSVpzWhbY89kt7Ss4H449Hr3M=; b=pi8eI0v+ARRYsohPsSgOXlWAwLSoqoqKINPPYu46tTA6kQ7jCP5qBEhztSEXwYeUZ6/Ie2 wVnyLPa1oQs/hHzgxzDstVjMxiX1s8OyRy686UeY2wMizRFEfYfapuTflxzXdG+jWC1yQg DVlMll+cpcRwat1D+nKdoUVqNFVy0BL0RY0/sSRcBbynNDGxss27K3pvLRXeY5rK4n4enX hRFLJzIq50d03fzmiOV6T1Xw8+VIeZFi4Yi585s4I6xO2lOxYK5m+sWtWky5wjX9/tBn7o TQtNTP89Uiojuh3ZtAKBurKTJ1OlAtK0Rj3RJc5OG4aTxL/0vk5Wvli9h3Z0aQ== 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:107257 Archived-At: --===============1166560812776153716== Content-Type: multipart/alternative; boundary="Apple-Mail=_6EE1B793-DFF4-4689-8670-E5389D567992" --Apple-Mail=_6EE1B793-DFF4-4689-8670-E5389D567992 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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 >=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) 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 > =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. 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 G= --Apple-Mail=_6EE1B793-DFF4-4689-8670-E5389D567992 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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=99= ve 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

G
= --Apple-Mail=_6EE1B793-DFF4-4689-8670-E5389D567992-- --===============1166560812776153716== 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== --===============1166560812776153716==--