From: Bernd Donner via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Bernd Donner <bleau1975@googlemail.com>
Subject: [NTG-context] Re: Artifact in flow cell connection
Date: Thu, 17 Oct 2024 16:39:48 +0200 [thread overview]
Message-ID: <CAO4UkVaSomMskeFJJ4tzUM3TDxPc355HKdMAkF7QSNngxCp+JQ@mail.gmail.com> (raw)
In-Reply-To: <981e8392-6a5e-43ff-afc9-abf49386545f@freedom.nl>
[-- Attachment #1.1: Type: text/plain, Size: 3854 bytes --]
Hello Bruce,
Hello Hans,
Thank you very much for your help and input. I tested the proposed patch
with the minimal example, and the glitch indeed disappeared.
I have to admit, I wasn’t aware that metafun could run in different
instances, let alone the existence of both a double instance and a scaled
instance. While your patch is quite clear, the inner workings of metapost
are a mystery to me. I greatly appreciate the quick fix and the explanation.
Best regards,
Bernd
---
This version improves readability, fixes minor typos, and maintains a
polite, professional tone.
On Wed, Oct 16, 2024, 22:34 Hans Hagen via ntg-context <ntg-context@ntg.nl>
wrote:
> Hi Bruce,
>
> > If you change the following MWE line
> >
> > \connection [bt] {compiler}
> >
> > to
> >
> > \connection [br] {compiler}
> >
> > then the glitch goes away, so I suggest that means it is a bug in the
> flow chart module.
>
> Actually not (but you're close) ... so for a moment put your calculator
> (hardware) hat on (although they use decimal clipping and rounding i guess)
>
> You noticed that coming from one directions gives a different result
> than coming from the other:
>
> metapost > message : 1.4999979972839355 1.8181943026455964
> metapost > message : 1.5 2.1818056973544033
>
> Now, why does this fail? We use a double instance here and as we
> calculate intersection points we are too precise compared to scaled
> where we get twice 1.5, so the points collapse in scaled mode and not in
> double. Maybe I need to make some helper for clipping a given precision.
>
> The mp graphic that does the framed loads a metafun double instance so a
> later instance with the same name in the chart (lua) module takes that
> one; when it is the first one it will take the scaled instance (mkiv is
> scaled by default and mkxl defaults to double).
>
> We can run these charts in their own instance (i'll do that).
>
> Here is the patch for mp-char.mpiv that fixes the issue:
>
> def flow_collapse_points = % this can become a core macro
> begingroup ;
> % remove redundant points
> save n ; numeric n ;
> n := 1 ;
> for i=2 upto flow_xypoint :
> % if not (flow_xypoints[i] = flow_xypoints[n]) :
> if abs(flow_xypoints[i] - flow_xypoints[n]) > eps :
> n := n + 1 ;
> flow_xypoints[n] := flow_xypoints[i]
> fi ;
> endfor ;
> flow_xypoint := n ;
> % make straight lines
> % if flow_xypoints[2] = flow_xypoints[flow_xypoint-1] :
> if abs(flow_xypoints[2] - flow_xypoints[flow_xypoint-1]) < eps :
> flow_xypoints[3] := flow_xypoints[flow_xypoint] ;
> flow_xypoint := 3 ;
> fi ;
> endgroup ;
> enddef ;
>
> But best check this! So the bt / tb was a clue indeed.
>
> 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 /
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
>
> ___________________________________________________________________________________
>
[-- Attachment #1.2: Type: text/html, Size: 5511 bytes --]
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2024-10-17 14:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 20:47 [NTG-context] " Bernd Donner via ntg-context
2024-10-15 6:47 ` [NTG-context] " Bernd Donner via ntg-context
2024-10-16 17:48 ` Bruce Horrocks
2024-10-16 18:47 ` Hans Hagen
2024-10-16 20:28 ` Hans Hagen via ntg-context
2024-10-17 14:39 ` Bernd Donner via ntg-context [this message]
2024-10-12 7:03 wangzhongtian
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=CAO4UkVaSomMskeFJJ4tzUM3TDxPc355HKdMAkF7QSNngxCp+JQ@mail.gmail.com \
--to=ntg-context@ntg.nl \
--cc=bleau1975@googlemail.com \
/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).