ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Check if two paths intersect in Metafun
@ 2020-12-25 13:48 Jairo A. del Rio
  2020-12-25 17:10 ` Fabrice L
  0 siblings, 1 reply; 2+ messages in thread
From: Jairo A. del Rio @ 2020-12-25 13:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 488 bytes --]

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.

Best regards,

Jairo

[-- Attachment #1.2: Type: text/html, Size: 1996 bytes --]

[-- Attachment #2: 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Check if two paths intersect in Metafun
  2020-12-25 13:48 Check if two paths intersect in Metafun Jairo A. del Rio
@ 2020-12-25 17:10 ` Fabrice L
  0 siblings, 0 replies; 2+ messages in thread
From: Fabrice L @ 2020-12-25 17:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-25 17:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-25 13:48 Check if two paths intersect in Metafun Jairo A. del Rio
2020-12-25 17:10 ` Fabrice L

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).