From: Fabrice L <fabrice.alpha@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Check if two paths intersect in Metafun
Date: Fri, 25 Dec 2020 12:10:18 -0500 [thread overview]
Message-ID: <8FB08E16-F58D-4394-82E1-3B9A98B979B6@gmail.com> (raw)
In-Reply-To: <CAKyqqaZviS3PXsr7COnNq2MLXgFw8hyjw-ZmeZ7ixa5VzrQYjw@mail.gmail.com>
Hi,
> Le 25 déc. 2020 à 08:48, Jairo A. del Rio <jairoadelrio6@gmail.com> a écrit :
>
> Hi, list. I've got a question about paths and intersections. The following:
>
> \starttext
> \startMPpage
> path p[];
>
> p[1] = fullcircle scaled 2cm;
> p[2] = unitsquare shifted (4cm,6cm);
>
> if (known (p[1] intersectionpoint p[2])):
>
> draw textext("yes");
>
> else:
>
> draw textext("no");
> fi;
>
> \stopMPpage
> \stoptext
>
> yields an error message: "The paths don't intersect". Is there a way to intercept this error message and trigger an action instead? Thank you in advance.
Instead of using « intersectionpoint » use « Intersectiontimes », this will give you the « time » of the intersection of the two paths. If the paths do not intersect, than the value is (-1,-1). So you could do something like:
pair checkintersec ;
checkintersec := p[1] intersectiontimes p[2] ;
If xpart(checkintersec) <> -1 :
draw textext("yes »);
else:
draw textext(« non »);
fi;
Fabrice.
>
> Best regards,
>
> Jairo
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________
prev parent reply other threads:[~2020-12-25 17:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-25 13:48 Jairo A. del Rio
2020-12-25 17:10 ` Fabrice L [this message]
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=8FB08E16-F58D-4394-82E1-3B9A98B979B6@gmail.com \
--to=fabrice.alpha@gmail.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).