summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/base
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-05-09 00:26:15 +0000
committerKarl Berry <karl@freefriends.org>2010-05-09 00:26:15 +0000
commit0114fbc0beecd9a094b260d78cccdc6ff3e85f1e (patch)
tree53f68a7eb4cd90f611560e9b477b55c671b94717 /Build/source/utils/asymptote/base
parent539c0d5c885fa1c451a55ef8e7e1a2bbf1a32861 (diff)
asy 1.94
git-svn-id: svn://tug.org/texlive/trunk@18161 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/base')
-rw-r--r--Build/source/utils/asymptote/base/contour.asy17
-rw-r--r--Build/source/utils/asymptote/base/math.asy105
-rw-r--r--Build/source/utils/asymptote/base/plain.asy1
-rw-r--r--Build/source/utils/asymptote/base/plain_arrows.asy2
-rw-r--r--Build/source/utils/asymptote/base/plain_filldraw.asy14
-rw-r--r--Build/source/utils/asymptote/base/plain_paths.asy4
-rw-r--r--Build/source/utils/asymptote/base/plain_picture.asy16
-rw-r--r--Build/source/utils/asymptote/base/slide.asy4
-rw-r--r--Build/source/utils/asymptote/base/three.asy27
9 files changed, 86 insertions, 104 deletions
diff --git a/Build/source/utils/asymptote/base/contour.asy b/Build/source/utils/asymptote/base/contour.asy
index 3c01640b2cc..27a79439e2d 100644
--- a/Build/source/utils/asymptote/base/contour.asy
+++ b/Build/source/utils/asymptote/base/contour.asy
@@ -13,7 +13,7 @@
import graph_settings;
-real eps=sqrtEpsilon;
+private real eps=sqrtEpsilon;
/*
GRID CONTOURS
@@ -53,15 +53,14 @@ real eps=sqrtEpsilon;
*/
-typedef int boxtype;
-boxtype exterior=-1;
-boxtype edge = 0;
-boxtype interior=+1;
+private typedef int boxtype;
+private boxtype exterior=-1;
+private boxtype edge = 0;
+private boxtype interior=+1;
-typedef int contourshape;
-contourshape none =0;
-contourshape line =1;
-contourshape hyperbola=2;
+private typedef int contourshape;
+private contourshape line =1;
+private contourshape hyperbola=2;
// Describe position by grid square and position in square
private struct gridpoint {
diff --git a/Build/source/utils/asymptote/base/math.asy b/Build/source/utils/asymptote/base/math.asy
index eef703cb7ee..ff267b955d7 100644
--- a/Build/source/utils/asymptote/base/math.asy
+++ b/Build/source/utils/asymptote/base/math.asy
@@ -89,39 +89,39 @@ triple intersectionpoint(triple n0, triple P0, triple n1, triple P1)
}
}
-// Given a real array A, return its partial sums.
-real[] partialsum(real[] A)
+// Given a real array a, return its partial sums.
+real[] partialsum(real[] a)
{
- real[] B=new real[A.length];
+ real[] b=new real[a.length];
real sum=0;
- for(int i=0; i < A.length; ++i) {
- sum += A[i];
- B[i]=sum;
+ for(int i=0; i < a.length; ++i) {
+ sum += a[i];
+ b[i]=sum;
}
- return B;
+ return b;
}
-// Given a real array A, return its partial dx-weighted sums.
-real[] partialsum(real[] A, real[] dx)
+// Given a real array a, return its partial dx-weighted sums.
+real[] partialsum(real[] a, real[] dx)
{
- real[] B=new real[A.length];
+ real[] b=new real[a.length];
real sum=0;
- for(int i=0; i < A.length; ++i) {
- sum += A[i]*dx[i];
- B[i]=sum;
+ for(int i=0; i < a.length; ++i) {
+ sum += a[i]*dx[i];
+ b[i]=sum;
}
- return B;
+ return b;
}
-// If strict=false, return whether i > j implies x[i] >= x[j]
-// If strict=true, return whether i > j implies x[i] > x[j]
-bool increasing(real[] x, bool strict=false)
+// If strict=false, return whether i > j implies a[i] >= a[j]
+// If strict=true, return whether i > j implies a[i] > a[j]
+bool increasing(real[] a, bool strict=false)
{
- real[] xp=copy(x);
- xp.delete(0);
- xp.push(0);
- bool[] b=strict ? (xp > x) : (xp >= x);
- b[x.length-1]=true;
+ real[] ap=copy(a);
+ ap.delete(0);
+ ap.push(0);
+ bool[] b=strict ? (ap > a) : (ap >= a);
+ b[a.length-1]=true;
return all(b);
}
@@ -157,67 +157,6 @@ real[][] zero(int n, int m)
return M;
}
-real[][] operator +(real[][] a, real[][] b)
-{
- int n=a.length;
- real[][] m=new real[n][];
- for(int i=0; i < n; ++i)
- m[i]=a[i]+b[i];
- return m;
-}
-
-real[][] operator -(real[][] a, real[][] b)
-{
- int n=a.length;
- real[][] m=new real[n][];
- for(int i=0; i < n; ++i)
- m[i]=a[i]-b[i];
- return m;
-}
-
-real[][] operator *(real[][] a, real b)
-{
- int n=a.length;
- real[][] m=new real[n][];
- for(int i=0; i < n; ++i)
- m[i]=a[i]*b;
- return m;
-}
-
-real[][] operator *(real b, real[][] a)
-{
- return a*b;
-}
-
-real[][] operator /(real[][] a, real b)
-{
- return a*(1/b);
-}
-
-private string incommensurate=
- "Multiplication of incommensurate matrices is undefined";
-
-pair[][] operator * (pair[][] a, pair[][] b)
-{
- int n=a.length;
- int nb=b.length;
- int nb0=b[0].length;
- pair[][] m=new pair[n][nb0];
- for(int i=0; i < n; ++i) {
- pair[] ai=a[i];
- pair[] mi=m[i];
- if(ai.length != nb)
- abort(incommensurate);
- for(int j=0; j < nb0; ++j) {
- pair sum;
- for(int k=0; k < nb; ++k)
- sum += ai[k]*b[k][j];
- mi[j]=sum;
- }
- }
- return m;
-}
-
bool square(real[][] m)
{
int n=m.length;
diff --git a/Build/source/utils/asymptote/base/plain.asy b/Build/source/utils/asymptote/base/plain.asy
index cc1a5064038..4d0b4e566fb 100644
--- a/Build/source/utils/asymptote/base/plain.asy
+++ b/Build/source/utils/asymptote/base/plain.asy
@@ -22,6 +22,7 @@ access version;
if(version.VERSION != VERSION) {
warning("version","using possibly incompatible version "+
version.VERSION+" of plain.asy"+'\n');
+ nowarn("version");
}
include plain_strings;
diff --git a/Build/source/utils/asymptote/base/plain_arrows.asy b/Build/source/utils/asymptote/base/plain_arrows.asy
index 18618c2b5b8..5284ee9650d 100644
--- a/Build/source/utils/asymptote/base/plain_arrows.asy
+++ b/Build/source/utils/asymptote/base/plain_arrows.asy
@@ -93,7 +93,7 @@ SimpleHead.head=new path(path g, position position=EndPoint, pen p=currentpen,
path left=rotate(-angle,x)*r;
path right=rotate(angle*factor,x)*r;
real[] T=arrowbasepoints(base,left,right);
- return subpath(left,T[0],0)--subpath(right,T[1],0);
+ return subpath(left,T[0],0)--subpath(right,0,T[1]);
};
arrowhead HookHead(real dir=arrowdir, real barb=arrowbarb)
diff --git a/Build/source/utils/asymptote/base/plain_filldraw.asy b/Build/source/utils/asymptote/base/plain_filldraw.asy
index b9cd191e075..a5eea35ef25 100644
--- a/Build/source/utils/asymptote/base/plain_filldraw.asy
+++ b/Build/source/utils/asymptote/base/plain_filldraw.asy
@@ -186,6 +186,20 @@ filltype RadialShade(pen penc, pen penr)
});
}
+filltype RadialShadeDraw(real xmargin=0, real ymargin=xmargin,
+ pen penc, pen penr, pen drawpen=nullpen)
+{
+ return filltype(new void(frame f, path[] g, pen Drawpen) {
+ if(drawpen != nullpen) Drawpen=drawpen;
+ if(Drawpen == nullpen) Drawpen=penc;
+ pair c=(min(g)+max(g))/2;
+ if(cyclic(g[0]))
+ radialshade(f,margin(g,xmargin,ymargin),penc,c,0,penr,c,
+ abs(max(g)-min(g))/2);
+ draw(f,margin(g,xmargin,ymargin),Drawpen);
+ });
+}
+
// Fill the region in frame dest underneath frame src and return the
// boundary of src.
path fill(frame dest, frame src, filltype filltype=NoFill,
diff --git a/Build/source/utils/asymptote/base/plain_paths.asy b/Build/source/utils/asymptote/base/plain_paths.asy
index 3dab68fe32e..b073e8090ec 100644
--- a/Build/source/utils/asymptote/base/plain_paths.asy
+++ b/Build/source/utils/asymptote/base/plain_paths.asy
@@ -204,9 +204,9 @@ pair dir(path p)
return dir(p,length(p));
}
-pair dir(path p, path h)
+pair dir(path p, path g)
{
- return 0.5*(dir(p)+dir(h));
+ return unit(dir(p)+dir(g));
}
// return the point on path p at arclength L
diff --git a/Build/source/utils/asymptote/base/plain_picture.asy b/Build/source/utils/asymptote/base/plain_picture.asy
index 56ebf9f4bbe..044ba90e7a7 100644
--- a/Build/source/utils/asymptote/base/plain_picture.asy
+++ b/Build/source/utils/asymptote/base/plain_picture.asy
@@ -1363,6 +1363,18 @@ struct picture {
light,P);
}
+ // Fit a 3D picture.
+ frame fit3(projection P=currentprojection) {
+ if(settings.render == 0) return fit(P);
+ if(fixed) return scaled();
+ if(empty3()) return newframe;
+ transform3 t=scaling(xsize3,ysize3,zsize3,keepAspect);
+ frame f=fit3(t,null,P);
+ transform3 s=scale3(f,xsize3,ysize3,zsize3,keepAspect);
+ if(s == identity4) return f;
+ return fit3(s*t,null,P);
+ }
+
// In case only an approximate picture size estimate is available, return the
// fitted frame slightly scaled (including labels and true size distances)
// so that it precisely meets the given size specification.
@@ -1848,14 +1860,14 @@ transform fixedscaling(picture pic=currentpicture, pair min, pair max,
pic.keepAspect);
}
-// Add frame src about position to frame dest with optional grouping.
+// Add frame src to frame dest about position with optional grouping.
void add(frame dest, frame src, pair position, bool group=false,
filltype filltype=NoFill, bool above=true)
{
add(dest,shift(position)*src,group,filltype,above);
}
-// Add frame src about position to picture dest with optional grouping.
+// Add frame src to picture dest about position with optional grouping.
void add(picture dest=currentpicture, frame src, pair position=0,
bool group=true, filltype filltype=NoFill, bool above=true)
{
diff --git a/Build/source/utils/asymptote/base/slide.asy b/Build/source/utils/asymptote/base/slide.asy
index dc1608203e1..092c3429145 100644
--- a/Build/source/utils/asymptote/base/slide.asy
+++ b/Build/source/utils/asymptote/base/slide.asy
@@ -444,7 +444,7 @@ void asyinclude(string s, real xsize=0, real ysize=xsize)
picture currentpictureSave=currentpicture;
currentpicture=new picture;
_eval("include \""+s+"\";",true);
- s=stripdirectory(settings.outname+"_"+s);
+ s=stripdirectory(outprefix()+"_"+s);
codefile.push(s);
frame f=(xsize > 0 || ysize > 0) ?
currentpicture.fit(xsize,ysize) : currentpicture.fit();
@@ -490,7 +490,7 @@ void asyfigure(string s, string options="", string caption="", pair align=S,
string asywrite(string s, string preamble="")
{
static int count=0;
- string name=settings.outname+"_slide"+(string) count;
+ string name=outprefix()+"_slide"+(string) count;
++count;
file temp=output(name+".asy");
write(temp,preamble);
diff --git a/Build/source/utils/asymptote/base/three.asy b/Build/source/utils/asymptote/base/three.asy
index cc7534f6f79..5b3dd26aba7 100644
--- a/Build/source/utils/asymptote/base/three.asy
+++ b/Build/source/utils/asymptote/base/three.asy
@@ -2610,12 +2610,10 @@ struct scene
if(!P.absolute) {
this.P=t*P;
- if(this.P.center) {
- bool recalculate=false;
+ if(this.P.center && settings.render != 0) {
triple target=0.5*(m+M);
this.P.target=target;
- recalculate=true;
- if(recalculate) this.P.calculate();
+ this.P.calculate();
}
if(this.P.autoadjust || this.P.infinity)
adjusted=adjusted | this.P.adjust(m,M);
@@ -2754,7 +2752,7 @@ object embed(string label="", string text=label, string prefix=defaultfilename,
P=S.T*P;
}
if(settings.verbose > 0) {
- if(P.center || (!P.infinity && P.autoadjust))
+ if((P.center && settings.render != 0) || (!P.infinity && P.autoadjust))
write("adjusting target to ",tinv*target);
}
}
@@ -3091,6 +3089,25 @@ fit=new frame[](string prefix="", picture[] pictures, string format="",
fit3(prefix,pictures,all,format,view,options,script,P);
};
+// Add frame src to picture dest about position.
+void add(picture dest=currentpicture, frame src, triple position)
+{
+ if(is3D(src)) {
+ dest.add(new void(frame f, transform3 t, picture, projection) {
+ add(f,shift(t*position)*src);
+ },true);
+ } else {
+ dest.add(new void(frame, transform3 t, picture pic, projection P) {
+ if(pic != null) {
+ pic.add(new void(frame f, transform T) {
+ add(f,T*shift(project(t*position,P))*src);
+ },true);
+ }
+ },true);
+ }
+ dest.addBox(position,position,min3(src),max3(src));
+}
+
exitfcn currentexitfunction=atexit();
void exitfunction()