diff options
Diffstat (limited to 'Build/source/utils/asymptote/doc/asymptote.texi')
-rw-r--r-- | Build/source/utils/asymptote/doc/asymptote.texi | 90 |
1 files changed, 53 insertions, 37 deletions
diff --git a/Build/source/utils/asymptote/doc/asymptote.texi b/Build/source/utils/asymptote/doc/asymptote.texi index 4a08d9c58ea..a25fae07653 100644 --- a/Build/source/utils/asymptote/doc/asymptote.texi +++ b/Build/source/utils/asymptote/doc/asymptote.texi @@ -3873,7 +3873,6 @@ as initializers, as in @code{real x=2*sin(pi/2);}. A variable is not added to the namespace until after the initializer is evaluated, so for example, in - @verbatim int x=2; int x=5*x; @@ -3911,7 +3910,6 @@ it a value. The default initializer for any type @code{T} can be redeclared by defining the function @code{T operator init()}. For instance, @code{int} variables are usually initialized to zero, but in - @verbatim int operator init() { return 3; @@ -3925,6 +3923,23 @@ illustrative purposes; redeclaring the initializers of built-in types is not recommended. Typically, @code{operator init} is used to define sensible defaults for user-defined types. +@cindex @code{var} +The special type @code{var} may be used to infer the type of a variable from +its initializer. If the initializer is an expression of a unique type, then +the variable will be defined with that type. For instance, +@verbatim +var x=5; +var y=4.3; +var reddash=red+dashed; +@end verbatim +@noindent +is equivalent to +@verbatim +int x=5; +real y=4.3; +pen reddash=red+dashed; +@end verbatim + @node Structures @section Structures @cindex @code{struct} @@ -3947,7 +3962,6 @@ structure. Any code at the top-level scope within the structure is executed on initialization. Variables hold references to structures. That is, in the example: - @verbatim struct T { int x; @@ -3967,7 +3981,6 @@ that @code{foo.x} will also be equal to @code{5}. The expression @code{new T} creates a new instance of the structure @code{T} and returns a reference to that instance. In creating the new instance, any code in the body of the record definition is executed. For example: - @verbatim int Tcount=0; struct T { @@ -4003,7 +4016,6 @@ initialized to a new instance (@code{new T}) by default. During the definition of the structure, however, variables of type @code{T} are initialized to @code{null} by default. This special behaviour is to avoid infinite recursion of creating new instances in code such as - @verbatim struct tree { int value; @@ -4013,7 +4025,6 @@ struct tree { @end verbatim Here is a simple example that illustrates the use of structures: - @verbatim struct S { real a=1; @@ -4038,7 +4049,6 @@ write((s+s).f(0)); // Outputs 2 @cindex constructors It is often convenient to have functions that construct new instances of a structure. Say we have a @code{Person} structure: - @verbatim struct Person { string firstname; @@ -4056,7 +4066,6 @@ creating a new person in real life, though). We can reduce the work by defining a constructor function @code{Person(string,string)}: - @verbatim struct Person { string firstname; @@ -4076,7 +4085,6 @@ Person joe=Person.Person("Joe", "Jones"); While it is now easier than before to create a new instance, we still have to refer to the constructor by the qualified name @code{Person.Person}. If we add the line - @verbatim from Person unravel Person; @end verbatim @@ -4109,7 +4117,6 @@ static Foo Foo(@var{args}) @{ This constructor is also implicitly copied to the enclosing scope after the end of the structure definition, so that it can used subsequently without qualifying it by the structure name. Our @code{Person} example can thus be implemented as: - @verbatim struct Person { string firstname; @@ -5116,11 +5123,10 @@ If @code{n} is negative, search backwards from the end of the array for the @cindex @code{search} @item int search(T[] a, T key) For built-in ordered types @code{T}, searches a sorted ordered array -@code{a} of @code{n} elements to find an interval containing -@code{key}, returning @code{-1} if @code{key} is less than the first -element, @code{n-1} if @code{key} is greater than or equal to the last -element, and otherwise the index corresponding to the left-hand -(smaller) endpoint. +@code{a} of @code{n} elements for k, returning the index @code{i} +if @code{a[i] <= key < a[i+1]}, @code{-1} if @code{key} is +less than all elements of @code{a}, or @code{n-1} if @code{key} is +greater than or equal to the last element of @code{a}. @cindex @code{copy} @item T[] copy(T[] a) @@ -5435,7 +5441,6 @@ Asymptote allows a section of an array to be addressed as a slice using a Python-like syntax. If @code{A} is an array, the expression @code{A[m:n]} returns a new array consisting of the elements of @code{A} with indices from @code{m} up to but not including @code{n}. For example, - @verbatim int[] x={0,1,2,3,4,5,6,7,8,9}; int[] y=x[2:6]; // y={2,3,4,5}; @@ -5446,7 +5451,6 @@ If the left index is omitted, it is taken be @code{0}. If the right index is omitted it is taken to be the length of the array. If both are omitted, the slice then goes from the start of the array to the end, producing a non-cyclic deep copy of the array. For example: - @verbatim int[] x={0,1,2,3,4,5,6,7,8,9}; int[] y=x[:4]; // y={0,1,2,3} @@ -5483,7 +5487,6 @@ Slices can also be assigned to, changing the value of the original array. If the array being assigned to the slice has a different length than the slice itself, elements will be inserted or removed from the array to accommodate it. For instance: - @verbatim string[] toppings={"mayo", "salt", "ham", "lettuce"}; toppings[0:2]=new string[] {"mustard", "pepper"}; @@ -5536,7 +5539,6 @@ trying to match function calls with possible function signatures. Implicit casting can be inhibited by declaring individual arguments @code{explicit} in the function signature, say to avoid an ambiguous function call in the following example, which outputs 0: - @verbatim int f(pair a) {return 0;} int f(explicit real x) {return 1;} @@ -5621,7 +5623,6 @@ adds the @code{axes} field of @code{graph} into the local name space, so that subsequently, one can just write @code{axes()}. If the given name is overloaded, all types and variables of that name are added. To add more than one name, just use a comma-separated list: - @verbatim from graph access axes, xaxis, yaxis; @end verbatim @@ -5636,7 +5637,6 @@ from graph access *; @cindex @code{unravel} Similarly, one can add the non-private fields and types of a structure to the local environment with the @code{unravel} keyword: - @verbatim struct matrix { real a,b,c,d; @@ -5685,7 +5685,6 @@ have the same name as local functions defined later. @cindex @code{as} To rename modules or fields when adding them to the local environment, use @code{as}: - @verbatim access graph as graph2d; from graph access xaxis as xline, yaxis as yline; @@ -5863,7 +5862,6 @@ is an ugly implementation of exponentiation. Loop constructs allocate a new frame in every iteration. This is so that higher-order functions can refer to variables of a specific iteration of a loop: - @verbatim void f(); for(int i=0; i < 10; ++i) { @@ -5879,7 +5877,6 @@ Here, every iteration of the loop has its own variable @code{x}, so @code{f()} will write @code{5}. If a variable in a loop is declared static, it will be allocated where the enclosing function or structure was defined (just as if it were declared static outside of the loop). For instance, in: - @verbatim void f() { static int x; @@ -5943,7 +5940,6 @@ latex latexusage @noindent or - @verbatim pdflatex latexusage asy latexusage @@ -6146,6 +6142,18 @@ returns, if @code{strict=false}, whether @code{i > j} implies @code{a[i] >= a[j]}, or if @code{strict=true}, whether @code{i > j} implies implies @code{a[i] > a[j]}. +@cindex @code{unique} +@item int unique(real[] a, real x) +if the sorted array @code{a} does not contain @code{x}, insert it +sequentially, returning the index of @code{x} in the resulting array. + +@cindex @code{lexorder} +@item bool lexorder(pair a, pair b) +returns the lexicographical partial order of @code{a} and @code{b}. + +@cindex @code{lexorder} +@item bool lexorder(triple a, triple b) +returns the lexicographical partial order of @code{a} and @code{b}. @end table @node interpolate @@ -7519,6 +7527,8 @@ path path(path3 p, pair P(triple)=xypart); @end verbatim @cindex @code{surface} +@cindex @code{render} +@cindex @code{defaultrender} A Bezier surface, the natural two-dimensional generalization of Bezier curves, is defined in @code{three_surface.asy} as a structure containing an array of Bezier patches. Surfaces may drawn with one of @@ -7526,13 +7536,17 @@ the routines @verbatim void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material surfacepen=currentpen, pen meshpen=nullpen, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen meshpen, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen[] meshpen=nullpens, - light light=currentlight, light meshlight=light, string name=""); + light light=currentlight, light meshlight=light, string name="", + render render=defaultrender); + @end verbatim The parameters @code{nu} and @code{nv} specify the number of subdivisions for drawing optional mesh lines for each Bezier patch. The optional @@ -7544,7 +7558,6 @@ struct material { pen[] p; // diffusepen,ambientpen,emissivepen,specularpen real opacity; real shininess; - real granularity; ... } @end verbatim @@ -7552,7 +7565,9 @@ struct material { These material properties are used to implement @code{OpenGL}-style lighting, based on the Phong-Blinn specular model. Sample Bezier surfaces are contained in the example files @code{BezierSurface.asy}, @code{teapot.asy}, -and @code{parametricsurface.asy}. +and @code{parametricsurface.asy}. The structure @code{render} contains +specialized rendering options documented at the beginning of module +@code{three.asy}. @cindex patch-dependent colors @cindex vertex-dependent colors @@ -7609,7 +7624,7 @@ Arbitrary thick three-dimensional curves and line caps (which the @code{OpenGL} standard does not require implementations to provide) are constructed with @verbatim -tube tube(path3 p, real width, real granularity=tubegranularity); +tube tube(path3 p, real width, render render=defaultrender); @end verbatim @noindent this returns a tube structure representing a tube of diameter @code{width} @@ -8054,8 +8069,8 @@ When not multiplied on the left by a transform3, three-dimensional @verbatim void label(picture pic=currentpicture, Label L, triple position, align align=NoAlign, pen p=currentpen, - light light=nolight, string name=L.s, - interaction interaction= + light light=nolight, string name="", + render render=defaultrender, interaction interaction= settings.autobillboard ? Billboard : Embedded) @end verbatim @noindent @@ -8064,7 +8079,7 @@ void label(picture pic=currentpicture, Label L, triple position, The optional @code{name} parameter is used as a prefix for naming the label patches in the @acronym{PRC} model tree. The default interaction is @code{Billboard}, which means that labels -are rotated interactively so that they always lie on the projection plane. +are rotated interactively so that they always face the camera. The interaction @code{Embedded} means that the label interacts as a normal @code{3D} surface, as illustrated in the example @code{billboard.asy}. @cindex @code{transform} @@ -9137,11 +9152,11 @@ this requires @code{Python 2.6.2} and the @code{Python Imaging Library}: @url{http://www.python.org/ftp/python/2.6.2/python-2.6.2.msi} @end quotation @quotation -@url{http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.6.exe}. +@url{http://effbot.org/downloads/PIL-1.1.7.win32-py2.6.exe}. @end quotation @noindent On @code{UNIX} systems, place -@url{http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz} in the +@url{http://effbot.org/downloads/Imaging-1.1.7.tar.gz} in the @code{Asymptote} source directory, and type (as the root user): @verbatim tar -zxf Imaging-1.1.7.tar.gz @@ -9525,8 +9540,9 @@ Melenchuk, Martin Wiebusch, and Stefan Knorr. @c LocalWords: usplinetype vsplinetype leftbutton middlebutton rightbutton @c LocalWords: rotateY rotateZ wheelup zoomin wheeldown zoomout TeXLive @c LocalWords: viewportshift signedint signedness psview multiplatform nowarn -@c LocalWords: singlereal singleint writeoverloaded tubegranularity dvisvg +@c LocalWords: singlereal singleint writeoverloaded dvisvg reddash lexorder @c LocalWords: bigdiagonal autobillboard dvisvgm maxtiles hyperrefOptions @c LocalWords: setpagesize pdfborder controlsystem OmitTickInterval SixViews @c LocalWords: OmitTickIntervals tickmodifiers autorotated SixViewsUS @c LocalWords: ThreeViewsUS ThreeViewsFR SixViewsFR ThreeViews partialsum +@c LocalWords: defaultrender |