diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-03 22:41:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-03 22:41:44 +0000 |
commit | 8b67398a304b54846d01ad667cf1fbb6eb0245d2 (patch) | |
tree | c5e045c9d36b21c8dffece4499e2a47e5dd4df8e /Master/texmf-dist/asymptote/tube.asy | |
parent | f76a89d7f9fc8837ce20a63e3a29b2ba75823159 (diff) |
asymptote 2.63 support files
git-svn-id: svn://tug.org/texlive/trunk@54036 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/tube.asy')
-rw-r--r-- | Master/texmf-dist/asymptote/tube.asy | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/Master/texmf-dist/asymptote/tube.asy b/Master/texmf-dist/asymptote/tube.asy index 33e2ea3c868..cfaf458db42 100644 --- a/Master/texmf-dist/asymptote/tube.asy +++ b/Master/texmf-dist/asymptote/tube.asy @@ -9,6 +9,33 @@ import three; +real tubegranularity=1e-7; + +void render(path3 s, real r, void f(path3, real)) +{ + void Split(triple z0, triple c0, triple c1, triple z1, real t0=0, real t1=1, + real depth=mantissaBits) { + if(depth > 0) { + real S=straightness(z0,c0,c1,z1); + if(S > max(tubegranularity*max(abs(z0),abs(c0),abs(c1),abs(z1)))) { + --depth; + triple m0=0.5*(z0+c0); + triple m1=0.5*(c0+c1); + triple m2=0.5*(c1+z1); + triple m3=0.5*(m0+m1); + triple m4=0.5*(m1+m2); + triple m5=0.5*(m3+m4); + real tm=0.5*(t0+t1); + Split(z0,m0,m3,m5,t0,tm,depth); + Split(m5,m4,m2,z1,tm,t1,depth); + return; + } + } + f(z0..controls c0 and c1..z1,t0); + } + Split(point(s,0),postcontrol(s,0),precontrol(s,1),point(s,1)); +} + // A 3D version of roundedpath(path, real). path3 roundedpath(path3 A, real r) { @@ -42,13 +69,8 @@ real[] sample(path3 g, real r, real relstep=0) real[] t; int n=length(g); if(relstep <= 0) { - for(int i=0; i < n; ++i) { - real S=straightness(g,i); - if(S < sqrtEpsilon*r) - t.push(i); - else - render(subpath(g,i,i+1),new void(path3, real s) {t.push(i+s);}); - } + for(int i=0; i < n; ++i) + render(subpath(g,i,i+1),r,new void(path3, real s) {t.push(i+s);}); t.push(n); } else { int nb=ceil(1/relstep); |