summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/base/graph.asy
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-18 23:33:08 +0000
committerKarl Berry <karl@freefriends.org>2009-05-18 23:33:08 +0000
commit0a3a4a0193ef03921995cac67f8c91c6e352d059 (patch)
tree4fd204ddd01ff808c75e91ce290a9b28a1e90696 /Build/source/utils/asymptote/base/graph.asy
parent7c769b8e95cd5bd87da30c618e5198d6d12461e1 (diff)
asymptote 1.73
git-svn-id: svn://tug.org/texlive/trunk@13217 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/base/graph.asy')
-rw-r--r--Build/source/utils/asymptote/base/graph.asy33
1 files changed, 22 insertions, 11 deletions
diff --git a/Build/source/utils/asymptote/base/graph.asy b/Build/source/utils/asymptote/base/graph.asy
index a778dd89261..805cf15f612 100644
--- a/Build/source/utils/asymptote/base/graph.asy
+++ b/Build/source/utils/asymptote/base/graph.asy
@@ -2135,17 +2135,25 @@ picture vectorfield(path vector(real), path g, int n, bool truesize=false,
return pic;
}
+real maxlength(pair a, pair b, int nx, int ny)
+{
+ return min((b.x-a.x)/nx,(b.y-a.y)/ny);
+}
+
+// return a vector field over box(a,b).
picture vectorfield(path vector(pair), pair a, pair b,
- int nx=nmesh, int ny=nx,
- bool autoscale=true, bool truesize=false,
- pen p=currentpen, arrowbar arrow=Arrow,
- margin margin=PenMargin)
+ int nx=nmesh, int ny=nx, bool truesize=false,
+ real maxlength=truesize ? 0 : maxlength(a,b,nx,ny),
+ bool cond(pair z)=null, pen p=currentpen,
+ arrowbar arrow=Arrow, margin margin=PenMargin)
{
picture pic;
real dx=1/nx;
real dy=1/ny;
+ bool all=cond == null;
real scale;
- if(autoscale) {
+
+ if(maxlength > 0) {
real size(pair z) {
path g=vector(z);
return abs(point(g,size(g)-1)-point(g,0));
@@ -2156,18 +2164,21 @@ picture vectorfield(path vector(pair), pair a, pair b,
for(int j=0; j <= ny; ++j)
max=max(max,size((x,interp(a.y,b.y,j*dy))));
}
- pair lambda=b-a;
- scale=min(lambda.x/nx,lambda.y/ny)/max;
+ scale=max > 0 ? maxlength/max : 1;
} else scale=1;
+
for(int i=0; i <= nx; ++i) {
real x=interp(a.x,b.x,i*dx);
for(int j=0; j <= ny; ++j) {
real y=interp(a.y,b.y,j*dy);
pair z=(x,y);
- if(truesize)
- draw(z,pic,vector(z),p,arrow);
- else
- draw(pic,shift(z)*scale(scale)*vector(z),p,arrow,margin);
+ if(all || cond(z)) {
+ path g=scale(scale)*vector(z);
+ if(truesize)
+ draw(z,pic,g,p,arrow);
+ else
+ draw(pic,shift(z)*g,p,arrow,margin);
+ }
}
}
return pic;