diff options
author | Karl Berry <karl@freefriends.org> | 2009-05-18 23:33:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-05-18 23:33:08 +0000 |
commit | 0a3a4a0193ef03921995cac67f8c91c6e352d059 (patch) | |
tree | 4fd204ddd01ff808c75e91ce290a9b28a1e90696 /Build/source/utils/asymptote/base | |
parent | 7c769b8e95cd5bd87da30c618e5198d6d12461e1 (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')
-rw-r--r-- | Build/source/utils/asymptote/base/geometry.asy | 115 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/graph.asy | 33 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/graph3.asy | 52 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/plain_Label.asy | 4 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/plain_boxes.asy | 2 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/three.asy | 105 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/three_light.asy | 17 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/trembling.asy | 20 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/version.asy | 2 |
9 files changed, 200 insertions, 150 deletions
diff --git a/Build/source/utils/asymptote/base/geometry.asy b/Build/source/utils/asymptote/base/geometry.asy index a4860557e1f..12e35339dcc 100644 --- a/Build/source/utils/asymptote/base/geometry.asy +++ b/Build/source/utils/asymptote/base/geometry.asy @@ -1,20 +1,21 @@ -// Copyright (c) 2007, Philippe Ivaldi. -// Version: : geometry.asy,v 0.1 2007/09/01 Philippe Ivaldi Exp $ +// geometry.asy -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 3 of the License, or (at -// your option) any later version. +// Copyright (C) 2007 +// Author: Philippe IVALDI 2007/09/01 + +// This program is free software ; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation ; either version 3 of the License, or +// (at your option) any later version. // This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of +// WITHOUT ANY WARRANTY ; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. +// Lesser General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -// 02110-1301, USA. +// You should have received a copy of the GNU Lesser General Public License +// along with this program ; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // COMMENTARY: // An Asymptote geometry module. @@ -54,10 +55,10 @@ void addMargins(picture pic=currentpicture, real approximate(real t) { - real ot=t; - if(abs(t-ceil(t)) < epsgeo) ot=ceil(t); - else if(abs(t-floor(t)) < epsgeo) ot=floor(t); - return ot; + real ot=t; + if(abs(t-ceil(t)) < epsgeo) ot=ceil(t); + else if(abs(t-floor(t)) < epsgeo) ot=floor(t); + return ot; } real[] approximate(real[] T) @@ -151,7 +152,7 @@ real rd(real x, real y, real z) ed=ea-6*eb; ee=ed+ec+ec; return 3*sum+fac*(1.0+ed*(-C1+C5*ed-C6*delz*ee) - +delz*(C2*ee+delz*(-C3*ec+delz*C4*ea)))/(ave*sqrt(ave)); + +delz*(C2*ee+delz*(-C3*ec+delz*C4*ea)))/(ave*sqrt(ave)); } /*<asyxml><function type="real" signature="elle(real,real)"><code></asyxml>*/ @@ -166,7 +167,7 @@ real elle(real phi, real k) cc=cos(phi)^2; q=(1-s*k)*(1+s*k); result=s*(rf(cc,q,1)-(s*k)^2*rd(cc,q,1)/3); - } else + } else if (phi <= pi && phi >= 0) { result=2*elle(pi/2,k)-elle(pi-phi,k); } else @@ -218,9 +219,9 @@ pair[] intersectionpoints(pair A, pair B, real[] equation) {/*<asyxml></code><documentation>Return the intersection points of the line AB with the conic whose an equation is equation[0]*x^2+equation[1]*x*y+equation[2]*y^2+equation[3]*x+equation[4]*y+equation[5]=0</documentation></function></asyxml>*/ - if(equation.length != 6) abort("intersectionpoints: bad length of array for a conic equation."); - return intersectionpoints(A, B, equation[0], equation[1], equation[2], - equation[3], equation[4], equation[5]); + if(equation.length != 6) abort("intersectionpoints: bad length of array for a conic equation."); + return intersectionpoints(A, B, equation[0], equation[1], equation[2], + equation[3], equation[4], equation[5]); } // *........................HEADER.........................* // *=======================================================* @@ -314,13 +315,13 @@ coordsys cartesiansystem(pair O=(0,0), pair i, pair j) { return O+(P[0][0]*m.x+P[0][1]*m.y,P[1][0]*m.x+P[1][1]*m.y); } - + pair dtr(pair m) { m-=O; return (iP[0][0]*m.x+iP[0][1]*m.y,iP[1][0]*m.x+iP[1][1]*m.y); } - + pair polar(real r, real a) { real ca=sin(ij-a)/(ni*sin(ij)); @@ -382,7 +383,7 @@ pair operator *(coordsys R, pair p) /*<asyxml><operator type="path" signature="*(coordsys,path)"><code></asyxml>*/ path operator *(coordsys R, path g) {/*<asyxml></code><documentation>Return the reconstructed path applying R*pair to each node, pre and post control point of 'g'.</documentation></operator></asyxml>*/ - guide og=point(g,0); + guide og=R*point(g,0); real l=length(g); for(int i=1; i <= l; ++i) { @@ -498,7 +499,7 @@ The operation will be done relatively to the default coordinate system."); /*<asyxml><function type="point[]" signature="standardizecoordsys(coordsys,bool...point[])"><code></asyxml>*/ point[] standardizecoordsys(coordsys R=currentcoordsys, - bool warn=true ... point[] M) + bool warn=true ... point[] M) {/*<asyxml></code><documentation>Return the points with the same coordinate system 'R'. If 'warn' is true and the coordinate systems are different, a warning is sent.</documentation></function></asyxml>*/ point[] op=new point[]; @@ -1078,9 +1079,9 @@ vector conj(explicit vector u) /*<asyxml><function type="transform" signature="rotate(explicit vector)"><code></asyxml>*/ transform rotate(explicit vector dir) {/*<asyxml></code><documentation>A rotation in the direction 'dir' limited to [-90,90] -This is useful for rotating text along a line in the direction dir. -rotate(explicit point dir) is also defined. -</documentation></function></asyxml>*/ + This is useful for rotating text along a line in the direction dir. + rotate(explicit point dir) is also defined. + </documentation></function></asyxml>*/ return rotate(locate(dir)); } transform rotate(explicit point dir){return rotate(locate(vector(dir)));} @@ -1312,7 +1313,7 @@ void perpendicularmark(picture pic=currentpicture, point z, g=margin(g,p).g; draw(apic,g,p); if(filltype != NoFill) filltype.fill(apic,(relpoint(g,0)-relpoint(g,0.5)+ - relpoint(g,1))--g--cycle,p+solid); + relpoint(g,1))--g--cycle,p+solid); add(pic,apic,locate(z)); } @@ -2304,8 +2305,8 @@ void markangle(picture pic=currentpicture, /*<asyxml><function type="void" signature="perpendicularmark(picture,line,line,real,pen,int,margin,filltype)"><code></asyxml>*/ void perpendicularmark(picture pic=currentpicture, line l1, line l2, - real size=0, pen p=currentpen, int quarter=1, - margin margin=NoMargin, filltype filltype=NoFill) + real size=0, pen p=currentpen, int quarter=1, + margin margin=NoMargin, filltype filltype=NoFill) {/*<asyxml></code><documentation>Draw a right angle at the intersection point of lines and aligned in the 'quarter' nth quarter of circle formed by 'l1.u' and 'l2.u'.</documentation></function></asyxml>*/ @@ -2956,16 +2957,16 @@ ellipse ellipse(point C, real a, real b, real angle=0) angle+=degrees(R.i); if(a < b) {angle += 90; real tmp=a; a=b; b=tmp;} if(finite(a) && finite(b)) { - real c=sqrt(abs(a^2-b^2)); - point f1, f2; - if(abs(a-b) < epsgeo) { - f1=C; f2=C; - } else { - f1=point(R,(locate(C)+rotate(angle)*(-c,0))/R); - f2=point(R,(locate(C)+rotate(angle)*(c,0))/R); - } - oe.init(f1,f2,a); + real c=sqrt(abs(a^2-b^2)); + point f1, f2; + if(abs(a-b) < epsgeo) { + f1=C; f2=C; } else { + f1=point(R,(locate(C)+rotate(angle)*(-c,0))/R); + f2=point(R,(locate(C)+rotate(angle)*(c,0))/R); + } + oe.init(f1,f2,a); + } else { if(finite(b) || !finite(a)) oe.init(C,C+R.polar(1,angle),infinity); else oe.init(C,C+R.polar(1,90+angle),infinity); } @@ -5000,9 +5001,9 @@ arc operator *(real x, explicit arc a) {/*<asyxml></code><documentation>Provide real*arc. Return the arc subtracting and adding '(x-1)*degrees(a)/2' to 'a.angle1' and 'a.angle2' respectively.</documentation></operator></asyxml>*/ real a1, a2, gle; - gle=(x-1)*degrees(a)/2; - a1=a.angle1-gle; - a2=a.angle2+gle; + gle=(x-1)*degrees(a)/2; + a1=a.angle1-gle; + a2=a.angle2+gle; arc oa; oa.init(a.el,a.angle0,a1,a2,a.polarconicroutine,a.direction); return oa; @@ -6232,11 +6233,11 @@ point[] intersectionpoints(triangle t, line l, bool extended=false) } } if(extended) { - for (int i=0; i < 3; ++i) { + for (int i=1; i <= 3; ++i) { addpoint(intersectionpoint(t.line(i),l)); } } else { - for (int i=0; i < 3; ++i) { + for (int i=1; i <= 3; ++i) { addpoint(intersectionpoint((segment)t.line(i),l)); } } @@ -6486,6 +6487,8 @@ circle operator *(inversion i, circle c) // *.......................INVERSIONS......................* // *=======================================================* +// *=======================================================* +// *........................FOOTER.........................* /*<asyxml><function type="point[]" signature="intersectionpoints(line,circle)"><code></asyxml>*/ point[] intersectionpoints(line l, circle c) {/*<asyxml></code><documentation>Note that the line 'l' may be a segment by casting. @@ -6534,7 +6537,7 @@ point[] intersectionpoints(line l, ellipse el) (perpendicular(ll,line(ell.F1,Ip[0])) || perpendicular(ll,line(ell.F2,Ip[0])))) { // http://www.mathcurve.com/courbes2d/ellipse/ellipse.shtml - // Définition tangentielle par antipodaire de cercle. + // Définition tangentielle par antipodaire de cercle. // 'l' is a tangent of 'el' transform t=scale(el.a/el.b,el.F1,el.F2,el.C,rotate(90,el.C)*el.F1); point inter=inverse(t)*intersectionpoints(C,t*ll)[0]; @@ -6664,11 +6667,11 @@ point[] intersectionpoints(triangle t, conic co, bool extended=false) if(!exist) OP.push(P[i]); }}} if(extended) { - for (int i=0; i < 3; ++i) { + for (int i=1; i <= 3; ++i) { addpoint(intersectionpoints(t.line(i),co)); } } else { - for (int i=0; i < 3; ++i) { + for (int i=1; i <= 3; ++i) { addpoint(intersectionpoints((segment)t.line(i),co)); } } @@ -6919,14 +6922,14 @@ line[] tangents(hyperbola h, point M) point Mp=changecoordsys(cano,M); real x0=Mp.x, y0=Mp.y; if(abs(x0) > epsgeo) { - real c0=a*y0^2/(b*x0)^2-1/b, - c1=2*a*y0/(b*x0^2), c2=a/x0^2-1; - real[] sol=quadraticroots(c0,c1,c2); - for (real y:sol) { - point tmp=changecoordsys(coordsys(h), point(cano,(a*(1+y*y0/b)/x0,y))); - ol.push(line(M,tmp)); - } - } else if(abs(y0) > epsgeo) { + real c0=a*y0^2/(b*x0)^2-1/b, + c1=2*a*y0/(b*x0^2), c2=a/x0^2-1; + real[] sol=quadraticroots(c0,c1,c2); + for (real y:sol) { + point tmp=changecoordsys(coordsys(h), point(cano,(a*(1+y*y0/b)/x0,y))); + ol.push(line(M,tmp)); + } + } else if(abs(y0) > epsgeo) { real y=-b/y0, x=sqrt(a*(1+b/y0^2)); ol.push(line(M,changecoordsys(coordsys(h),point(cano,(x,y))))); ol.push(line(M,changecoordsys(coordsys(h),point(cano,(-x,y))))); 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; diff --git a/Build/source/utils/asymptote/base/graph3.asy b/Build/source/utils/asymptote/base/graph3.asy index 43bf62d26ca..a1c8258638f 100644 --- a/Build/source/utils/asymptote/base/graph3.asy +++ b/Build/source/utils/asymptote/base/graph3.asy @@ -1823,35 +1823,51 @@ void draw(picture pic=currentpicture, Label[] L=new Label[], draw(pic,L,g,sequence(new pen(int) {return p;},g.length)); } -picture vectorfield(path3 vector(pair z), triple f(pair z), - pair a, pair b, int nx=nmesh, int ny=nx, - bool autoscale=true, pen p=currentpen, +real maxlength(triple f(pair z), pair a, pair b, int nu, int nv) +{ + return min(abs(f((b.x,a.y))-f(a))/nu,abs(f((a.x,b.y))-f(a))/nv); +} + +// return a vector field on a parametric surface f over box(a,b). +picture vectorfield(path3 vector(pair v), triple f(pair z), pair a, pair b, + int nu=nmesh, int nv=nu, bool truesize=false, + real maxlength=truesize ? 0 : maxlength(f,a,b,nu,nv), + bool cond(pair z)=null, pen p=currentpen, arrowbar3 arrow=Arrow3, margin3 margin=PenMargin3) { picture pic; - real dx=1/nx; - real dy=1/ny; + real du=1/nu; + real dv=1/nv; + bool all=cond == null; real scale; - if(autoscale) { + + if(maxlength > 0) { real size(pair z) { path3 g=vector(z); return abs(point(g,size(g)-1)-point(g,0)); } real max=size((0,0)); - 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)))); + for(int i=0; i <= nu; ++i) { + real x=interp(a.x,b.x,i*du); + for(int j=0; j <= nv; ++j) + max=max(max,size((x,interp(a.y,b.y,j*dv)))); } - pair lambda=(abs(f((b.x,a.y))-f(a)),abs(f((a.x,b.y))-f(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); - draw(pic,shift(f(z))*scale3(scale)*vector(z),p,arrow,margin); + + for(int i=0; i <= nu; ++i) { + real x=interp(a.x,b.x,i*du); + for(int j=0; j <= nv; ++j) { + pair z=(x,interp(a.y,b.y,j*dv)); + if(all || cond(z)) { + path3 g=scale3(scale)*vector(z); + if(truesize) { + picture opic; + draw(opic,g,p,arrow,margin); + add(pic,opic,f(z)); + } else + draw(pic,shift(f(z))*g,p,arrow,margin); + } } } return pic; diff --git a/Build/source/utils/asymptote/base/plain_Label.asy b/Build/source/utils/asymptote/base/plain_Label.asy index 72f924224d4..77a04deb007 100644 --- a/Build/source/utils/asymptote/base/plain_Label.asy +++ b/Build/source/utils/asymptote/base/plain_Label.asy @@ -563,7 +563,7 @@ frame pack(pair align=2S ... object inset[]) return F; } -path[] texpath(Label L) +path[] texpath(Label L, bool tex=settings.tex != "none") { static string[] stringcache; static pen[] pencache; @@ -582,7 +582,7 @@ path[] texpath(Label L) } if(i == -1) { - g=_texpath(s,p); + g=tex ? _texpath(s,p) : textpath(s,p); stringcache.push(s); pencache.push(p); pathcache.push(g); diff --git a/Build/source/utils/asymptote/base/plain_boxes.asy b/Build/source/utils/asymptote/base/plain_boxes.asy index 6ec7f23c985..7fb82c37c1f 100644 --- a/Build/source/utils/asymptote/base/plain_boxes.asy +++ b/Build/source/utils/asymptote/base/plain_boxes.asy @@ -131,6 +131,6 @@ frame bbox(string prefix="", picture pic=currentpicture, pen p=currentpen, filltype filltype=NoFill) { frame f=pic.fit(prefix,max(pic.xsize-2*xmargin,0),max(pic.ysize-2*ymargin,0)); - box(f,xmargin,ymargin,p,filltype,false); + box(f,xmargin,ymargin,p,filltype,above=false); return f; } diff --git a/Build/source/utils/asymptote/base/three.asy b/Build/source/utils/asymptote/base/three.asy index 2ba6b73abe1..7c76714518a 100644 --- a/Build/source/utils/asymptote/base/three.asy +++ b/Build/source/utils/asymptote/base/three.asy @@ -216,7 +216,7 @@ pair dir(triple v, triple dir, projection P) // perpendicular to the vector camera-target. projection perspective(triple camera, triple up=Z, triple target=O, bool showtarget=true, bool autoadjust=true, - bool center=false) + bool center=autoadjust) { if(camera == target) abort("camera cannot be at target"); @@ -228,16 +228,15 @@ projection perspective(triple camera, triple up=Z, triple target=O, projection perspective(real x, real y, real z, triple up=Z, triple target=O, bool showtarget=true, bool autoadjust=true, - bool center=false) + bool center=autoadjust) { return perspective((x,y,z),up,target,showtarget,autoadjust,center); } projection orthographic(triple camera, triple up=Z, triple target=O, - bool showtarget=true, bool autoadjust=true, - bool center=false) + bool showtarget=true, bool center=false) { - return projection(camera,up,target,showtarget,autoadjust,center, + return projection(camera,up,target,showtarget,center=center, new transformation(triple camera, triple up, triple target) { return transformation(look(camera,up,target));}); @@ -245,9 +244,9 @@ projection orthographic(triple camera, triple up=Z, triple target=O, projection orthographic(real x, real y, real z, triple up=Z, triple target=O, bool showtarget=true, - bool autoadjust=true, bool center=false) + bool center=false) { - return orthographic((x,y,z),up,target,showtarget,autoadjust,center); + return orthographic((x,y,z),up,target,showtarget,center=center); } projection oblique(real angle=45) @@ -2176,9 +2175,8 @@ private string format(triple v, string sep=" ") return format(v.x)+sep+format(v.y)+sep+format(v.z); } -private string format(pen p) +private string format(real[] c) { - real[] c=colors(rgb(p)); return format((c[0],c[1],c[2])); } @@ -2256,8 +2254,7 @@ string embed3D(string label="", string text=label, string prefix, frame f, string format="", real width=0, real height=0, real angle=30, string options="", string script="", - pen background=white, light light=currentlight, - projection P=currentprojection) + light light=currentlight, projection P=currentprojection) { if(!prc(format) || Embed == null) return ""; @@ -2302,7 +2299,7 @@ string embed3D(string label="", string text=label, string prefix, ",3Dcoo="+format(P.target/cm)+ ",3Droll="+format(roll)+ ",3Droo="+format(abs(v))+ - ",3Dbg="+format(background); + ",3Dbg="+format(light.background()); if(options != "") options3 += ","+options; if(name != "") options3 += ",3Djscript="+stripdirectory(name); @@ -2315,14 +2312,13 @@ object embed(string label="", string text=label, frame f, string format="", real width=0, real height=0, real angle=30, string options="", string script="", - pen background=white, light light=currentlight, - projection P=currentprojection) + light light=currentlight, projection P=currentprojection) { object F; if(is3D(format)) F.L=embed3D(label,text,prefix,f,format,width,height,angle,options,script, - background,light,P); + light,P); else F.f=f; return F; @@ -2333,7 +2329,7 @@ object embed(string label="", string text=label, picture pic, string format="", real xsize=pic.xsize, real ysize=pic.ysize, bool keepAspect=pic.keepAspect, bool view=true, string options="", - string script="", real angle=0, pen background=white, + string script="", real angle=0, light light=currentlight, projection P=currentprojection) { object F; @@ -2348,7 +2344,7 @@ object embed(string label="", string text=label, projection P=P.copy(); - if(!P.autoadjust && !P.absolute && P.showtarget) + if(!P.absolute && P.showtarget) draw(pic,P.target,nullpen); transform3 t=pic.scaling(xsize3,ysize3,zsize3,keepAspect,warn); @@ -2359,18 +2355,11 @@ object embed(string label="", string text=label, if(!P.absolute) { P=t*P; - if(P.autoadjust || P.center) { + if(P.center) { bool recalculate=false; - if(P.center || P.target.x < m.x || - P.target.y < m.y || - P.target.z < m.z || - P.target.x > M.x || - P.target.y > M.y || - P.target.z > M.z) { - P.target=0.5*(m+M); - recalculate=true; - if(!P.center) write("adjusting target to ",tinv*P.target); - } + triple target=0.5*(m+M); + P.target=target; + recalculate=true; if(recalculate) P.calculate(); } if(P.autoadjust || P.infinity) @@ -2421,9 +2410,7 @@ object embed(string label="", string text=label, if(P.autoadjust || P.infinity) adjusted=adjusted | P.adjust(min3(f),max3(f)); - if(adjusted && !P.infinity) - write("adjusting camera to ",tinv*P.camera); - + triple target=P.target; modelview=P.modelview(); f=modelview*f; P=modelview*P; @@ -2436,9 +2423,11 @@ object embed(string label="", string text=label, triple s=(-0.5(m.x+M.x),-0.5*(m.y+M.y),0); f=shift(s)*f; // Eye will be at (0,0,0). } else { + transform3 T=identity4; // Choose the angle to be just large enough to view the entire image: + if(angle == 0) angle=P.angle; int maxiterations=100; - if(is3D && angle == 0 && !P.infinity) { + if(is3D && angle == 0) { real h=-0.5*P.target.z; pair r,R; real diff=realMax; @@ -2448,20 +2437,45 @@ object embed(string label="", string text=label, r=minratio(f); R=maxratio(f); pair lasts=s; - s=r+R; - transform3 t=shift(h*s.x,h*s.y,0); - f=t*f; - P=t*P; + if(P.autoadjust) { + s=r+R; + transform3 t=shift(h*s.x,h*s.y,0); + f=t*f; + T=t*T; + adjusted=true; + } diff=abs(s-lasts); ++i; } while (diff > angleprecision && i < maxiterations); - real aspect=width > 0 ? height/width : 1; - angle=anglefactor*max(aTan(-r.x*aspect)+aTan(R.x*aspect), - aTan(-r.y)+aTan(R.y)); + real rx=-r.x*aspect; + real Rx=R.x*aspect; + real ry=-r.y; + real Ry=R.y; + if(!P.autoadjust) { + if(rx > Rx) Rx=rx; + else rx=Rx; + if(ry > Ry) Ry=ry; + else ry=Ry; + } + + angle=anglefactor*max(aTan(rx)+aTan(Rx),aTan(ry)+aTan(Ry)); if(viewportmargin.y != 0) angle=2*aTan(Tan(0.5*angle)-viewportmargin.y/P.target.z); + + modelview=T*modelview; } + if(settings.verbose > 0) { + transform3 inv=inverse(modelview); + if(adjusted) + write("adjusting camera to ",tinv*inv*P.camera); + target=inv*P.target; + } + P=T*P; + } + if(settings.verbose > 0) { + if(P.center || (!P.infinity && P.autoadjust)) + write("adjusting target to ",tinv*target); } } @@ -2483,7 +2497,6 @@ object embed(string label="", string text=label, modelview=P.modelview(); f=modelview*f; P=modelview*P; - angle=P.angle; m=min3(f); M=max3(f); real r=0.5*abs(M-m); @@ -2510,7 +2523,7 @@ object embed(string label="", string text=label, shipout3(prefix,f,preview ? nativeformat() : format, width+2*viewportmargin.x,height+2*viewportmargin.y, P.infinity ? 0 : angle,m,M, - tinv*inverse(modelview)*shift(0,0,zcenter), + tinv*inverse(modelview)*shift(0,0,zcenter),light.background(), P.absolute ? (modelview*light).position : light.position, light.diffuse,light.ambient,light.specular, light.viewport,view && !preview); @@ -2526,7 +2539,7 @@ object embed(string label="", string text=label, image=graphic(image); } if(prc) F.L=embed3D(label,text=image,prefix,f,format, - width,height,angle,options,script,background,light, + width,height,angle,options,script,light, P.absolute ? P : Q); } @@ -2562,13 +2575,15 @@ currentpicture.fitter=new frame(string prefix, picture pic, string format, if(!keep) file3.push(prefix+"."+format); } object F=embed(prefix=prefix,pic,format,xsize,ysize,keepAspect,view, - options,script,P); + options,script,currentlight,P); if(prc) label(f,F.L); else { - if(settings.render == 0) + if(settings.render == 0) { add(f,F.f); - else if(!view) + if(currentlight.background != nullpen) + box(f,currentlight.background,Fill,above=false); + } else if(!view) label(f,graphic(prefix)); } } diff --git a/Build/source/utils/asymptote/base/three_light.asy b/Build/source/utils/asymptote/base/three_light.asy index 388c344895a..54ca7a47151 100644 --- a/Build/source/utils/asymptote/base/three_light.asy +++ b/Build/source/utils/asymptote/base/three_light.asy @@ -79,6 +79,7 @@ struct light { real[][] diffuse; real[][] ambient; real[][] specular; + pen background; // Background color of the 3D canvas. real specularfactor; bool viewport; // Are the lights specified (and fixed) in the viewport frame? triple[] position; // Only directional lights are implemented. @@ -89,12 +90,14 @@ struct light { void operator init(pen[] diffuse=array(position.length,white), pen[] ambient=array(position.length,black), - pen[] specular=diffuse, real specularfactor=1, + pen[] specular=diffuse, pen background=nullpen, + real specularfactor=1, bool viewport=true, triple[] position) { this.position=new triple[position.length]; this.diffuse=new real[position.length][]; this.ambient=new real[position.length][]; this.specular=new real[position.length][]; + this.background=background; for(int i=0; i < position.length; ++i) { this.position[i]=unit(position[i]); this.diffuse[i]=rgba(diffuse[i]); @@ -106,22 +109,24 @@ struct light { } void operator init(pen diffuse=white, pen ambient=black, pen specular=diffuse, - real specularfactor=1, + pen background=nullpen, real specularfactor=1, bool viewport=true...triple[] position) { int n=position.length; operator init(array(n,diffuse),array(n,ambient),array(n,specular), - specularfactor,viewport,position); + background,specularfactor,viewport,position); } void operator init(pen diffuse=white, pen ambient=black, pen specular=diffuse, - bool viewport=true, real x, real y, real z) { - operator init(diffuse,ambient,specular,viewport,(x,y,z)); + pen background=nullpen, bool viewport=true, + real x, real y, real z) { + operator init(diffuse,ambient,specular,background,viewport,(x,y,z)); } void operator init(explicit light light) { diffuse=copy(light.diffuse); ambient=copy(light.ambient); specular=copy(light.specular); + background=light.background; specularfactor=light.specularfactor; viewport=light.viewport; position=copy(light.position); @@ -147,6 +152,8 @@ struct light { } return rgb(p[0],p[1],p[2])+opacity(opacity(m.diffuse())); } + + real[] background() {return rgba(background == nullpen ? white : background);} } light operator * (transform3 t, light light) diff --git a/Build/source/utils/asymptote/base/trembling.asy b/Build/source/utils/asymptote/base/trembling.asy index 6b94317b1c4..fc50ce9b7f5 100644 --- a/Build/source/utils/asymptote/base/trembling.asy +++ b/Build/source/utils/asymptote/base/trembling.asy @@ -1,21 +1,19 @@ // Copyright (c) 2008, Philippe Ivaldi. // trembling.asy: handwriting package for the software Asymptote. -// Last modified: Mon Jul 7 23:35:36 CEST 2008 -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or (at -// your option) any later version. +// This program is free software ; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation ; either version 3 of the License, or +// (at your option) any later version. // This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of +// WITHOUT ANY WARRANTY ; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. +// Lesser General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -// 02110-1301, USA. +// You should have received a copy of the GNU Lesser General Public License +// along with this program ; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // COMMENTARY: diff --git a/Build/source/utils/asymptote/base/version.asy b/Build/source/utils/asymptote/base/version.asy index e8dcc965de5..6f560eb187d 100644 --- a/Build/source/utils/asymptote/base/version.asy +++ b/Build/source/utils/asymptote/base/version.asy @@ -1 +1 @@ -string VERSION="1.72"; +string VERSION="1.73"; |