summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/base
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-18 23:24:00 +0000
committerKarl Berry <karl@freefriends.org>2010-06-18 23:24:00 +0000
commit47fea6d4aa5c9cfb2e71c51f769dac3023630035 (patch)
tree6a4b15f0b85d8bb5602146e20241b49e938f409b /Build/source/utils/asymptote/base
parent0dfdf5c49b160d464b74a9cae8882ea81cc47878 (diff)
asy 1.99
git-svn-id: svn://tug.org/texlive/trunk@19047 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/base')
-rw-r--r--Build/source/utils/asymptote/base/bezulate.asy48
-rw-r--r--Build/source/utils/asymptote/base/graph3.asy81
-rw-r--r--Build/source/utils/asymptote/base/three.asy23
-rw-r--r--Build/source/utils/asymptote/base/three_surface.asy7
-rw-r--r--Build/source/utils/asymptote/base/three_tube.asy15
5 files changed, 88 insertions, 86 deletions
diff --git a/Build/source/utils/asymptote/base/bezulate.asy b/Build/source/utils/asymptote/base/bezulate.asy
index f3817a47bcf..5b21d8c1605 100644
--- a/Build/source/utils/asymptote/base/bezulate.asy
+++ b/Build/source/utils/asymptote/base/bezulate.asy
@@ -20,34 +20,34 @@ int countIntersections(path[] p, pair start, pair end)
path[][] containmentTree(path[] paths)
{
path[][] result;
- for(int i=0; i < paths.length; ++i) {
- bool classified=false;
+ for(path g : paths) {
// check if current curve contains or is contained in a group of curves
- for(int j=0; !classified && j < result.length; ++j)
- {
- int test = inside(paths[i],result[j][0],zerowinding);
- if(test == 1) // current curve contains group's toplevel curve
- {
- // replace toplevel curve with current curve
- result[j].insert(0,paths[i]);
- classified = true;
- }
- else if(test == -1) // current curve contained in group's toplevel curve
- {
- result[j].push(paths[i]);
- classified = true;
- }
+ int j;
+ for(j=0; j < result.length; ++j) {
+ path[] resultj=result[j];
+ int test=inside(g,resultj[0],zerowinding);
+ if(test == 1) {
+ // current curve contains group's toplevel curve;
+ // replace toplevel curve with current curve
+ resultj.insert(0,g);
+ // check to see if any other groups are contained within this curve
+ for(int k=j+1; k < result.length;) {
+ if(inside(g,result[k][0]) == 1) {
+ resultj.append(result[k]);
+ result.delete(k);
+ } else ++k;
+ }
+ break;
+ } else if(test == -1) {
+ // current curve contained within group's toplevel curve
+ resultj.push(g);
+ break;
}
+ }
// create a new group if this curve does not belong to another group
- if(!classified)
- result.push(new path[] {paths[i]});
+ if(j == result.length)
+ result.push(new path[] {g});
}
-
- // sort group so that later paths in the array are contained in previous paths
- bool comparepaths(path i, path j) {return inside(i,j,zerowinding)==1;}
- for(int i=0; i < result.length; ++i)
- result[i] = sort(result[i],comparepaths);
-
return result;
}
diff --git a/Build/source/utils/asymptote/base/graph3.asy b/Build/source/utils/asymptote/base/graph3.asy
index ee83e8cb99b..9eee4209134 100644
--- a/Build/source/utils/asymptote/base/graph3.asy
+++ b/Build/source/utils/asymptote/base/graph3.asy
@@ -1610,60 +1610,55 @@ surface bispline(real[][] z, real[][] p, real[][] q, real[][] r,
surface s=surface(count);
s.index=new int[n][m];
- int k=-1;
+ int k=0;
for(int i=0; i < n; ++i) {
- bool[] condi=all ? null : cond[i];
+ int ip=i+1;
real xi=x[i];
+ real xp=x[ip];
+ real x1=interp(xi,xp,1/3);
+ real x2=interp(xi,xp,2/3);
+ real hx=x1-xi;
real[] zi=z[i];
- real[] zp=z[i+1];
+ real[] zp=z[ip];
real[] ri=r[i];
- real[] rp=r[i+1];
+ real[] rp=r[ip];
real[] pi=p[i];
- real[] pp=p[i+1];
+ real[] pp=p[ip];
real[] qi=q[i];
- real[] qp=q[i+1];
- real xp=x[i+1];
- real hx=(xp-xi)/3;
+ real[] qp=q[ip];
int[] indexi=s.index[i];
+ bool[] condi=all ? null : cond[i];
for(int j=0; j < m; ++j) {
- real yj=y[j];
- real yp=y[j+1];
if(all || condi[j]) {
- triple[][] P=array(4,array(4,O));
- real hy=(yp-yj)/3;
+ real yj=y[j];
+ int jp=j+1;
+ real yp=y[jp];
+ real y1=interp(yj,yp,1/3);
+ real y2=interp(yj,yp,2/3);
+ real hy=y1-yj;
real hxy=hx*hy;
- // x and y directions
- for(int k=0; k < 4; ++k) {
- P[0][k] += xi*X;
- P[k][0] += yj*Y;
- P[1][k] += (xp+2*xi)/3*X;
- P[k][1] += (yp+2*yj)/3*Y;
- P[2][k] += (2*xp+xi)/3*X;
- P[k][2] += (2*yp+yj)/3*Y;
- P[3][k] += xp*X;
- P[k][3] += yp*Y;
- }
- // z: value
- P[0][0] += zi[j]*Z;
- P[3][0] += zp[j]*Z;
- P[0][3] += zi[j+1]*Z;
- P[3][3] += zp[j+1]*Z;
- // z: first derivative
- P[1][0] += (P[0][0].z+hx*pi[j])*Z;
- P[1][3] += (P[0][3].z+hx*pi[j+1])*Z;
- P[2][0] += (P[3][0].z-hx*pp[j])*Z;
- P[2][3] += (P[3][3].z-hx*pp[j+1])*Z;
- P[0][1] += (P[0][0].z+hy*qi[j])*Z;
- P[3][1] += (P[3][0].z+hy*qp[j])*Z;
- P[0][2] += (P[0][3].z-hy*qi[j+1])*Z;
- P[3][2] += (P[3][3].z-hy*qp[j+1])*Z;
- // z: second derivative
- P[1][1] += (P[0][1].z+P[1][0].z-P[0][0].z+hxy*ri[j])*Z;
- P[1][2] += (P[0][2].z+P[1][3].z-P[0][3].z-hxy*ri[j+1])*Z;
- P[2][1] += (P[2][0].z+P[3][1].z-P[3][0].z-hxy*rp[j])*Z;
- P[2][2] += (P[2][3].z+P[3][2].z-P[3][3].z+hxy*rp[j+1])*Z;
- s.s[++k]=patch(P);
+ real zij=zi[j];
+ real zip=zi[jp];
+ real zpj=zp[j];
+ real zpp=zp[jp];
+ real pij=hx*pi[j];
+ real ppj=hx*pp[j];
+ real qip=hy*qi[jp];
+ real qpp=hy*qp[jp];
+ real zippip=zip+hx*pi[jp];
+ real zppmppp=zpp-hx*pp[jp];
+ real zijqij=zij+hy*qi[j];
+ real zpjqpj=zpj+hy*qp[j];
+
+ s.s[k]=patch(new triple[][] {
+ {(xi,yj,zij),(xi,y1,zijqij),(xi,y2,zip-qip),(xi,yp,zip)},
+ {(x1,yj,zij+pij),(x1,y1,zijqij+pij+hxy*ri[j]),
+ (x1,y2,zippip-qip-hxy*ri[jp]),(x1,yp,zippip)},
+ {(x2,yj,zpj-ppj),(x2,y1,zpjqpj-ppj-hxy*rp[j]),
+ (x2,y2,zppmppp-qpp+hxy*rp[jp]),(x2,yp,zppmppp)},
+ {(xp,yj,zpj),(xp,y1,zpjqpj),(xp,y2,zpp-qpp),(xp,yp,zpp)}},copy=false);
indexi[j]=k;
+ ++k;
}
}
}
diff --git a/Build/source/utils/asymptote/base/three.asy b/Build/source/utils/asymptote/base/three.asy
index 2de8b4a5cca..f528e2a9e52 100644
--- a/Build/source/utils/asymptote/base/three.asy
+++ b/Build/source/utils/asymptote/base/three.asy
@@ -2746,10 +2746,13 @@ struct scene
transform3 T=identity4;
picture pic2;
- void operator init(frame f, projection P=currentprojection) {
+ void operator init(frame f, real width, real height,
+ projection P=currentprojection) {
this.f=f;
this.t=identity4;
this.P=P;
+ this.width=width;
+ this.height=height;
}
void operator init(picture pic, real xsize=pic.xsize, real ysize=pic.ysize,
@@ -2897,8 +2900,8 @@ object embed(string label="", string text=label, string prefix=defaultfilename,
triple lambda=M-m;
S.viewportmargin=viewportmargin((lambda.x,lambda.y));
- S.width=lambda.x+2*S.viewportmargin.x;
- S.height=lambda.y+2*S.viewportmargin.y;
+ S.width=ceil(max(S.width,lambda.x)+2*S.viewportmargin.x);
+ S.height=ceil(max(S.height,lambda.y)+2*S.viewportmargin.y);
S.f=shift((-0.5(m.x+M.x),-0.5*(m.y+M.y),0))*S.f; // Eye will be at (0,0,0)
} else {
if(P.angle == 0) {
@@ -3018,7 +3021,8 @@ object embed(string label="", string text=label,
light light=currentlight, projection P=currentprojection)
{
if(is3D(format))
- return embed(label,text,prefix,scene(f,P),format,view,options,script,light);
+ return embed(label,text,prefix,scene(f,width,height,P),format,view,options,
+ script,light);
else {
object F;
F.f=f;
@@ -3072,11 +3076,13 @@ currentpicture.fitter=new frame(string prefix, picture pic, string format,
return f;
};
-frame embedder(string prefix, frame f, string format, bool view,
- string options, string script, light light, projection P)
+frame embedder(string prefix, frame f, string format, real width, real height,
+ bool view, string options, string script, light light,
+ projection P)
{
return embedder(new object(string prefix, string format) {
- return embed(prefix=prefix,f,format,view,options,script,light,P);
+ return embed(prefix=prefix,f,format,width,height,view,options,script,
+ light,P);
},prefix,format,view,light);
}
@@ -3225,7 +3231,8 @@ frame[] fit3(string prefix="", picture[] pictures, picture all,
for(int i=settings.reverse ? pictures.length-1 : 0;
i >= 0 && i < pictures.length && !settings.interrupt;
settings.reverse ? --i : ++i) {
- frame f=embedder(prefix,out[i],format,view,options,script,light,S.P);
+ frame f=embedder(prefix,out[i],format,S.width,S.height,view,options,
+ script,light,S.P);
if(!settings.loop) out[i]=f;
}
if(!settings.loop) break;
diff --git a/Build/source/utils/asymptote/base/three_surface.asy b/Build/source/utils/asymptote/base/three_surface.asy
index c4f05c7882f..6d0c54d2479 100644
--- a/Build/source/utils/asymptote/base/three_surface.asy
+++ b/Build/source/utils/asymptote/base/three_surface.asy
@@ -10,7 +10,7 @@ private real Fuzz=10.0*realEpsilon;
private real nineth=1/9;
struct patch {
- triple[][] P=new triple[4][4];
+ triple[][] P;
triple[] normals; // Optionally specify 4 normal vectors at the corners.
pen[] colors; // Optionally specify 4 corner colors.
bool straight; // Patch is based on a piecewise straight external path.
@@ -186,9 +186,9 @@ struct patch {
void operator init(triple[][] P, triple[] normals=new triple[],
pen[] colors=new pen[], bool straight=false,
- bool3 planar=default) {
+ bool3 planar=default, bool copy=true) {
init();
- this.P=copy(P);
+ this.P=copy ? copy(P) : P;
if(normals.length != 0)
this.normals=copy(normals);
if(colors.length != 0)
@@ -306,6 +306,7 @@ struct patch {
patch operator * (transform3 t, patch s)
{
patch S;
+ S.P=new triple[4][4];
for(int i=0; i < 4; ++i) {
triple[] si=s.P[i];
triple[] Si=S.P[i];
diff --git a/Build/source/utils/asymptote/base/three_tube.asy b/Build/source/utils/asymptote/base/three_tube.asy
index 281eb0716da..aa5688f081e 100644
--- a/Build/source/utils/asymptote/base/three_tube.asy
+++ b/Build/source/utils/asymptote/base/three_tube.asy
@@ -92,8 +92,9 @@ private real[][][] bispline0(real[][] z, real[][] p, real[][] q, real[][] r,
int k=0;
for(int i=0; i < n; ++i) {
int ip=i+1;
- bool[] condi=all ? null : cond[i];
real xi=x[i];
+ real xp=x[ip];
+ real hx=(xp-xi)/3;
real[] zi=z[i];
real[] zp=z[ip];
real[] ri=r[i];
@@ -102,13 +103,12 @@ private real[][][] bispline0(real[][] z, real[][] p, real[][] q, real[][] r,
real[] pp=p[ip];
real[] qi=q[i];
real[] qp=q[ip];
- real xp=x[ip];
- real hx=(xp-xi)/3;
+ bool[] condi=all ? null : cond[i];
for(int j=0; j < m; ++j) {
- real yj=y[j];
- int jp=j+1;
- real yp=y[jp];
if(all || condi[j]) {
+ real yj=y[j];
+ int jp=j+1;
+ real yp=y[jp];
real hy=(yp-yj)/3;
real hxy=hx*hy;
real zij=zi[j];
@@ -164,8 +164,7 @@ real[][][] bispline(real[][] f, real[] x, real[] y,
real[][] p=transpose(tp);
for(int i=0; i < n; ++i)
r[i]=clamped(d1[i],d2[i])(y,p[i]);
- real[][][] s=bispline0(f,p,q,r,x,y,cond);
- return s;
+ return bispline0(f,p,q,r,x,y,cond);
}
bool uperiodic(real[][] a) {