[metapost] Extending a path

Yasir Malik ymalik at stevens.edu
Tue Nov 30 20:08:17 CET 2010


The problem I was having in the last message on this thread was that I 
could not extend a line at point 0, but I could at point 1, which is the 
end of the line.  Metapost said the extended line and the original line 
did not meet.  This problem even happened when I reversed the path and 
tried to extend at point 1.

I'm still not sure why this is happening, but I got around this problem by 
creating a new path, instead of extending the path:

def extendLine(expr p, d, begin) =
begingroup
save q, newp;
path q, newp;

if begin:
   q := (-d*unitvector(direction 0 of p))--(0, 0);
   q := q shifted point 0 of p;
   newp := (point 0 of q)--(point length p of p);
else:
   q := (0, 0)--(d*unitvector(direction 0 of p));
   q := q shifted point (length p) of p;
   newp := (point 0 of p)--(point length q of q);
fi

newp

endgroup
enddef;


Regards,
Yasir


More information about the metapost mailing list