summaryrefslogtreecommitdiff
path: root/graphics/asymptote/base/three_tube.asy
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-03-05 03:00:59 +0000
committerNorbert Preining <norbert@preining.info>2020-03-05 03:00:59 +0000
commit898048513951b471a492afa23e46112d14bcb236 (patch)
tree8596afc705f55d2d07b324a756f7283ac0e2d21b /graphics/asymptote/base/three_tube.asy
parent19d25b8009801aa98ea2f46b45c37c257f990491 (diff)
CTAN sync 202003050300
Diffstat (limited to 'graphics/asymptote/base/three_tube.asy')
-rw-r--r--graphics/asymptote/base/three_tube.asy19
1 files changed, 14 insertions, 5 deletions
diff --git a/graphics/asymptote/base/three_tube.asy b/graphics/asymptote/base/three_tube.asy
index 86451b97fa..a5b8f3cc89 100644
--- a/graphics/asymptote/base/three_tube.asy
+++ b/graphics/asymptote/base/three_tube.asy
@@ -16,9 +16,12 @@ struct rmf {
// http://www.cs.hku.hk/research/techreps/document/TR-2007-07.pdf
rmf[] rmf(path3 g, real[] t)
{
+ static triple s0;
+ triple T=dir(g,0);
+ triple Tp=cross(s0,T);
+ Tp=abs(Tp) < sqrtEpsilon ? perp(T) : unit(Tp);
rmf[] R=new rmf[t.length];
- triple d=dir(g,0);
- R[0]=rmf(point(g,0),perp(d),d);
+ R[0]=rmf(point(g,0),Tp,T);
for(int i=1; i < t.length; ++i) {
rmf Ri=R[i-1];
real t=t[i];
@@ -37,14 +40,17 @@ rmf[] rmf(path3 g, real[] t)
} else
R[i]=R[i-1];
}
+ s0=R[t.length-1].s;
return R;
}
rmf[] rmf(triple z0, triple c0, triple c1, triple z1, real[] t)
{
+ static triple s0;
+
real norm=sqrtEpsilon*max(abs(z0),abs(c0),abs(c1),abs(z1));
-// Special case of dir for t in (0,1].
+ // Special case of dir for t in (0,1].
triple dir(real t) {
if(t == 1) {
triple dir=z1-c1;
@@ -63,7 +69,6 @@ rmf[] rmf(triple z0, triple c0, triple c1, triple z1, real[] t)
return unit(a);
}
- rmf[] R=new rmf[t.length];
triple T=c0-z0;
if(abs(T) < norm) {
T=z0-2*c0+c1;
@@ -71,8 +76,11 @@ rmf[] rmf(triple z0, triple c0, triple c1, triple z1, real[] t)
T=z1-z0+3.0*(c0-c1);
}
T=unit(T);
- triple Tp=perp(T);
+ triple Tp=cross(s0,T);
+ Tp=abs(Tp) < sqrtEpsilon ? perp(T) : unit(Tp);
+ rmf[] R=new rmf[t.length];
R[0]=rmf(z0,Tp,T);
+
for(int i=1; i < t.length; ++i) {
rmf Ri=R[i-1];
real t=t[i];
@@ -91,6 +99,7 @@ rmf[] rmf(triple z0, triple c0, triple c1, triple z1, real[] t)
} else
R[i]=R[i-1];
}
+ s0=R[t.length-1].s;
return R;
}