diff options
author | Karl Berry <karl@freefriends.org> | 2023-02-18 18:40:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-02-18 18:40:50 +0000 |
commit | 14e4f63a357437636c6cb5c2130c3865c0079ef3 (patch) | |
tree | df263fab51006eea4be1bc1c481a07304401326f /Master/texmf-dist/asymptote/graph.asy | |
parent | 7f326f6942dc81b97699f20698fe017b15ef74fa (diff) |
asymptote 2.85 support files, windows binaries
git-svn-id: svn://tug.org/texlive/trunk@65878 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/graph.asy')
-rw-r--r-- | Master/texmf-dist/asymptote/graph.asy | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/Master/texmf-dist/asymptote/graph.asy b/Master/texmf-dist/asymptote/graph.asy index 1d4dfc1bfd3..433aa2fc20f 100644 --- a/Master/texmf-dist/asymptote/graph.asy +++ b/Master/texmf-dist/asymptote/graph.asy @@ -2186,45 +2186,49 @@ 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 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; + real dx=(b.x-a.x)/(nx-1); + real dy=(b.y-a.y)/(ny-1); bool all=cond == null; real scale; - if(maxlength > 0) { - real size(pair z) { - path g=vector(z); - return abs(point(g,size(g)-1)-point(g,0)); - } - real max=size(a); - for(int i=0; i <= nx; ++i) { - real x=interp(a.x,b.x,i*dx); - for(int j=0; j <= ny; ++j) - max=max(max,size((x,interp(a.y,b.y,j*dy)))); + transform t=scale(dx,dy); + pair size(pair z) { + path g=t*vector(z); + int n=size(g); + pair w=n == 1 ? point(g,0) : point(g,n-1)-point(g,0); + return (abs(w.x),abs(w.y)); + } + pair max=size(a); + for(int i=0; i < nx; ++i) { + real x=a.x+i*dx; + for(int j=0; j < ny; ++j) { + real y=a.y+j*dy; + max=maxbound(max,size((x,y))); } - scale=max > 0 ? maxlength/max : 1; - } else scale=1; + } + + if(max.x == 0) + scale=max.y == 0 ? 1.0 : dy/max.y; + else if(max.y == 0) + scale=dx/max.x; + else + scale=min(dx/max.x,dy/max.y); - 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); + for(int i=0; i < nx; ++i) { + real x=a.x+i*dx; + for(int j=0; j < ny; ++j) { + real y=a.y+j*dy; pair z=(x,y); if(all || cond(z)) { - path g=scale(scale)*vector(z); + path v=scale(scale)*t*vector(z); + path g=size(v) == 1 ? (0,0)--v : v; if(truesize) draw(z,pic,g,p,arrow); else |