From e355922861e2bc91176c058d563d477444c2dfd9 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 15 Jul 2009 00:14:18 +0000 Subject: asymptote 1.81 source/w32 update git-svn-id: svn://tug.org/texlive/trunk@14262 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/utils/asymptote/base/plain_pens.asy | 5 +- .../source/utils/asymptote/base/plain_strings.asy | 7 +- Build/source/utils/asymptote/base/three.asy | 74 ++++++++++++++++++++-- .../source/utils/asymptote/base/three_surface.asy | 29 ++++++--- 4 files changed, 96 insertions(+), 19 deletions(-) (limited to 'Build/source/utils/asymptote/base') diff --git a/Build/source/utils/asymptote/base/plain_pens.asy b/Build/source/utils/asymptote/base/plain_pens.asy index 09993d44da8..fd2dfadde68 100644 --- a/Build/source/utils/asymptote/base/plain_pens.asy +++ b/Build/source/utils/asymptote/base/plain_pens.asy @@ -195,9 +195,10 @@ pen font(string name, string options="") pen font(string name, real size, string options="") { + string s=(string) (size/pt)+"pt"; if(settings.tex == "context") - return fontsize(size)+font(name+","+(string) size+"pt",options); - return fontsize(size)+font(name+" at "+(string) size+"pt"); + return fontsize(size)+font(name+","+s,options); + return fontsize(size)+font(name+" at "+s); } pen font(string encoding, string family, string series, string shape) diff --git a/Build/source/utils/asymptote/base/plain_strings.asy b/Build/source/utils/asymptote/base/plain_strings.asy index 0fe59ba5a63..598d61e4249 100644 --- a/Build/source/utils/asymptote/base/plain_strings.asy +++ b/Build/source/utils/asymptote/base/plain_strings.asy @@ -83,7 +83,7 @@ string verbatim(string s) } // Split a string into an array of substrings delimited by delimiter -string[] split(string s, string delimiter) +string[] split(string s, string delimiter=" ") { string[] S; int last=0; @@ -100,6 +100,11 @@ string[] split(string s, string delimiter) return S; } +int system(string s) +{ + return system(split(s)); +} + int[] operator ecast(string[] a) { return sequence(new int(int i) {return (int) a[i];},a.length); diff --git a/Build/source/utils/asymptote/base/three.asy b/Build/source/utils/asymptote/base/three.asy index 63a497c497c..2befc77a9c8 100644 --- a/Build/source/utils/asymptote/base/three.asy +++ b/Build/source/utils/asymptote/base/three.asy @@ -950,6 +950,64 @@ bool cyclic(guide3 g) {flatguide3 f; g(f); return f.cyclic();} int size(guide3 g) {flatguide3 f; g(f); return f.size();} int length(guide3 g) {flatguide3 f; g(f); return f.nodes.length-1;} +triple dir(path3 p) +{ + return dir(p,length(p)); +} + +triple dir(path3 p, path3 h) +{ + return 0.5*(dir(p)+dir(h)); +} + +// return the point on path3 p at arclength L +triple arcpoint(path3 p, real L) +{ + return point(p,arctime(p,L)); +} + +// return the direction on path3 p at arclength L +triple arcdir(path3 p, real L) +{ + return dir(p,arctime(p,L)); +} + +// return the time on path3 p at the relative fraction l of its arclength +real reltime(path3 p, real l) +{ + return arctime(p,l*arclength(p)); +} + +// return the point on path3 p at the relative fraction l of its arclength +triple relpoint(path3 p, real l) +{ + return point(p,reltime(p,l)); +} + +// return the direction of path3 p at the relative fraction l of its arclength +triple reldir(path3 p, real l) +{ + return dir(p,reltime(p,l)); +} + +// return the initial point of path3 p +triple beginpoint(path3 p) +{ + return point(p,0); +} + +// return the point on path3 p at half of its arclength +triple midpoint(path3 p) +{ + return relpoint(p,0.5); +} + +// return the final point of path3 p +triple endpoint(path3 p) +{ + return point(p,length(p)); +} + path3 path3(triple v) { triple[] point={v}; @@ -2294,7 +2352,7 @@ string embed3D(string label="", string text=label, string prefix, file3.push(prefix); triple target=P.target; - if(P.infinity && P.viewportshift != 0) { + if(P.viewportshift != 0) { triple lambda=max3(f)-min3(f); target -= (P.viewportshift.x*lambda.x/P.zoom, P.viewportshift.y*lambda.y/P.zoom,0); @@ -2414,7 +2472,7 @@ object embed(string label="", string text=label, projection Q; if(!P.absolute) { - if(scale) { + if(scale && P.autoadjust) { pair v=(s.xx,s.yy); transform3 T=P.t; pair x=project(X,T); @@ -2424,7 +2482,11 @@ object embed(string label="", string text=label, return b == 0 ? (0.5*(a.x+a.y)) : (b.x^2*a.x+b.y^2*a.y)/(b.x^2+b.y^2); } pic2.erase(); - t=xscale3(f(v,x))*yscale3(f(v,y))*zscale3(f(v,z))*t; + transform3 s=keepAspect ? scale3(min(f(v,x),f(v,y),f(v,z))) : + xscale3(f(v,x))*yscale3(f(v,y))*zscale3(f(v,z)); + s=shift(P.target)*s*shift(-P.target); + t=s*t; + P=s*P; f=pic.fit3(t,is3D ? null : pic2,P); } @@ -2547,8 +2609,8 @@ object embed(string label="", string text=label, } else if(M.z >= 0) abort("camera too close"); shipout3(prefix,f,preview ? nativeformat() : format, - width,height,P.infinity ? 0 : angle,P.zoom,m,M, - prc && !P.infinity ? 0 : P.viewportshift, + width,height,P.infinity ? 0 : 2aTan(Tan(0.5*angle)*P.zoom), + P.zoom,m,M,P.viewportshift, tinv*inverse(modelview)*shift(0,0,zcenter),light.background(), P.absolute ? (modelview*light).position : light.position, light.diffuse,light.ambient,light.specular, @@ -2568,7 +2630,7 @@ object embed(string label="", string text=label, if(!P.infinity && P.viewportshift != 0) write("warning: PRC does not support off-axis projections; use pan instead of shift"); F.L=embed3D(label,text=image,prefix,f,format, - width,height,angle,options,script,light,Q); + width,height,angle,options,script,light,Q); } } diff --git a/Build/source/utils/asymptote/base/three_surface.asy b/Build/source/utils/asymptote/base/three_surface.asy index 2f5d80aacbe..f2ad86dfe7e 100644 --- a/Build/source/utils/asymptote/base/three_surface.asy +++ b/Build/source/utils/asymptote/base/three_surface.asy @@ -148,13 +148,13 @@ struct patch { triple min(triple bound=P[0][0]) { if(havemin3) return minbound(min3,bound); havemin3=true; - return min3=minbound(P,bound); + return min3=minbezier(P,bound); } triple max(triple bound=P[0][0]) { if(havemax3) return maxbound(max3,bound); havemax3=true; - return max3=maxbound(P,bound); + return max3=maxbezier(P,bound); } triple center() { @@ -162,11 +162,11 @@ struct patch { } pair min(projection P, pair bound=project(this.P[0][0],P.t)) { - return minbound(this.P,P.t,bound); + return minbezier(this.P,P.t,bound); } pair max(projection P, pair bound=project(this.P[0][0],P.t)) { - return maxbound(this.P,P.t,bound); + return maxbezier(this.P,P.t,bound); } void operator init(triple[][] P, triple[] normals=new triple[], @@ -1163,12 +1163,14 @@ path[] path(Label L, pair z=0, projection P) } void label(frame f, Label L, triple position, align align=NoAlign, - pen p=currentpen, light light=nolight, + pen p=currentpen, bool targetsize=false, light light=nolight, projection P=currentprojection) { Label L=L.copy(); L.align(align); L.p(p); + if(targetsize && settings.render != 0) + L.T=L.T*scale(abs(P.camera-position)/abs(P.vector())); if(L.defaulttransform3) L.T3=transform3(P); if(is3D()) { @@ -1188,14 +1190,13 @@ void label(frame f, Label L, triple position, align align=NoAlign, } void label(picture pic=currentpicture, Label L, triple position, - align align=NoAlign, pen p=currentpen, light light=nolight) + align align=NoAlign, pen p=currentpen, bool targetsize=false, + light light=nolight) { Label L=L.copy(); L.align(align); L.p(p); L.position(0); - path[] g=texpath(L); - if(g.length == 0 || (g.length == 1 && size(g[0]) == 0)) return; pic.add(new void(frame f, transform3 t, picture pic, projection P) { // Handle relative projected 3D alignments. Label L=L.copy(); @@ -1204,6 +1205,8 @@ void label(picture pic=currentpicture, Label L, triple position, determinant(P.t) != 0) L.align(L.align.dir*unit(project(v+L.align.dir3,P.t)-project(v,P.t))); + if(targetsize && settings.render != 0) + L.T=L.T*scale(abs(P.camera-v)/abs(P.vector())); if(L.defaulttransform3) L.T3=transform3(P); if(is3D()) @@ -1222,6 +1225,12 @@ void label(picture pic=currentpicture, Label L, triple position, } },!L.defaulttransform3); + Label L=L.copy(); + if(targetsize && settings.render != 0) + L.T=L.T*scale(abs(currentprojection.camera-position)/ + abs(currentprojection.vector())); + path[] g=texpath(L); + if(g.length == 0 || (g.length == 1 && size(g[0]) == 0)) return; if(L.defaulttransform3) L.T3=transform3(currentprojection); path3[] G=path3(g); @@ -1230,7 +1239,7 @@ void label(picture pic=currentpicture, Label L, triple position, } void label(picture pic=currentpicture, Label L, path3 g, align align=NoAlign, - pen p=currentpen) + bool targetsize=false, pen p=currentpen) { Label L=L.copy(); L.align(align); @@ -1246,7 +1255,7 @@ void label(picture pic=currentpicture, Label L, path3 g, align align=NoAlign, a.dir3=dir(g,position); // Pass 3D direction via unused field. L.align(a); } - label(pic,L,point(g,position)); + label(pic,L,point(g,position),targetsize); } surface extrude(Label L, triple axis=Z) -- cgit v1.2.3