summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2007-11-29 14:19:49 +0000
committerNorbert Preining <preining@logic.at>2007-11-29 14:19:49 +0000
commit46c01a8363a5c5724540e0522784de465f6cf463 (patch)
tree008a4ae83e0420277e691dcd32102b2680b221b1 /Master/texmf-dist/metapost
parent226da5591b002ccf13fe6c8c9532f5088d7ebcb5 (diff)
bpolynomial update from CTAN
git-svn-id: svn://tug.org/texlive/trunk@5644 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r--Master/texmf-dist/metapost/bpolynomial/bpolynomial.mp27
1 files changed, 23 insertions, 4 deletions
diff --git a/Master/texmf-dist/metapost/bpolynomial/bpolynomial.mp b/Master/texmf-dist/metapost/bpolynomial/bpolynomial.mp
index 6840bb04038..f1c0129bb94 100644
--- a/Master/texmf-dist/metapost/bpolynomial/bpolynomial.mp
+++ b/Master/texmf-dist/metapost/bpolynomial/bpolynomial.mp
@@ -9,15 +9,21 @@
if known bpolynomial_fileversion: endinput fi;
string bpolynomial_fileversion;
-bpolynomial_fileversion := "v0.3 (2007/11/26)";
+bpolynomial_fileversion := "v0.4 (2007/11/28)";
message "Loading bpolynomial " & bpolynomial_fileversion;
+vardef newBPolynomial@#(expr a, b, c, d)=
+ defineBPolynomial.@#(a, b, c, d);
+ defineBPolynomial.@#'(0, 3a, 2b, c);
+ defineBPolynomial.@#''(0, 0, 6a, 2b);
+ defineBPolynomial.@#'''(0, 0, 0, 6a);
+enddef;
+
%%% This macro defines two macros @#.eval and @#.getPath.
%%% Parameters are the coefficients of the polynomial a*x^3 + b*x^2 + c*x + d.
-vardef newBPolynomial@#(expr ca,cb,cc,cd)=
+vardef defineBPolynomial@#(expr ca,cb,cc,cd)=
numeric @#.a, @#.b, @#.c, @#.d;
-
%%% Save coefficients for later access.
%%% For instance, variable @#.a refers to coefficient a of polynomial @#.
@#.a := ca;
@@ -25,12 +31,14 @@ numeric @#.a, @#.b, @#.c, @#.d;
@#.c := cc;
@#.d := cd;
- %%% Define a macro that returns polynomial values.
+
+ %%% Define macro that returns values of polynomial @#.
%%% Parameter is an x value.
vardef @#.eval(expr x)=
(((@#.a*x + @#.b)*x + @#.c)*x + @#.d)
enddef;
+
%%% Define a macro that returns a path of the polynomial
%%% on a given intervall [xl, xr].
vardef @#.getPath(expr xl,xr)=
@@ -63,4 +71,15 @@ numeric @#.a, @#.b, @#.c, @#.d;
(xA,yA)..controls (xB,yB) and (xC,yC)..(xD,yD)
enddef;
+
+ %%% Define macro that returns a path tangent to @# at point (x, f(x))
+ %%% covering interval (x+xm, x+xp).
+ vardef @#.getTangent(expr x, xm, xp)=
+ save m, y;
+ numeric m, y;
+ m := (3@#.a*x + 2@#.b)*x + @#.c;
+ y := @#.eval(x);
+ (x+xm, y + m*xm) -- (x+xp, y + m*xp)
+ enddef;
+
enddef;