[metapost] Extending a path
Yasir Malik
ymalik at stevens.edu
Fri Nov 26 17:13:54 CET 2010
> Or if you want to extend pp with a straight line for
> a distance d:
> path qq;
> n := length pp;
> qq := (0,0)--(d*unitvector(direction n of pp));
> pp & (qq shifted point n of pp)
>
Why is it in the following program, the commented out code gives the error
"! Paths don't touch; `&' will be changed to `..'." but the code above it
works fine?
beginfig(1);
u = 1cm;
path qq, pp;
numeric n, d;
pp := (3u, 4u)--(8u, 10u);
d := 1u;
n := length pp;
pickup pencircle scaled 4pt;
drawdot(point 0 of pp);
drawdot(point n of pp);
pickup pencircle scaled 1pt;
qq := (0,0)--(d*unitvector(direction n of pp));
draw pp & (qq shifted point n of pp);
%qq := (0, 0)--(-d*unitvector(direction n of pp));
%draw pp & (qq shifted point 0 of pp);
endfig;
end
If I just draw the following:
qq := (0, 0)--(-d*unitvector(direction n of pp));
draw (qq shifted point 0 of pp);
the path correctly appears at the point 0=(3, 4) of pp. If I change the &
to --, I notice the line produced is slightly more jagged than path
produced by draw pp & (qq shifted point n of pp);
Thanks,
Yasir
More information about the metapost
mailing list