summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/base
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-07-20 23:59:26 +0000
committerKarl Berry <karl@freefriends.org>2009-07-20 23:59:26 +0000
commitc575a3e01c48c6807ff66e39df09c16ece08af60 (patch)
treec3bb87255b16358bb998849d2d83302bedea2e78 /Build/source/utils/asymptote/base
parent3927b41be4f2831464a2c190c28042b7285dd91b (diff)
asymptote 1.82
git-svn-id: svn://tug.org/texlive/trunk@14356 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/base')
-rw-r--r--Build/source/utils/asymptote/base/labelpath3.asy2
-rw-r--r--Build/source/utils/asymptote/base/three.asy15
-rw-r--r--Build/source/utils/asymptote/base/three_arrows.asy54
-rw-r--r--Build/source/utils/asymptote/base/tube.asy11
4 files changed, 46 insertions, 36 deletions
diff --git a/Build/source/utils/asymptote/base/labelpath3.asy b/Build/source/utils/asymptote/base/labelpath3.asy
index b8a946a07ae..bf2e6d4c084 100644
--- a/Build/source/utils/asymptote/base/labelpath3.asy
+++ b/Build/source/utils/asymptote/base/labelpath3.asy
@@ -21,7 +21,7 @@ triple[] firstframe(path3 p, triple optional=O)
}
// Modification of the bishop frame construction contained in
-// space_tube.asy(from Philippe Ivaldi's modules).
+// space_tube.asy (from Philippe Ivaldi's modules).
// For noncyclic path3s only
triple[] nextframe(path3 p, real reltimestart, triple[] start, real
reltimeend, int subdiv=20)
diff --git a/Build/source/utils/asymptote/base/three.asy b/Build/source/utils/asymptote/base/three.asy
index 2befc77a9c8..39075193073 100644
--- a/Build/source/utils/asymptote/base/three.asy
+++ b/Build/source/utils/asymptote/base/three.asy
@@ -1745,7 +1745,7 @@ transform3 align(triple u)
}
// return a rotation that maps X,Y to the projection plane.
-transform3 transform3(projection P)
+transform3 transform3(projection P=currentprojection)
{
triple v=unit(P.oblique ? P.camera : P.vector());
triple u=unit(perp(P.up,v));
@@ -2015,7 +2015,7 @@ draw=new void(frame f, path3 g, material p=currentpen,
if(settings.thick) {
real width=linewidth(q);
if(width > 0) {
- surface s=tube(g,width,p.granularity);
+ tube T=tube(g,width,p.granularity);
int L=length(g);
if(L >= 0) {
if(!cyclic(g)) {
@@ -2034,13 +2034,14 @@ draw=new void(frame f, path3 g, material p=currentpen,
cap=scale3r*unitcylinder;
cap.append(scale3r*shift(Z)*unitdisk);
}
- s.append(shift(point(g,0))*align(-dir0)*cap);
- s.append(shift(point(g,L))*align(dirL)*cap);
+ T.s.append(shift(point(g,0))*align(-dir0)*cap);
+ T.s.append(shift(point(g,L))*align(dirL)*cap);
}
- if(opacity(q) == 1) _draw(f,g,q);
+ if(opacity(q) == 1)
+ _draw(f,T.center,q);
}
- for(int i=0; i < s.s.length; ++i)
- draw3D(f,s.s[i],p,light);
+ for(int i=0; i < T.s.s.length; ++i)
+ draw3D(f,T.s.s[i],p,light);
} else _draw(f,g,q);
} else _draw(f,g,q);
}
diff --git a/Build/source/utils/asymptote/base/three_arrows.asy b/Build/source/utils/asymptote/base/three_arrows.asy
index 418065e5e1e..841c4f731f4 100644
--- a/Build/source/utils/asymptote/base/three_arrows.asy
+++ b/Build/source/utils/asymptote/base/three_arrows.asy
@@ -82,33 +82,41 @@ void render(path3 s, real granularity=tubegranularity, void f(path3, real))
Split(point(s,0),postcontrol(s,0),precontrol(s,1),point(s,1));
}
-surface tube(path3 g, real width, real granularity=tubegranularity)
+struct tube
{
- surface tube;
- real r=0.5*width;
+ surface s;
+ path3 center;
- transform3 t=scale3(r);
+ void operator init(path3 g, real width, real granularity=tubegranularity) {
+ real r=0.5*width;
- int n=length(g);
- for(int i=0; i < n; ++i) {
- real S=straightness(g,i);
- if(S < sqrtEpsilon*r) {
- triple v=point(g,i);
- triple u=point(g,i+1)-v;
- tube.append(shift(v)*align(unit(u))*scale(r,r,abs(u))*unitcylinder);
- } else {
- render(subpath(g,i,i+1),granularity,new void(path3 q, real) {
- real L=arclength(q);
- surface segment=scale(r,r,L)*unitcylinder;
- bend(segment,q,L);
- tube.s.append(segment.s);
- });
- }
+ transform3 t=scale3(r);
- if((cyclic(g) || i > 0) && abs(dir(g,i,1)-dir(g,i,-1)) > sqrtEpsilon)
- tube.append(shift(point(g,i))*t*align(dir(g,i,-1))*unithemisphere);
+ int n=length(g);
+ for(int i=0; i < n; ++i) {
+ path3 gi=subpath(g,i,i+1);
+ real S=straightness(g,i);
+ if(S < sqrtEpsilon*r) {
+ triple v=point(g,i);
+ triple u=point(g,i+1)-v;
+ s.append(shift(v)*align(unit(u))*scale(r,r,abs(u))*unitcylinder);
+ center=center&gi;
+ } else {
+ render(gi,granularity,new void(path3 q, real) {
+ real L=arclength(q);
+ surface segment=scale(r,r,L)*unitcylinder;
+ bend(segment,q,L);
+ s.s.append(segment.s);
+ triple a=L*Z/3;
+ center=center&bend(O,q,L)..controls bend(a,q,L) and bend(2a,q,L)..
+ bend(3a,q,L);
+ });
+ }
+
+ if((cyclic(g) || i > 0) && abs(dir(g,i,1)-dir(g,i,-1)) > sqrtEpsilon)
+ s.append(shift(point(g,i))*t*align(dir(g,i,-1))*unithemisphere);
+ }
}
- return tube;
}
// Refine a noncyclic path3 g so that it approaches its endpoint in
@@ -168,7 +176,7 @@ struct arrowhead3
}
if(draw)
for(path3 g : H)
- s.append(tube(g,width));
+ s.append(tube(g,width).s);
return shift(v)*s;
}
diff --git a/Build/source/utils/asymptote/base/tube.asy b/Build/source/utils/asymptote/base/tube.asy
index f62d3897adf..1f8ef950251 100644
--- a/Build/source/utils/asymptote/base/tube.asy
+++ b/Build/source/utils/asymptote/base/tube.asy
@@ -15,9 +15,9 @@ path3 roundedpath(path3 A, real r)
guide3 rounded;
triple before, after, indir, outdir;
int len=length(A);
- bool guideclosed=cyclic(A);
+ bool cyclic=cyclic(A);
if(len < 2) {return A;};
- if(guideclosed) {rounded=point(point(A,0)--point(A,1),r);}
+ if(cyclic) {rounded=point(point(A,0)--point(A,1),r);}
else {rounded=point(A,0);}
for(int i=1; i < len; i=i+1) {
before=point(point(A,i)--point(A,i-1),r);
@@ -26,7 +26,7 @@ path3 roundedpath(path3 A, real r)
outdir=dir(point(A,i)--point(A,i+1),1);
rounded=rounded--before{indir}..{outdir}after;
}
- if(guideclosed) {
+ if(cyclic) {
before=point(point(A,0)--point(A,len-1),r);
indir=dir(point(A,len-1)--point(A,0),1);
outdir=dir(point(A,0)--point(A,1),1);
@@ -205,6 +205,7 @@ surface tube(path3 g, coloredpath section,
pair M=max(section.p), m=min(section.p);
real[] t=sample(g,max(M.x-m.x,M.y-m.y)/max(realEpsilon,abs(corner)),
min(abs(relstep),1));
- t.cyclic(cyclic(g));
- return surface(rmf(g,t),section,T,cyclic(g));
+ bool cyclic=cyclic(g);
+ t.cyclic(cyclic);
+ return surface(rmf(g,t),section,T,cyclic);
}