From 4631b9a200935cb69b604b1d7995fb0d85b229f2 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 6 Jul 2010 00:30:47 +0000 Subject: asymptote 2.01 git-svn-id: svn://tug.org/texlive/trunk@19252 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf/doc/asymptote/CAD.pdf | Bin 67565 -> 67395 bytes Master/texmf/doc/asymptote/asymptote.pdf | Bin 1692650 -> 1553892 bytes Master/texmf/doc/asymptote/examples/arrows3.asy | 2 + Master/texmf/doc/asymptote/examples/basealign.asy | 1 + Master/texmf/doc/asymptote/examples/billboard.asy | 2 + Master/texmf/doc/asymptote/examples/intro.asy | 933 +++++++++++---------- .../texmf/doc/asymptote/examples/latexusage-1.asy | 55 ++ .../texmf/doc/asymptote/examples/latexusage-2.asy | 23 + .../texmf/doc/asymptote/examples/latexusage-3.asy | 38 + Master/texmf/doc/asymptote/examples/latexusage.tex | 3 +- .../texmf/doc/asymptote/examples/mergeExample.asy | 77 ++ .../doc/asymptote/examples/partitionExample.asy | 27 + Master/texmf/doc/asymptote/examples/quilt.asy | 44 + Master/texmf/doc/asymptote/examples/workcone.asy | 8 +- Master/texmf/doc/asymptote/examples/xstitch.asy | 5 +- 15 files changed, 768 insertions(+), 450 deletions(-) create mode 100644 Master/texmf/doc/asymptote/examples/latexusage-1.asy create mode 100644 Master/texmf/doc/asymptote/examples/latexusage-2.asy create mode 100644 Master/texmf/doc/asymptote/examples/latexusage-3.asy create mode 100644 Master/texmf/doc/asymptote/examples/mergeExample.asy create mode 100644 Master/texmf/doc/asymptote/examples/partitionExample.asy create mode 100644 Master/texmf/doc/asymptote/examples/quilt.asy (limited to 'Master/texmf/doc/asymptote') diff --git a/Master/texmf/doc/asymptote/CAD.pdf b/Master/texmf/doc/asymptote/CAD.pdf index 7076ef94893..327f2ff3b0b 100644 Binary files a/Master/texmf/doc/asymptote/CAD.pdf and b/Master/texmf/doc/asymptote/CAD.pdf differ diff --git a/Master/texmf/doc/asymptote/asymptote.pdf b/Master/texmf/doc/asymptote/asymptote.pdf index f21cc658464..d4a834d8dde 100644 Binary files a/Master/texmf/doc/asymptote/asymptote.pdf and b/Master/texmf/doc/asymptote/asymptote.pdf differ diff --git a/Master/texmf/doc/asymptote/examples/arrows3.asy b/Master/texmf/doc/asymptote/examples/arrows3.asy index 12ad43463ee..57fc4b3d338 100644 --- a/Master/texmf/doc/asymptote/examples/arrows3.asy +++ b/Master/texmf/doc/asymptote/examples/arrows3.asy @@ -2,6 +2,8 @@ import three; size(15cm); +defaultrender.merge=true; + currentprojection=perspective(24,14,13); currentlight=light(gray(0.5),specularfactor=3,viewport=false, (0.5,-0.5,-0.25),(0.5,0.5,0.25),(0.5,0.5,1),(-0.5,-0.5,-1)); diff --git a/Master/texmf/doc/asymptote/examples/basealign.asy b/Master/texmf/doc/asymptote/examples/basealign.asy index 4bf83c94033..d653ec3c043 100644 --- a/Master/texmf/doc/asymptote/examples/basealign.asy +++ b/Master/texmf/doc/asymptote/examples/basealign.asy @@ -2,6 +2,7 @@ import fontsize; import three; settings.autobillboard=false; +settings.embed=false; currentprojection=orthographic(Z); defaultpen(fontsize(100pt)); diff --git a/Master/texmf/doc/asymptote/examples/billboard.asy b/Master/texmf/doc/asymptote/examples/billboard.asy index e126c1c5157..6e5df871007 100644 --- a/Master/texmf/doc/asymptote/examples/billboard.asy +++ b/Master/texmf/doc/asymptote/examples/billboard.asy @@ -2,6 +2,8 @@ import three; size(100); +currentprojection=perspective(1,-2,1); + draw(unitbox); label("Billboard",X,red,Billboard); diff --git a/Master/texmf/doc/asymptote/examples/intro.asy b/Master/texmf/doc/asymptote/examples/intro.asy index 4234b8cee8e..20b03c578dc 100644 --- a/Master/texmf/doc/asymptote/examples/intro.asy +++ b/Master/texmf/doc/asymptote/examples/intro.asy @@ -1,5 +1,3 @@ -// Introduction to Asymptote - orientation=Landscape; settings.tex="pdflatex"; @@ -8,6 +6,10 @@ import slide; import three; import animate; +bool long=true; + +usepackage("mflogo"); + usersetting(); viewportsize=pagewidth-2pagemargin; @@ -18,23 +20,39 @@ viewportsize=pagewidth-2pagemargin; bibliographystyle("alpha"); itempen=fontsize(22pt); - -titlepage("Asymptote: The Vector Graphics Language", - "Andy Hammerlindl and John Bowman", - "University of Toronto and University of Alberta","August 16, 2007", - "http://asymptote.sf.net"); +defaultpen(itempen); +viewportmargin=(2,2); + +titlepage(long ? "Asymptote: The Vector Graphics Language" : + "Interactive TeX-Aware 3D Vector Graphics", + "John Bowman and Andy Hammerlindl", +"Department of Mathematical and Statistical Sciences\\ + University of Alberta\\ +%and Instituto Nacional de Matem\'atica Pura e Aplicada (IMPA) +\medskip\Green{Collaborators: Orest Shardt, Michail Vidiassov}", +"June 30, 2010", +"http://asymptote.sf.net/intro.pdf"); title("History"); -item("\TeX\ and METAFONT (Knuth, 1979)"); -item("MetaPost (Hobby, 1989): 2D Bezier Control Point Selection"); -item("Asymptote (Hammerlindl, Bowman, Prince, 2004): 2D \& 3D Graphics"); - -title("Statistics (as of April, 2007)"); -item("Runs on Windows, Mac OS X, Linux, etc."); -item("1800 downloads a month from {\tt asymptote.sourceforge.net}."); -item("33\ 000 lines of C++ code."); -item("18\ 000 lines of Asymptote code."); - +item("1979: \TeX\ and \MF\ (Knuth)"); +item("1986: 2D B\'ezier control point selection (Hobby)"); +item("1989: MetaPost (Hobby)"); +item("2004: Asymptote"); +subitem("2004: initial public release (Hammerlindl, Bowman, \& Prince)"); +subitem("2005: 3D B\'ezier control point selection (Bowman)"); +subitem("2008: 3D interactive \TeX\ within PDF files (Shardt \& Bowman)"); +subitem("2009: 3D billboard labels that always face camera (Bowman)"); +subitem("2010: 3D PDF enhancements (Vidiassov \& Bowman)"); + +title("Statistics (as of June, 2010)"); +item("Runs under Linux/UNIX, Mac OS X, Microsoft Windows."); +item("4000 downloads/month from primary\hfill\\ + {\tt asymptote.sourceforge.net} site alone."); +item("80\ 000 lines of low-level C++ code."); +item("36\ 000 lines of high-level Asymptote code."); +item("Latest stable release: Version 2.00 (LGPL)."); + +if(long) { title("Vector Graphics"); item("Raster graphics assign colors to a grid of pixels."); figure("pixel.pdf"); @@ -61,17 +79,24 @@ add(zoom(100), (0,0)); add(zoom(10), (200,0)); add(zoom(1), (400,0)); ")); +} title("Cartesian Coordinates"); + +item("Asymptote's graphical capabilities are based on four primitive + commands: {\tt draw}, {\tt label}, {\tt fill}, {\tt clip} \cite{Bowman08}"); + asyfilecode("diagonal"); item("units are {\tt PostScript} {\it big points\/} (1 {\tt bp} = 1/72 {\tt inch})"); item("{\tt --} means join the points with a linear segment to create a {\it path}"); -item("cyclic path:"); +item("{\it cyclic\/} path:"); -asyfilecode("square"); +asycode(" +draw((0,0)--(100,0)--(100,100)--(0,100)--cycle); +"); title("Scaling to a Given Size"); @@ -79,11 +104,7 @@ item("{\tt PostScript} units are often inconvenient."); item("Instead, scale user coordinates to a specified final size:"); -code(" -size(101,101); -draw((0,0)--(1,0)--(1,1)--(0,1)--cycle); -"); -asyfigure("square"); +asyfilecode("square"); item("One can also specify the size in {\tt cm}:"); @@ -96,18 +117,36 @@ title("Labels"); item("Adding and aligning \LaTeX\ labels is easy:"); -asyfilecode("labelsquare","height=6cm"); - +asycode(preamble="defaultpen(fontsize("+string(fontsize(itempen))+"));", +"size(6cm); +draw(unitsquare); +label(\"$A$\",(0,0),SW); +label(\"$B$\",(1,0),SE); +label(\"$C$\",(1,1),NE); +label(\"$D$\",(0,1),NW); +"); -title("2D Bezier Splines"); +title("2D B\'ezier Splines"); -item("Using {\tt ..} instead of {\tt --} specifies a {\it Bezier cubic +item("Using {\tt ..} instead of {\tt --} specifies a {\it B\'ezier cubic spline}:"); code(" draw(z0 .. controls c0 and c1 .. z1,blue); "); -asyfigure("beziercurve","height=7cm"); +asyfigure(asywrite("defaultpen(fontsize("+string(fontsize(itempen))+")); +size(0,7cm); +pair z0=(0,0); +pair c0=(1,1); +pair c1=(2,1); +pair z1=(3,0); +draw(z0..controls c0 and c1 .. z1,blue); +draw(z0--c0--c1--z1,dashed); +dot(\"$z_0$\",z0,W,red); +dot(\"$c_0$\",c0,NW,red); +dot(\"$c_1$\",c1,NE,red); +dot(\"$z_1$\",z1,red); +")); equation("(1-t)^3 z_0+3t(1-t)^2 c_0+3t^2(1-t) c_1+t^3 z_1, \qquad t\in [0,1]."); @@ -139,7 +178,7 @@ dot(z); picture output; save(); -for (int i=0; i0$ and a shift $b$ so that all of the - coordinates when transformed will lie in the interval $[0,S]$. That is, if - $u$ and $t$ are the user and truesize components:"); + coordinates when transformed will lie in the interval $[0,S]$."); + +item("That is, if $u$ and $t$ are the user and truesize components:"); equation("0\le au+t+b \le S."); -item("We are maximizing the variable $a$ subject to a number of inequalities. - This is a linear programming problem that can be solved by the simplex - method."); +item("Maximize the variable $a$ subject to a number of inequalities."); +item("Use the simplex method to solve the resulting linear programming problem."); + +if(long) { title("Sizing"); item("Every addition of a coordinate $(t,u)$ adds two restrictions"); equation("au+t+b\ge 0,"); @@ -829,7 +615,7 @@ asyfigure(asywrite(" import palette; size(160,0); pen[] p=Rainbow(NColors=11); -for (int i=1; i<10; ++i) { +for(int i=1; i<10; ++i) { draw(scale(i)*unitcircle, p[i]+linewidth(2)); } ")); @@ -845,6 +631,7 @@ item("This defines a partial ordering on coordinates. When sizing a picture, item("In practice, the linear programming problem will have less than a dozen restraints."); item("All picture sizing is implemented in Asymptote code."); +} title("Infinite Lines"); item("Deferred drawing allows us to draw infinite lines."); @@ -852,59 +639,321 @@ code("drawline(P, Q);"); asyfigure("elliptic","height=12cm"); -title("A Final Example: Quilting"); +title("Helpful Math Notation"); + +item("Integer division returns a {\tt real}. Use {\tt quotient} for an integer + result:"); +code("3/4 == 0.75 quotient(3,4) == 0"); + +item("Caret for real and integer exponentiation:"); +code("2^3 2.7^3 2.7^3.2"); + +item("Many expressions can be implicitly scaled by a numeric constant:"); +code("2pi 10cm 2x^2 3sin(x) 2(a+b)"); + +item("Pairs are complex numbers:"); +code("(0,1)*(0,1) == (-1,0)"); + +title("Function Calls"); + +item("Functions can take default arguments in any position. Arguments are + matched to the first possible location:"); +string unitsize="unitsize(0.65cm);"; +string preamble="void drawEllipse(real xsize=1, real ysize=xsize, pen p=blue) { + draw(xscale(xsize)*yscale(ysize)*unitcircle, p); +} +"; + +asycode(preamble=unitsize,preamble+" +drawEllipse(2); +drawEllipse(red); +"); + +item("Arguments can be given by name:"); +asycode(preamble=unitsize+preamble," +drawEllipse(xsize=2, ysize=1); +drawEllipse(ysize=2, xsize=3, green); +"); + +if(long) { +title("Rest Arguments"); +item("Rest arguments allow one to write a function that takes an arbitrary + number of arguments:"); +code(" +int sum(... int[] nums) { + int total=0; + for(int i=0; i < nums.length; ++i) + total += nums[i]; + return total; +} + +sum(1,2,3,4); // returns 10 +sum(); // returns 0 +sum(1,2,3 ... new int[] {4,5,6}); // returns 21 + +int subtract(int start ... int[] subs) { + return start - sum(... subs); +} +"); +} + +title("High-Order Functions"); + +item("Functions are first-class values. They can be passed to other + functions:"); +code("import graph; +real f(real x) { + return x*sin(10x); +} +draw(graph(f,-3,3,300),red);"); asyfigure(asywrite(" -import math; +import graph; +size(300,0); +real f(real x) { + return x*sin(10x); +} +draw(graph(f,-3,3,300),red); +")); + +if(long) { +title("Higher-Order Functions"); +item("Functions can return functions:"); +equation("f_n(x)=n\sin\left(\frac{x}{n}\right)."); +skip(); +string preamble=" +import graph; +size(300,0); +"; +string graphfunc2=" +typedef real func(real); +func f(int n) { + real fn(real x) { + return n*sin(x/n); + } + return fn; +} + +func f1=f(1); +real y=f1(pi); -int n=8, skip=3; +for(int i=1; i<=5; ++i) + draw(graph(f(i),-10,10),red); +"; +code(graphfunc2); +string name=asywrite(graphfunc2,preamble=preamble); +asy(nativeformat(),name+".asy"); +label(graphic(name+"."+nativeformat()),(0.5,0), + Fill(figureborder,figuremattpen)); -pair r(int k) { return unityroot(n,k); } +title("Anonymous Functions"); -pen col=blue, col2=purple; +item("Create new functions with {\tt new}:"); +code(" +path p=graph(new real (real x) { return x*sin(10x); },-3,3,red); -guide square=box((1,1),(-1,-1)); +func f(int n) { + return new real (real x) { return n*sin(x/n); }; +}"); -guide step(int mult) -{ - guide g; - for (int k=0; k