summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/examples
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/examples')
-rw-r--r--Build/source/utils/asymptote/examples/animations/earthmoon.asy2
-rw-r--r--Build/source/utils/asymptote/examples/animations/sphere.asy6
-rw-r--r--Build/source/utils/asymptote/examples/animations/wheel.asy16
-rw-r--r--Build/source/utils/asymptote/examples/electromagnetic.asy12
-rw-r--r--Build/source/utils/asymptote/examples/hyperboloid.asy4
-rw-r--r--Build/source/utils/asymptote/examples/hyperboloidsilhouette.asy4
-rw-r--r--Build/source/utils/asymptote/examples/pseudosphere.asy33
-rw-r--r--Build/source/utils/asymptote/examples/ring.asy1
-rw-r--r--Build/source/utils/asymptote/examples/splitpatch.asy69
9 files changed, 122 insertions, 25 deletions
diff --git a/Build/source/utils/asymptote/examples/animations/earthmoon.asy b/Build/source/utils/asymptote/examples/animations/earthmoon.asy
index 08c578d86d2..efca043b8bc 100644
--- a/Build/source/utils/asymptote/examples/animations/earthmoon.asy
+++ b/Build/source/utils/asymptote/examples/animations/earthmoon.asy
@@ -62,7 +62,7 @@ draw(pic,shift(cst,0,0)*scale3(Rtl/2)*unitsphere,yellow);
surface terre=scale3(Rtl/5)*unitsphere;
surface lune=scale3(Rl)*unitsphere;
-int n=100;
+int n=50;
real step=2pi/n;
for(int i=0; i < n; ++i) {
diff --git a/Build/source/utils/asymptote/examples/animations/sphere.asy b/Build/source/utils/asymptote/examples/animations/sphere.asy
index 56c5f73e3b6..125cecc5566 100644
--- a/Build/source/utils/asymptote/examples/animations/sphere.asy
+++ b/Build/source/utils/asymptote/examples/animations/sphere.asy
@@ -22,11 +22,7 @@ for(int i=0; i < nbpts; ++i) {
transform3 t=rotate(angle,(0,0,0),(1,0.25,0.25));
revolution r=sphere(O,3);
draw(surface(r),lightgrey);
-skeleton s;
-r.transverse(s,reltime(r.g,0.5));
-r.longitudinal(s);
-draw(s.transverse.back,linetype("8 8",8));
-draw(s.transverse.front);
+draw(r,backpen=linetype("8 8",8));
animation A;
diff --git a/Build/source/utils/asymptote/examples/animations/wheel.asy b/Build/source/utils/asymptote/examples/animations/wheel.asy
index 2ea45f75613..6620d590850 100644
--- a/Build/source/utils/asymptote/examples/animations/wheel.asy
+++ b/Build/source/utils/asymptote/examples/animations/wheel.asy
@@ -1,4 +1,9 @@
import graph;
+
+// Uncomment the following 2 lines to support pdf animations:
+// usepackage("animate");
+// settings.tex="pdflatex";
+
import animation;
size(0,200);
@@ -24,6 +29,8 @@ guide wheel(guide g=nullpath, real a, real b, int n)
real t1=0;
real t2=t1+2*pi;
+animation a;
+
draw(circle((0,0),1));
draw(wheel(t1,t2,100),linetype("0 2"));
yequals(Label("$y=-1$",1.0),-1,extend=true,linetype("4 4"));
@@ -34,8 +41,6 @@ pair z2=wheelpoint(t2);
dot(z1);
dot(z2);
-animation a;
-
int n=10;
real dt=(t2-t1)/n;
for(int i=0; i <= n; ++i) {
@@ -49,5 +54,10 @@ for(int i=0; i <= n; ++i) {
restore();
}
-// Produce the final merged gif.
+erase();
+
+// Merge the images into a gif animation.
a.movie(BBox(0.25cm),loops=10,delay=250);
+
+// Merge the images into a pdf animation.
+// label(a.pdf(BBox(0.25cm),delay=250,"controls",multipage=false));
diff --git a/Build/source/utils/asymptote/examples/electromagnetic.asy b/Build/source/utils/asymptote/examples/electromagnetic.asy
index 058c7c5c574..d229f76b748 100644
--- a/Build/source/utils/asymptote/examples/electromagnetic.asy
+++ b/Build/source/utils/asymptote/examples/electromagnetic.asy
@@ -33,15 +33,15 @@ picture q=secondaryX(new void(picture p) {
scale(p,LogLeft,Linear);
xlimits(p,lambda(fmax),lambda(fmin));
ylimits(p,0,1);
- xaxis(p,Label("\nano\metre",1),Top,LeftTicks(DefaultLogFormat,n=10));
+ xaxis(p,Label("\nano\metre",1,0.01N),Top,LeftTicks(DefaultLogFormat,n=10));
});
add(q,above=true);
margin margin=PenMargin(0,0);
-draw("radio",Scale((10,1))--Scale((5e12,1)),N,Arrow);
-draw("infrared",Scale((1e12,1.5))--Scale(shift(0,1.5)*ir),Arrows,margin);
-draw("UV",Scale(shift(0,1.5)*uv)--Scale((1e17,1.5)),Arrows,margin);
-draw("x-rays",Scale((1e16,1))--Scale((1e21,1)),N,Arrows);
-draw("$\gamma$-rays",Scale((fmax,1.5))--Scale((2e18,1.5)),Arrow);
+draw("radio",Scale((10,1))--Scale((5e12,1)),S,Arrow);
+draw("infrared",Scale((1e12,1.75))--Scale(shift(0,1.75)*ir),LeftSide,Arrows,margin);
+draw("UV",Scale(shift(0,1.75)*uv)--Scale((1e17,1.76)),LeftSide,Arrows,margin);
+draw("x-rays",Scale((1e16,1))--Scale((1e21,1)),RightSide,Arrows);
+draw("$\gamma$-rays",Scale((fmax,1.75))--Scale((2e18,1.75)),Arrow);
diff --git a/Build/source/utils/asymptote/examples/hyperboloid.asy b/Build/source/utils/asymptote/examples/hyperboloid.asy
index 0cf6da08c40..22f3b3d80b0 100644
--- a/Build/source/utils/asymptote/examples/hyperboloid.asy
+++ b/Build/source/utils/asymptote/examples/hyperboloid.asy
@@ -2,7 +2,7 @@ size(200);
import solids;
currentprojection=perspective(4,4,3);
-revolution hyperboloid=revolution(new real(real x) {return sqrt(1+x*x);},
- -2,2,20,operator..,X);
+revolution hyperboloid=revolution(graph(new triple(real z) {
+ return (sqrt(1+z*z),0,z);},-2,2,20,operator ..),axis=Z);
draw(surface(hyperboloid),green,render(compression=Low,merge=true));
draw(hyperboloid,6,blue,longitudinalpen=nullpen);
diff --git a/Build/source/utils/asymptote/examples/hyperboloidsilhouette.asy b/Build/source/utils/asymptote/examples/hyperboloidsilhouette.asy
index 1187208a670..1bb265de622 100644
--- a/Build/source/utils/asymptote/examples/hyperboloidsilhouette.asy
+++ b/Build/source/utils/asymptote/examples/hyperboloidsilhouette.asy
@@ -4,6 +4,6 @@ settings.render=0;
settings.prc=false;
currentprojection=perspective(4,4,3);
-revolution hyperboloid=revolution(new real(real x) {return sqrt(1+x*x);},
- -2,2,20,operator..,X);
+revolution hyperboloid=revolution(graph(new triple(real z) {
+ return (sqrt(1+z*z),0,z);},-2,2,20,operator ..),axis=Z);
draw(hyperboloid.silhouette(64),blue);
diff --git a/Build/source/utils/asymptote/examples/pseudosphere.asy b/Build/source/utils/asymptote/examples/pseudosphere.asy
new file mode 100644
index 00000000000..a740381ef0e
--- /dev/null
+++ b/Build/source/utils/asymptote/examples/pseudosphere.asy
@@ -0,0 +1,33 @@
+// Pseudosphere:
+// x = a sin(u) cos(v);
+// y = a sin(u) sin(v);
+// z = a (ln(tg(u/2))+cos(u));
+
+import three;
+import solids;
+import graph3;
+import palette;
+
+triple pseudosphere(real x) {
+ return (sin(x),0,cos(x)+log(tan(x/2)));
+}
+
+size(20cm,IgnoreAspect);
+currentprojection=orthographic(160,40,100);
+currentlight=(50,50,50);
+
+path3 G=graph(pseudosphere,0.5pi,0.965pi,10,Spline);
+
+revolution r=revolution(O,G,Z);
+
+draw(r,1,longitudinalpen=nullpen);
+surface s=surface(r);
+s.colors(palette(s.map(zpart),Gradient(cyan+white+opacity(0.9),
+ magenta+white+opacity(0.9))));
+draw(s);
+
+draw(r,6,backpen=linetype("10 10",10),longitudinalpen=nullpen);
+
+int n=10;
+for(int i=0; i < n; ++i)
+ draw(rotate(i*360/n,O,Z)*G);
diff --git a/Build/source/utils/asymptote/examples/ring.asy b/Build/source/utils/asymptote/examples/ring.asy
index 6963d42d23f..5fec60d4c0b 100644
--- a/Build/source/utils/asymptote/examples/ring.asy
+++ b/Build/source/utils/asymptote/examples/ring.asy
@@ -1,5 +1,4 @@
size(0,100);
-path unitcircle=E..N..W..S..cycle;
path g=scale(2)*unitcircle;
label("$a \le r \le b$");
radialshade(unitcircle^^g,yellow+evenodd,(0,0),1.0,yellow+brown,(0,0),2);
diff --git a/Build/source/utils/asymptote/examples/splitpatch.asy b/Build/source/utils/asymptote/examples/splitpatch.asy
index f1f5b6b98ba..2e9fae66431 100644
--- a/Build/source/utils/asymptote/examples/splitpatch.asy
+++ b/Build/source/utils/asymptote/examples/splitpatch.asy
@@ -2,6 +2,64 @@ import three;
size(300);
+// A structure to subdivide two intersecting patches about their intersection.
+struct split
+{
+ surface[] S=sequence(new surface(int i) {return new surface;},1);
+ surface[] T=sequence(new surface(int i) {return new surface;},1);
+
+ struct tree {
+ tree[] tree=new tree[2];
+ }
+ // Default subdivision depth.
+ int n=20;
+
+ // Subdivide p and q to depth n if they overlap.
+ void write(tree pt, tree qt, triple[][] p, triple[][] q, int depth=n) {
+ --depth;
+ triple[][][] Split(triple[][] P)=depth % 2 == 0 ? hsplit : vsplit;
+ triple[][][] P=Split(p);
+ triple[][][] Q=Split(q);
+
+ for(int i=0; i < 2; ++i) {
+ triple[][] Pi=P[i];
+ for(int j=0; j < 2; ++j) {
+ triple[][] Qj=Q[j];
+ if(overlap(Pi,Qj)) {
+ if(!pt.tree.initialized(i))
+ pt.tree[i]=new tree;
+ if(!qt.tree.initialized(j))
+ qt.tree[j]=new tree;
+ if(depth > 0)
+ write(pt.tree[i],qt.tree[j],Pi,Qj,depth);
+ }
+ }
+ }
+ }
+
+ // Output the subpatches of p from subdivision.
+ void read(surface[] S, tree t, triple[][] p, int depth=n) {
+ --depth;
+ triple[][][] Split(triple[][] P)=depth % 2 == 0 ? hsplit : vsplit;
+ triple[][][] P=Split(p);
+
+ for(int i=0; i < 2; ++i) {
+ if(t.tree.initialized(i))
+ read(S,t.tree[i],P[i],depth);
+ else {
+ S[0].push(patch(P[i]));
+ }
+ }
+ }
+
+ void operator init(triple[][] p, triple[][] q, int depth=n) {
+ tree ptrunk,qtrunk;
+ write(ptrunk,qtrunk,p,q,depth);
+ read(T,ptrunk,p,depth);
+ read(S,qtrunk,q,depth);
+ }
+}
+
currentprojection=orthographic(0,0,1);
triple[][] A={
@@ -18,11 +76,12 @@ triple[][] B={
{(0.5,0,2),(0.5,1,2),(0.5,2,2),(0.5,3,2)}
};
-split S=split(A,B,10);
-//write(S.T.length);
+split S=split(B,A);
defaultrender.merge=true;
-for(int i=0; i < S.T.length; ++i)
- draw(surface(patch(S.T[i])),Pen(i));
-draw(surface(patch(B)),blue);
+for(int i=0; i < S.S[0].s.length; ++i)
+ draw(surface(S.S[0].s[i]),Pen(i));
+
+for(int i=0; i < S.T[0].s.length; ++i)
+ draw(surface(S.T[0].s[i]),Pen(i));