ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* troubles with cutafter
@ 2020-10-27 13:06 Damien Thiriet
  2020-10-27 14:23 ` Taco Hoekwater
  0 siblings, 1 reply; 2+ messages in thread
From: Damien Thiriet @ 2020-10-27 13:06 UTC (permalink / raw)
  To: ntg-context

Hello,


I went into some troubles with cutafter.
Must have missed something obvious.



\starttext
\startMPpage
path p[];
p1:= origin -- (100,0);
p2:= (50,-50) -- (50,100);
draw p1;
draw p2;
draw (p1 cutafter (p1 intersectionpoint p2)) withcolor red;

\stopMPpage
\stoptext

Can someone explain me why the whole path p1 
of this MWE is in red? I expected only its 
first half to be in red, and the whole line is.

Thanks,

Damien Thiriet 

___________________________________________________________________________________
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: troubles with cutafter
  2020-10-27 13:06 troubles with cutafter Damien Thiriet
@ 2020-10-27 14:23 ` Taco Hoekwater
  0 siblings, 0 replies; 2+ messages in thread
From: Taco Hoekwater @ 2020-10-27 14:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users



> On 27 Oct 2020, at 14:06, Damien Thiriet <damien@thiriet.web4me.fr> wrote:
> 
> Hello,
> 
> 
> I went into some troubles with cutafter.
> Must have missed something obvious.

Not so obvious: due to rounding/precision errors, the result of “intersectionpoint”
is rarely the actual point. It finds a point “close to” the actual intersection
of the two paths.

The intersectionpoint calculation works by limited recursive bisection of the two paths, 
and thus it  finds imprecise results in all but the most trivial cases. The result may
be an actual point on p1 or p2, or on both, or even on neither.

The better solution is to use intersectiontimes and subpath:

  draw subpath (0, xpart (p1 intersectiontimes p2)) of p1 withcolor red;

Best wishes,
Taco
___________________________________________________________________________________
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-10-27 14:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 13:06 troubles with cutafter Damien Thiriet
2020-10-27 14:23 ` Taco Hoekwater

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