diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-07 18:19:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-07 18:19:31 +0000 |
commit | 752012c605d34cd943795527a9738475a6958fcc (patch) | |
tree | 4ee06acdd8333a662c2d6f6ef716235053468f55 /Master/texmf-dist/asymptote/plain_constants.asy | |
parent | 9789d09132f18a838e84f041b4b3aff28d3426ec (diff) |
texmf -> texmf-dist: start with unique dirs from texmf
git-svn-id: svn://tug.org/texlive/trunk@29712 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/plain_constants.asy')
-rw-r--r-- | Master/texmf-dist/asymptote/plain_constants.asy | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/Master/texmf-dist/asymptote/plain_constants.asy b/Master/texmf-dist/asymptote/plain_constants.asy new file mode 100644 index 00000000000..bf6988d4c42 --- /dev/null +++ b/Master/texmf-dist/asymptote/plain_constants.asy @@ -0,0 +1,166 @@ +restricted int undefined=(intMax % 2 == 1) ? intMax : intMax-1; + +restricted real inches=72; +restricted real inch=inches; +restricted real cm=inches/2.54; +restricted real mm=0.1cm; +restricted real bp=1; // A PostScript point. +restricted real pt=72.0/72.27; // A TeX pt; smaller than a PostScript bp. +restricted pair I=(0,1); + +restricted pair right=(1,0); +restricted pair left=(-1,0); +restricted pair up=(0,1); +restricted pair down=(0,-1); + +restricted pair E=(1,0); +restricted pair N=(0,1); +restricted pair W=(-1,0); +restricted pair S=(0,-1); + +restricted pair NE=unit(N+E); +restricted pair NW=unit(N+W); +restricted pair SW=unit(S+W); +restricted pair SE=unit(S+E); + +restricted pair ENE=unit(E+NE); +restricted pair NNE=unit(N+NE); +restricted pair NNW=unit(N+NW); +restricted pair WNW=unit(W+NW); +restricted pair WSW=unit(W+SW); +restricted pair SSW=unit(S+SW); +restricted pair SSE=unit(S+SE); +restricted pair ESE=unit(E+SE); + +restricted real sqrtEpsilon=sqrt(realEpsilon); +restricted pair Align=sqrtEpsilon*NE; +restricted int mantissaBits=ceil(-log(realEpsilon)/log(2))+1; + +int min(... int[] a) {return min(a);} +int max(... int[] a) {return max(a);} + +real min(... real[] a) {return min(a);} +real max(... real[] a) {return max(a);} + +bool finite(real x) +{ + return abs(x) < infinity; +} + +bool finite(pair z) +{ + return abs(z.x) < infinity && abs(z.y) < infinity; +} + +bool finite(triple v) +{ + return abs(v.x) < infinity && abs(v.y) < infinity && abs(v.z) < infinity; +} + +restricted file stdin=input(); +restricted file stdout=output(); + +void none(file file) {} +void endl(file file) {write(file,'\n',flush);} +void newl(file file) {write(file,'\n');} +void DOSendl(file file) {write(file,'\r\n',flush);} +void DOSnewl(file file) {write(file,'\r\n');} +void tab(file file) {write(file,'\t');} +void comma(file file) {write(file,',');} +typedef void suffix(file); + +// Used by interactive write to warn that the outputted type is the resolution +// of an overloaded name. +void overloadedMessage(file file) { + write(file,' <overloaded>'); + endl(file); +} + +void write(suffix suffix=endl) {suffix(stdout);} +void write(file file, suffix suffix=none) {suffix(file);} + +path box(pair a, pair b) +{ + return a--(b.x,a.y)--b--(a.x,b.y)--cycle; +} + +restricted path unitsquare=box((0,0),(1,1)); + +restricted path unitcircle=E..N..W..S..cycle; +restricted real circleprecision=0.0006; + +restricted transform invert=reflect((0,0),(1,0)); + +restricted pen defaultpen; + +// A type that takes on one of the values true, false, or default. +struct bool3 { + bool value; + bool set; +} + +void write(file file, string s="", bool3 b, suffix suffix=none) +{ + if(b.set) write(b.value,suffix); + else write("default",suffix); +} + +void write(string s="", bool3 b, suffix suffix=endl) +{ + write(stdout,s,b,suffix); +} + +restricted bool3 default; + +bool operator cast(bool3 b) +{ + return b.set && b.value; +} + +bool3 operator cast(bool b) +{ + bool3 B; + B.value=b; + B.set=true; + return B; +} + +bool operator == (bool3 a, bool3 b) +{ + return a.set == b.set && (!a.set || (a.value == b.value)); +} + +bool operator != (bool3 a, bool3 b) +{ + return a.set != b.set || (a.set && (a.value != b.value)); +} + +bool operator == (bool3 a, bool b) +{ + return a.set && a.value == b; +} + +bool operator != (bool3 a, bool b) +{ + return !a.set || a.value != b; +} + +bool operator == (bool a, bool3 b) +{ + return b.set && b.value == a; +} + +bool operator != (bool a, bool3 b) +{ + return !b.set || b.value != a; +} + +bool[] operator cast(bool3[] b) +{ + return sequence(new bool(int i) {return b[i];},b.length); +} + +bool3[] operator cast(bool[] b) +{ + return sequence(new bool3(int i) {return b[i];},b.length); +} |