[metapost] Extending a path
Boguslaw Jackowski
B_Jackowski at GUST.org.pl
Sun Nov 14 15:52:25 CET 2010
Hi, everybody,
DL> Finally, I have played around with cubic extrapolation:
DL> taking the last cubic Bezier segment in a path, extracting
DL> its mathematical formula, and extending the time variable
DL> past 1. If that segment is a straight line, this will
DL> produce a straight line extension. This is a little involved
DL> (and seldom what anyone but a mathematician wants), but I can
DL> provide some code if needed.
Just a comment: extending a B\'ezier path is an operation
that is not so infrequently needed in programming fonts.
Hence, I included a macro |extrapolate| into my "font library"
that computes a ``superpath'' (as opposed to ``subpath'')
for a single B\'ezier segment in such a way that for
0<=t1<=t2<=1 the following identity holds:
subpath (t1,t2) of (extrapolate (t1,t2) of b) = b.
%
vardef extrapolate expr t of b = % |t| pair, |b| B\'ezier segment
clearxy;
Casteljau(xpart(t)) = point 0 of b;
Casteljau(1/3[xpart(t),ypart(t)]) = point 1/3 of b;
Casteljau(2/3[xpart(t),ypart(t)]) = point 2/3 of b;
Casteljau(ypart(t)) = point 1 of b;
z0 .. controls z1 and z2 .. z3
enddef;
%
def Casteljau(expr t) =
t[t[t[z0,z1], t[z1,z2] ], t[t[z1,z2], t[z2,z3] ] ]
enddef;
%
The macro |extrapolate| works quite reasonably
if the dependence between B\'ezier's time parameter
and B\'ezier's length is less or more regular.
Otherwise, weird (and likely unwanted) effects
can be expected.
Cheers -- Jacko
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Bogus\l{}aw Jackowski: B_Jackowski at GUST.ORG.PL
----------------------------------------------------------------
Hofstadter's Law: It always takes longer than you expect, even
when you take into account Hofstadter's Law.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
More information about the metapost
mailing list