From: Fabrice L via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Fabrice L <fabrice.alpha@gmail.com>
Subject: MP: problem connecting paths.
Date: Sun, 19 Dec 2021 23:30:24 -0500 [thread overview]
Message-ID: <694BE441-A172-40EC-8365-3489BA0ADCE9@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2648 bytes --]
Dear list,
I have a problem connecting path with the operator « & » (page 16 Metafun manual). The problem is illustrated by the code (and the joined PDF) which follows.
I draw random cycled forms (left part of the figure) and when they interact, they are modified to « fit together » (right part of the figure) . When building these new forms, I connect paths (usually two or three depending on position 0 of the path); the last point a path is the same as the first point of the next path ; for exemple, to modify the blue circle, named « circleA », I take the circle A from P1 to P2, then a segment from P2 to P1 and cycle to have a closed path. So I should be able to do :
newcircleA := circleA cutbefore P1 cutafter P2 & (P2 -- P1) & cycle ;
The « & » operator is supposed to work (if I understand correctly) in this case, but I have this error message :
"! Paths don't touch; `&' will be changed to `..’."
Which I do not understand since the paths « touch ». There was a similar question last year, without a clear answer («
METAPOST subpath rounding issue »https://www.mail-archive.com/ntg-context@ntg.nl/msg94294.html).
A solution is to ignore the repeating points :
newcircleA := circleA cutbefore P1 cutafter P2 -- (P2 -- P1) -- cycle ;
but this new shape has 9 points instead of 7. The problem is that I do these operations a number of times, and the length of a path (in the number of points) is increasing and cause trouble when I look for intersections with others shapes.
Here is the MWE:
\startMPpage
path circleA , circleB ;
pair P[];
circleA := fullcircle scaled 1in randomized 3 ;
circleB := fullcircle scaled 1in randomized 3 shifted(0.3in,0.3in) ;
draw circleA withcolor blue ;
draw circleB withcolor red ;
P[1] := circleA intersectionpoint circleB ;
dotlabel.lft("$P_1$",P[1]) ;
dotlabel.rt("$\blue\tfx P_0^A$",point 0 of circleA) ;
P[2] := reverse(circleA) intersectionpoint circleB ;
dotlabel.rt("$P_2$",P[2]) ;
dotlabel.rt("$\red\tfx P_0^B$",point 0 of circleB) ;
path newcircleA , newcircleB ;
% newcircleA := circleA cutbefore P1 cutafter P2 & (P2 -- P1) & cycle ;
% previous line gives an error :
% "! Paths don't touch; `&' will be changed to `..'."
newcircleA := circleA cutbefore P1 cutafter P2 -- (P2 -- P1) -- cycle ;
newcircleA := newcircleA xshifted 2in ;
draw newcircleA withcolor darkgreen ;
newcircleB := (circleB cutafter P1) -- (P1 -- P2) -- (circleB cutbefore P2 ) & cycle ;
newcircleB := newcircleB xshifted 2in ;
draw newcircleB withcolor black ;
drawpoints newcircleA ; drawpointlabels newcircleA ;
\stopMPpage
[-- Attachment #2: test.pdf --]
[-- Type: application/pdf, Size: 12968 bytes --]
[-- Attachment #3: Type: text/plain, Size: 54 bytes --]
I would appreciate any help ! Thanks !
Fabrice.
[-- Attachment #4: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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 reply other threads:[~2021-12-20 4:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-20 4:30 Fabrice L via ntg-context [this message]
2021-12-20 7:21 ` Mikael Sundqvist via ntg-context
2021-12-20 14:45 ` Fabrice L via ntg-context
2021-12-20 17:14 ` Mikael Sundqvist via ntg-context
2021-12-20 17:59 ` Fabrice L via ntg-context
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=694BE441-A172-40EC-8365-3489BA0ADCE9@gmail.com \
--to=ntg-context@ntg.nl \
--cc=fabrice.alpha@gmail.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).