diff options
author | Norbert Preining <preining@logic.at> | 2018-06-15 16:03:13 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2018-06-15 16:03:13 +0000 |
commit | 6c74bdbfb4caa51514bdea1edd36bc71532a16b0 (patch) | |
tree | 74f65d377efe78179a53322abefcbd6fea9c0876 /Master/texmf-dist/doc/support/ketcindy/ketmanual | |
parent | 355b4e5dc0f07541a7603df5f55f71a695efac0e (diff) |
ketcindy 20180615.1
git-svn-id: svn://tug.org/texlive/trunk@48019 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/support/ketcindy/ketmanual')
3 files changed, 0 insertions, 7321 deletions
diff --git a/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/Cindy.js b/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/Cindy.js deleted file mode 100644 index 04aa2fd9134..00000000000 --- a/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/Cindy.js +++ /dev/null @@ -1,781 +0,0 @@ -/* CindyJS - (C) 2014-2016 The CindyJS Project - * Mostly licensed under the Apache License 2.0, but subprojects may use different licensing. - * See https://github.com/CindyJS/CindyJS/tree/bb244cab7fdc8d4ea030751ec40c6d384c09f464 - * for corresponding sources and their respective licensing conditions. - */ -var enableInlineVideo=function(){function p(f,k,p,F){function E(p){ea=k(E,F);f(p-(K||p));K=p}var ea,K;return{start:function(){ea||E(0)},stop:function(){p(ea);ea=null;K=0}}}function E(f,k,p,F){function E(k){!!f[p]===!!F&&k.stopImmediatePropagation();delete f[p]}return f.addEventListener(k,E,!1),E}function ja(f,k,p,F){function E(f){p[k]=f}F&&E(f[k]);Object.defineProperty(f,k,{get:function(){return p[k]},set:E})}function Ca(f,k,p){p.addEventListener(k,function(){return f.dispatchEvent(new Event(k))})} -function pa(f,k){Promise.resolve().then(function(){f.dispatchEvent(new Event(k))})}function Da(f){var k=new Audio;return Ca(f,"play",k),Ca(f,"playing",k),Ca(f,"pause",k),k.crossOrigin=f.crossOrigin,k.src=f.src||f.currentSrc||"data:",k}function aa(k,p,F){(K||0)+200<Date.now()&&(k[Ea]=!0,K=Date.now());F||(k.currentTime=p);f[++nb%3]=100*p|0}function k(f){this.video.readyState>=this.video.HAVE_FUTURE_DATA?(this.hasAudio||(this.driver.currentTime=this.video.currentTime+f*this.video.playbackRate/1E3,this.video.loop&& -this.driver.currentTime>=this.video.duration&&(this.driver.currentTime=0)),aa(this.video,this.driver.currentTime)):this.video.networkState===this.video.NETWORK_IDLE&&0===this.video.buffered.length&&this.video.load();this.video.ended&&(delete this.video[Ea],this.video.pause(!0))}function Oa(){var f=this[W];return this.webkitDisplayingFullscreen?void this[ob]():("data:"!==f.driver.src&&f.driver.src!==this.src&&(aa(this,0,!0),f.driver.src=this.src),void(this.paused&&(f.paused=!1,0===this.buffered.length&& -this.load(),f.driver.play(),f.updater.start(),f.hasAudio||(pa(this,"play"),f.video.readyState>=f.video.HAVE_ENOUGH_DATA&&pa(this,"playing")))))}function F(f){var k=this[W];k.driver.pause();k.updater.stop();this.webkitDisplayingFullscreen&&this[sa]();k.paused&&!f||(k.paused=!0,k.hasAudio||pa(this,"pause"),this.ended&&(this[Ea]=!0,pa(this,"ended")))}function ea(F,E){var I=F[W]={};I.paused=!0;I.hasAudio=E;I.video=F;I.updater=p(k.bind(I),requestAnimationFrame,cancelAnimationFrame);E?I.driver=Da(F):(F.addEventListener("canplay", -function(){F.paused||pa(F,"playing")}),I.driver={src:F.src||F.currentSrc||"data:",muted:!0,paused:!0,pause:function(){I.driver.paused=!0},play:function(){I.driver.paused=!1;I.driver.currentTime>=I.video.duration&&aa(F,0)},get ended(){return I.driver.currentTime>=I.video.duration}});F.addEventListener("emptied",function(){var f=!I.driver.src||"data:"===I.driver.src;I.driver.src&&I.driver.src!==F.src&&(aa(F,0,!0),I.driver.src=F.src,f?I.driver.play():I.updater.stop())},!1);F.addEventListener("webkitbeginfullscreen", -function(){F.paused?E&&0===I.driver.buffered.length&&I.driver.load():(F.pause(),F[ob]())});E&&(F.addEventListener("webkitendfullscreen",function(){I.driver.currentTime=F.currentTime}),F.addEventListener("seeking",function(){0>f.indexOf(100*F.currentTime|0)&&(I.driver.currentTime=F.currentTime)}))}var K,U="object"==typeof document&&"object-fit"in document.head.style&&!matchMedia("(-webkit-video-playable-inline)").matches,W="bfred-it:iphone-inline-video",Ea="bfred-it:iphone-inline-video:event",ob="bfred-it:iphone-inline-video:nativeplay", -sa="bfred-it:iphone-inline-video:nativepause",f=[],nb=0;return function(f,k){if(void 0===k&&(k={}),!f[W])if(k.everywhere||U&&(k.iPad||k.ipad?/iPhone|iPod|iPad/:/iPhone|iPod/).test(navigator.userAgent)){!f.paused&&f.webkitDisplayingFullscreen&&f.pause();ea(f,!f.muted);var p=f[W];f[ob]=f.play;f[sa]=f.pause;f.play=Oa;f.pause=F;ja(f,"paused",p.driver);ja(f,"muted",p.driver,!0);ja(f,"playbackRate",p.driver,!0);ja(f,"ended",p.driver);ja(f,"loop",p.driver,!0);E(f,"seeking");E(f,"seeked");E(f,"timeupdate", -Ea,!1);E(f,"ended",Ea,!1);f.classList.add("IIV");f.muted&&f.autoplay&&f.play();/iPhone|iPod|iPad/.test(navigator.platform)||console.warn("iphone-inline-video is not guaranteed to work in emulated environments")}}}(); -(function(){function p(b,d,e){f.biginteger_used=1;null!=b&&("number"==typeof b&&"undefined"==typeof d?this.fromInt(b):"number"==typeof b?this.fromNumber(b,d,e):null==d&&"string"!=typeof b?this.fromString(b,256):this.fromString(b,d))}function E(){return new p(null,void 0,void 0)}function ja(b,d,e,q,f,k){for(;0<=--k;){var v=d*this[b++]+e[q]+f;f=Math.floor(v/67108864);e[q++]=v&67108863}return f}function Ca(b,d,e,q,f,k){var v=d&32767;for(d>>=15;0<=--k;){var C=this[b]&32767,p=this[b++]>>15,F=d*C+p*v,C= -v*C+((F&32767)<<15)+e[q]+(f&1073741823);f=(C>>>30)+(F>>>15)+d*p+(f>>>30);e[q++]=C&1073741823}return f}function pa(b,d,e,q,f,k){var v=d&16383;for(d>>=14;0<=--k;){var C=this[b]&16383,p=this[b++]>>14,F=d*C+p*v,C=v*C+((F&16383)<<14)+e[q]+f;f=(C>>28)+(F>>14)+d*p;e[q++]=C&268435455}return f}function Da(b,d){var e=cb[b.charCodeAt(d)];return null==e?-1:e}function aa(b){var d=E();d.fromInt(b);return d}function k(b){var d=1,e;0!=(e=b>>>16)&&(b=e,d+=16);0!=(e=b>>8)&&(b=e,d+=8);0!=(e=b>>4)&&(b=e,d+=4);0!=(e= -b>>2)&&(b=e,d+=2);0!=b>>1&&(d+=1);return d}function Oa(b){this.m=b}function F(b){this.m=b;this.mp=b.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<b.DB-15)-1;this.mt2=2*b.t}function ea(b,d){return b&d}function K(b,d){return b|d}function U(b,d){return b^d}function W(b,d){return b&~d}function Ea(){}function ob(b){return b}function sa(b){this.r2=E();this.q3=E();p.ONE.dlShiftTo(2*b.t,this.r2);this.mu=this.r2.divide(b);this.m=b}var f={use_lines:!0,use_xyz:!1},nb=!1;"undefined"!==typeof module&& -module.exports?(module.exports=f,nb=!0):"undefined"!==typeof document?window.ClipperLib=f:self.ClipperLib=f;var V;if(nb)Y="chrome",V="Netscape";else{var Y=navigator.userAgent.toString().toLowerCase();V=navigator.appName}var I,Xb,Jb,Qa,ab,xb;I=-1!=Y.indexOf("chrome")&&-1==Y.indexOf("chromium")?1:0;nb=-1!=Y.indexOf("chromium")?1:0;Xb=-1!=Y.indexOf("safari")&&-1==Y.indexOf("chrome")&&-1==Y.indexOf("chromium")?1:0;Jb=-1!=Y.indexOf("firefox")?1:0;Y.indexOf("firefox/17");Y.indexOf("firefox/15");Y.indexOf("firefox/3"); -Qa=-1!=Y.indexOf("opera")?1:0;Y.indexOf("msie 10");Y.indexOf("msie 9");ab=-1!=Y.indexOf("msie 8")?1:0;xb=-1!=Y.indexOf("msie 7")?1:0;Y=-1!=Y.indexOf("msie ")?1:0;f.biginteger_used=null;"Microsoft Internet Explorer"==V?(p.prototype.am=Ca,V=30):"Netscape"!=V?(p.prototype.am=ja,V=26):(p.prototype.am=pa,V=28);p.prototype.DB=V;p.prototype.DM=(1<<V)-1;p.prototype.DV=1<<V;p.prototype.FV=Math.pow(2,52);p.prototype.F1=52-V;p.prototype.F2=2*V-52;var cb=[],qa;V=48;for(qa=0;9>=qa;++qa)cb[V++]=qa;V=97;for(qa= -10;36>qa;++qa)cb[V++]=qa;V=65;for(qa=10;36>qa;++qa)cb[V++]=qa;Oa.prototype.convert=function(b){return 0>b.s||0<=b.compareTo(this.m)?b.mod(this.m):b};Oa.prototype.revert=function(b){return b};Oa.prototype.reduce=function(b){b.divRemTo(this.m,null,b)};Oa.prototype.mulTo=function(b,d,e){b.multiplyTo(d,e);this.reduce(e)};Oa.prototype.sqrTo=function(b,d){b.squareTo(d);this.reduce(d)};F.prototype.convert=function(b){var d=E();b.abs().dlShiftTo(this.m.t,d);d.divRemTo(this.m,null,d);0>b.s&&0<d.compareTo(p.ZERO)&& -this.m.subTo(d,d);return d};F.prototype.revert=function(b){var d=E();b.copyTo(d);this.reduce(d);return d};F.prototype.reduce=function(b){for(;b.t<=this.mt2;)b[b.t++]=0;for(var d=0;d<this.m.t;++d){var e=b[d]&32767,q=e*this.mpl+((e*this.mph+(b[d]>>15)*this.mpl&this.um)<<15)&b.DM,e=d+this.m.t;for(b[e]+=this.m.am(0,q,b,d,0,this.m.t);b[e]>=b.DV;)b[e]-=b.DV,b[++e]++}b.clamp();b.drShiftTo(this.m.t,b);0<=b.compareTo(this.m)&&b.subTo(this.m,b)};F.prototype.mulTo=function(b,d,e){b.multiplyTo(d,e);this.reduce(e)}; -F.prototype.sqrTo=function(b,d){b.squareTo(d);this.reduce(d)};p.prototype.copyTo=function(b){for(var d=this.t-1;0<=d;--d)b[d]=this[d];b.t=this.t;b.s=this.s};p.prototype.fromInt=function(b){this.t=1;this.s=0>b?-1:0;0<b?this[0]=b:-1>b?this[0]=b+this.DV:this.t=0};p.prototype.fromString=function(b,d){var e;if(16==d)e=4;else if(8==d)e=3;else if(256==d)e=8;else if(2==d)e=1;else if(32==d)e=5;else if(4==d)e=2;else{this.fromRadix(b,d);return}this.s=this.t=0;for(var q=b.length,f=!1,k=0;0<=--q;){var v=8==e? -b[q]&255:Da(b,q);0>v?"-"==b.charAt(q)&&(f=!0):(f=!1,0==k?this[this.t++]=v:k+e>this.DB?(this[this.t-1]|=(v&(1<<this.DB-k)-1)<<k,this[this.t++]=v>>this.DB-k):this[this.t-1]|=v<<k,k+=e,k>=this.DB&&(k-=this.DB))}8==e&&0!=(b[0]&128)&&(this.s=-1,0<k&&(this[this.t-1]|=(1<<this.DB-k)-1<<k));this.clamp();f&&p.ZERO.subTo(this,this)};p.prototype.clamp=function(){for(var b=this.s&this.DM;0<this.t&&this[this.t-1]==b;)--this.t};p.prototype.dlShiftTo=function(b,d){var e;for(e=this.t-1;0<=e;--e)d[e+b]=this[e];for(e= -b-1;0<=e;--e)d[e]=0;d.t=this.t+b;d.s=this.s};p.prototype.drShiftTo=function(b,d){for(var e=b;e<this.t;++e)d[e-b]=this[e];d.t=Math.max(this.t-b,0);d.s=this.s};p.prototype.lShiftTo=function(b,d){var e=b%this.DB,q=this.DB-e,f=(1<<q)-1,k=Math.floor(b/this.DB),v=this.s<<e&this.DM,C;for(C=this.t-1;0<=C;--C)d[C+k+1]=this[C]>>q|v,v=(this[C]&f)<<e;for(C=k-1;0<=C;--C)d[C]=0;d[k]=v;d.t=this.t+k+1;d.s=this.s;d.clamp()};p.prototype.rShiftTo=function(b,d){d.s=this.s;var e=Math.floor(b/this.DB);if(e>=this.t)d.t= -0;else{var q=b%this.DB,f=this.DB-q,k=(1<<q)-1;d[0]=this[e]>>q;for(var v=e+1;v<this.t;++v)d[v-e-1]|=(this[v]&k)<<f,d[v-e]=this[v]>>q;0<q&&(d[this.t-e-1]|=(this.s&k)<<f);d.t=this.t-e;d.clamp()}};p.prototype.subTo=function(b,d){for(var e=0,f=0,n=Math.min(b.t,this.t);e<n;)f+=this[e]-b[e],d[e++]=f&this.DM,f>>=this.DB;if(b.t<this.t){for(f-=b.s;e<this.t;)f+=this[e],d[e++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;e<b.t;)f-=b[e],d[e++]=f&this.DM,f>>=this.DB;f-=b.s}d.s=0>f?-1:0;-1>f?d[e++]=this.DV+ -f:0<f&&(d[e++]=f);d.t=e;d.clamp()};p.prototype.multiplyTo=function(b,d){var e=this.abs(),f=b.abs(),n=e.t;for(d.t=n+f.t;0<=--n;)d[n]=0;for(n=0;n<f.t;++n)d[n+e.t]=e.am(0,f[n],d,n,0,e.t);d.s=0;d.clamp();this.s!=b.s&&p.ZERO.subTo(d,d)};p.prototype.squareTo=function(b){for(var d=this.abs(),e=b.t=2*d.t;0<=--e;)b[e]=0;for(e=0;e<d.t-1;++e){var f=d.am(e,d[e],b,2*e,0,1);(b[e+d.t]+=d.am(e+1,2*d[e],b,2*e+1,f,d.t-e-1))>=d.DV&&(b[e+d.t]-=d.DV,b[e+d.t+1]=1)}0<b.t&&(b[b.t-1]+=d.am(e,d[e],b,2*e,0,1));b.s=0;b.clamp()}; -p.prototype.divRemTo=function(b,d,e){var f=b.abs();if(!(0>=f.t)){var n=this.abs();if(n.t<f.t)null!=d&&d.fromInt(0),null!=e&&this.copyTo(e);else{null==e&&(e=E());var N=E(),v=this.s;b=b.s;var C=this.DB-k(f[f.t-1]);0<C?(f.lShiftTo(C,N),n.lShiftTo(C,e)):(f.copyTo(N),n.copyTo(e));f=N.t;n=N[f-1];if(0!=n){var F=n*(1<<this.F1)+(1<f?N[f-2]>>this.F2:0),bb=this.FV/F,F=(1<<this.F1)/F,pb=1<<this.F2,H=e.t,ea=H-f,K=null==d?E():d;N.dlShiftTo(ea,K);0<=e.compareTo(K)&&(e[e.t++]=1,e.subTo(K,e));p.ONE.dlShiftTo(f,K); -for(K.subTo(N,N);N.t<f;)N[N.t++]=0;for(;0<=--ea;){var I=e[--H]==n?this.DM:Math.floor(e[H]*bb+(e[H-1]+pb)*F);if((e[H]+=N.am(0,I,e,ea,0,f))<I)for(N.dlShiftTo(ea,K),e.subTo(K,e);e[H]<--I;)e.subTo(K,e)}null!=d&&(e.drShiftTo(f,d),v!=b&&p.ZERO.subTo(d,d));e.t=f;e.clamp();0<C&&e.rShiftTo(C,e);0>v&&p.ZERO.subTo(e,e)}}}};p.prototype.invDigit=function(){if(1>this.t)return 0;var b=this[0];if(0==(b&1))return 0;var d=b&3,d=d*(2-(b&15)*d)&15,d=d*(2-(b&255)*d)&255,d=d*(2-((b&65535)*d&65535))&65535,d=d*(2-b*d%this.DV)% -this.DV;return 0<d?this.DV-d:-d};p.prototype.isEven=function(){return 0==(0<this.t?this[0]&1:this.s)};p.prototype.exp=function(b,d){if(4294967295<b||1>b)return p.ONE;var e=E(),f=E(),n=d.convert(this),N=k(b)-1;for(n.copyTo(e);0<=--N;)if(d.sqrTo(e,f),0<(b&1<<N))d.mulTo(f,n,e);else var v=e,e=f,f=v;return d.revert(e)};p.prototype.toString=function(b){if(0>this.s)return"-"+this.negate().toString(b);if(16==b)b=4;else if(8==b)b=3;else if(2==b)b=1;else if(32==b)b=5;else if(4==b)b=2;else return this.toRadix(b); -var d=(1<<b)-1,e,f=!1,n="",k=this.t,v=this.DB-k*this.DB%b;if(0<k--)for(v<this.DB&&0<(e=this[k]>>v)&&(f=!0,n="0123456789abcdefghijklmnopqrstuvwxyz".charAt(e));0<=k;)v<b?(e=(this[k]&(1<<v)-1)<<b-v,e|=this[--k]>>(v+=this.DB-b)):(e=this[k]>>(v-=b)&d,0>=v&&(v+=this.DB,--k)),0<e&&(f=!0),f&&(n+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(e));return f?n:"0"};p.prototype.negate=function(){var b=E();p.ZERO.subTo(this,b);return b};p.prototype.abs=function(){return 0>this.s?this.negate():this};p.prototype.compareTo= -function(b){var d=this.s-b.s;if(0!=d)return d;var e=this.t,d=e-b.t;if(0!=d)return 0>this.s?-d:d;for(;0<=--e;)if(0!=(d=this[e]-b[e]))return d;return 0};p.prototype.bitLength=function(){return 0>=this.t?0:this.DB*(this.t-1)+k(this[this.t-1]^this.s&this.DM)};p.prototype.mod=function(b){var d=E();this.abs().divRemTo(b,null,d);0>this.s&&0<d.compareTo(p.ZERO)&&b.subTo(d,d);return d};p.prototype.modPowInt=function(b,d){var e;e=256>b||d.isEven()?new Oa(d):new F(d);return this.exp(b,e)};p.ZERO=aa(0);p.ONE= -aa(1);Ea.prototype.convert=ob;Ea.prototype.revert=ob;Ea.prototype.mulTo=function(b,d,e){b.multiplyTo(d,e)};Ea.prototype.sqrTo=function(b,d){b.squareTo(d)};sa.prototype.convert=function(b){if(0>b.s||b.t>2*this.m.t)return b.mod(this.m);if(0>b.compareTo(this.m))return b;var d=E();b.copyTo(d);this.reduce(d);return d};sa.prototype.revert=function(b){return b};sa.prototype.reduce=function(b){b.drShiftTo(this.m.t-1,this.r2);b.t>this.m.t+1&&(b.t=this.m.t+1,b.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+ -1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>b.compareTo(this.r2);)b.dAddOffset(1,this.m.t+1);for(b.subTo(this.r2,b);0<=b.compareTo(this.m);)b.subTo(this.m,b)};sa.prototype.mulTo=function(b,d,e){b.multiplyTo(d,e);this.reduce(e)};sa.prototype.sqrTo=function(b,d){b.squareTo(d);this.reduce(d)};var H=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239, -241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Zb=67108864/H[H.length-1];p.prototype.chunkSize= -function(b){return Math.floor(Math.LN2*this.DB/Math.log(b))};p.prototype.toRadix=function(b){null==b&&(b=10);if(0==this.signum()||2>b||36<b)return"0";var d=this.chunkSize(b),d=Math.pow(b,d),e=aa(d),f=E(),n=E(),k="";for(this.divRemTo(e,f,n);0<f.signum();)k=(d+n.intValue()).toString(b).substr(1)+k,f.divRemTo(e,f,n);return n.intValue().toString(b)+k};p.prototype.fromRadix=function(b,d){this.fromInt(0);null==d&&(d=10);for(var e=this.chunkSize(d),f=Math.pow(d,e),n=!1,k=0,v=0,C=0;C<b.length;++C){var F= -Da(b,C);0>F?"-"==b.charAt(C)&&0==this.signum()&&(n=!0):(v=d*v+F,++k>=e&&(this.dMultiply(f),this.dAddOffset(v,0),v=k=0))}0<k&&(this.dMultiply(Math.pow(d,k)),this.dAddOffset(v,0));n&&p.ZERO.subTo(this,this)};p.prototype.fromNumber=function(b,d,e){if("number"==typeof d)if(2>b)this.fromInt(1);else for(this.fromNumber(b,e),this.testBit(b-1)||this.bitwiseTo(p.ONE.shiftLeft(b-1),K,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(d);)this.dAddOffset(2,0),this.bitLength()>b&&this.subTo(p.ONE.shiftLeft(b- -1),this);else{e=[];var f=b&7;e.length=(b>>3)+1;d.nextBytes(e);e[0]=0<f?e[0]&(1<<f)-1:0;this.fromString(e,256)}};p.prototype.bitwiseTo=function(b,d,e){var f,n,k=Math.min(b.t,this.t);for(f=0;f<k;++f)e[f]=d(this[f],b[f]);if(b.t<this.t){n=b.s&this.DM;for(f=k;f<this.t;++f)e[f]=d(this[f],n);e.t=this.t}else{n=this.s&this.DM;for(f=k;f<b.t;++f)e[f]=d(n,b[f]);e.t=b.t}e.s=d(this.s,b.s);e.clamp()};p.prototype.changeBit=function(b,d){var e=p.ONE.shiftLeft(b);this.bitwiseTo(e,d,e);return e};p.prototype.addTo=function(b, -d){for(var e=0,f=0,n=Math.min(b.t,this.t);e<n;)f+=this[e]+b[e],d[e++]=f&this.DM,f>>=this.DB;if(b.t<this.t){for(f+=b.s;e<this.t;)f+=this[e],d[e++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;e<b.t;)f+=b[e],d[e++]=f&this.DM,f>>=this.DB;f+=b.s}d.s=0>f?-1:0;0<f?d[e++]=f:-1>f&&(d[e++]=this.DV+f);d.t=e;d.clamp()};p.prototype.dMultiply=function(b){this[this.t]=this.am(0,b-1,this,0,0,this.t);++this.t;this.clamp()};p.prototype.dAddOffset=function(b,d){if(0!=b){for(;this.t<=d;)this[this.t++]=0;for(this[d]+= -b;this[d]>=this.DV;)this[d]-=this.DV,++d>=this.t&&(this[this.t++]=0),++this[d]}};p.prototype.multiplyLowerTo=function(b,d,e){var f=Math.min(this.t+b.t,d);e.s=0;for(e.t=f;0<f;)e[--f]=0;var n;for(n=e.t-this.t;f<n;++f)e[f+this.t]=this.am(0,b[f],e,f,0,this.t);for(n=Math.min(b.t,d);f<n;++f)this.am(0,b[f],e,f,0,d-f);e.clamp()};p.prototype.multiplyUpperTo=function(b,d,e){--d;var f=e.t=this.t+b.t-d;for(e.s=0;0<=--f;)e[f]=0;for(f=Math.max(d-this.t,0);f<b.t;++f)e[this.t+f-d]=this.am(d-f,b[f],e,0,0,this.t+f- -d);e.clamp();e.drShiftTo(1,e)};p.prototype.modInt=function(b){if(0>=b)return 0;var d=this.DV%b,e=0>this.s?b-1:0;if(0<this.t)if(0==d)e=this[0]%b;else for(var f=this.t-1;0<=f;--f)e=(d*e+this[f])%b;return e};p.prototype.millerRabin=function(b){var d=this.subtract(p.ONE),e=d.getLowestSetBit();if(0>=e)return!1;var f=d.shiftRight(e);b=b+1>>1;b>H.length&&(b=H.length);for(var n=E(),k=0;k<b;++k){n.fromInt(H[Math.floor(Math.random()*H.length)]);var v=n.modPow(f,this);if(0!=v.compareTo(p.ONE)&&0!=v.compareTo(d)){for(var C= -1;C++<e&&0!=v.compareTo(d);)if(v=v.modPowInt(2,this),0==v.compareTo(p.ONE))return!1;if(0!=v.compareTo(d))return!1}}return!0};p.prototype.clone=function(){var b=E();this.copyTo(b);return b};p.prototype.intValue=function(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]};p.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24};p.prototype.shortValue=function(){return 0== -this.t?this.s:this[0]<<16>>16};p.prototype.signum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1};p.prototype.toByteArray=function(){var b=this.t,d=[];d[0]=this.s;var e=this.DB-b*this.DB%8,f,n=0;if(0<b--)for(e<this.DB&&(f=this[b]>>e)!=(this.s&this.DM)>>e&&(d[n++]=f|this.s<<this.DB-e);0<=b;)if(8>e?(f=(this[b]&(1<<e)-1)<<8-e,f|=this[--b]>>(e+=this.DB-8)):(f=this[b]>>(e-=8)&255,0>=e&&(e+=this.DB,--b)),0!=(f&128)&&(f|=-256),0==n&&(this.s&128)!=(f&128)&&++n,0<n||f!=this.s)d[n++]=f; -return d};p.prototype.equals=function(b){return 0==this.compareTo(b)};p.prototype.min=function(b){return 0>this.compareTo(b)?this:b};p.prototype.max=function(b){return 0<this.compareTo(b)?this:b};p.prototype.and=function(b){var d=E();this.bitwiseTo(b,ea,d);return d};p.prototype.or=function(b){var d=E();this.bitwiseTo(b,K,d);return d};p.prototype.xor=function(b){var d=E();this.bitwiseTo(b,U,d);return d};p.prototype.andNot=function(b){var d=E();this.bitwiseTo(b,W,d);return d};p.prototype.not=function(){for(var b= -E(),d=0;d<this.t;++d)b[d]=this.DM&~this[d];b.t=this.t;b.s=~this.s;return b};p.prototype.shiftLeft=function(b){var d=E();0>b?this.rShiftTo(-b,d):this.lShiftTo(b,d);return d};p.prototype.shiftRight=function(b){var d=E();0>b?this.lShiftTo(-b,d):this.rShiftTo(b,d);return d};p.prototype.getLowestSetBit=function(){for(var b=0;b<this.t;++b)if(0!=this[b]){var d=b*this.DB,b=this[b];if(0==b)b=-1;else{var e=0;0==(b&65535)&&(b>>=16,e+=16);0==(b&255)&&(b>>=8,e+=8);0==(b&15)&&(b>>=4,e+=4);0==(b&3)&&(b>>=2,e+=2); -0==(b&1)&&++e;b=e}return d+b}return 0>this.s?this.t*this.DB:-1};p.prototype.bitCount=function(){for(var b=0,d=this.s&this.DM,e=0;e<this.t;++e){for(var f=this[e]^d,n=0;0!=f;)f&=f-1,++n;b+=n}return b};p.prototype.testBit=function(b){var d=Math.floor(b/this.DB);return d>=this.t?0!=this.s:0!=(this[d]&1<<b%this.DB)};p.prototype.setBit=function(b){return this.changeBit(b,K)};p.prototype.clearBit=function(b){return this.changeBit(b,W)};p.prototype.flipBit=function(b){return this.changeBit(b,U)};p.prototype.add= -function(b){var d=E();this.addTo(b,d);return d};p.prototype.subtract=function(b){var d=E();this.subTo(b,d);return d};p.prototype.multiply=function(b){var d=E();this.multiplyTo(b,d);return d};p.prototype.divide=function(b){var d=E();this.divRemTo(b,d,null);return d};p.prototype.remainder=function(b){var d=E();this.divRemTo(b,null,d);return d};p.prototype.divideAndRemainder=function(b){var d=E(),e=E();this.divRemTo(b,d,e);return[d,e]};p.prototype.modPow=function(b,d){var e=b.bitLength(),f,n=aa(1),N; -if(0>=e)return n;f=18>e?1:48>e?3:144>e?4:768>e?5:6;N=8>e?new Oa(d):d.isEven()?new sa(d):new F(d);var v=[],C=3,p=f-1,bb=(1<<f)-1;v[1]=N.convert(this);if(1<f)for(e=E(),N.sqrTo(v[1],e);C<=bb;)v[C]=E(),N.mulTo(e,v[C-2],v[C]),C+=2;for(var H=b.t-1,K,ea=!0,I=E(),e=k(b[H])-1;0<=H;){e>=p?K=b[H]>>e-p&bb:(K=(b[H]&(1<<e+1)-1)<<p-e,0<H&&(K|=b[H-1]>>this.DB+e-p));for(C=f;0==(K&1);)K>>=1,--C;0>(e-=C)&&(e+=this.DB,--H);if(ea)v[K].copyTo(n),ea=!1;else{for(;1<C;)N.sqrTo(n,I),N.sqrTo(I,n),C-=2;0<C?N.sqrTo(n,I):(C=n, -n=I,I=C);N.mulTo(I,v[K],n)}for(;0<=H&&0==(b[H]&1<<e);)N.sqrTo(n,I),C=n,n=I,I=C,0>--e&&(e=this.DB-1,--H)}return N.revert(n)};p.prototype.modInverse=function(b){var d=b.isEven();if(this.isEven()&&d||0==b.signum())return p.ZERO;for(var e=b.clone(),f=this.clone(),n=aa(1),k=aa(0),v=aa(0),C=aa(1);0!=e.signum();){for(;e.isEven();)e.rShiftTo(1,e),d?(n.isEven()&&k.isEven()||(n.addTo(this,n),k.subTo(b,k)),n.rShiftTo(1,n)):k.isEven()||k.subTo(b,k),k.rShiftTo(1,k);for(;f.isEven();)f.rShiftTo(1,f),d?(v.isEven()&& -C.isEven()||(v.addTo(this,v),C.subTo(b,C)),v.rShiftTo(1,v)):C.isEven()||C.subTo(b,C),C.rShiftTo(1,C);0<=e.compareTo(f)?(e.subTo(f,e),d&&n.subTo(v,n),k.subTo(C,k)):(f.subTo(e,f),d&&v.subTo(n,v),C.subTo(k,C))}if(0!=f.compareTo(p.ONE))return p.ZERO;if(0<=C.compareTo(b))return C.subtract(b);if(0>C.signum())C.addTo(b,C);else return C;return 0>C.signum()?C.add(b):C};p.prototype.pow=function(b){return this.exp(b,new Ea)};p.prototype.gcd=function(b){var d=0>this.s?this.negate():this.clone();b=0>b.s?b.negate(): -b.clone();if(0>d.compareTo(b)){var e=d,d=b;b=e}var e=d.getLowestSetBit(),f=b.getLowestSetBit();if(0>f)return d;e<f&&(f=e);for(0<f&&(d.rShiftTo(f,d),b.rShiftTo(f,b));0<d.signum();)0<(e=d.getLowestSetBit())&&d.rShiftTo(e,d),0<(e=b.getLowestSetBit())&&b.rShiftTo(e,b),0<=d.compareTo(b)?(d.subTo(b,d),d.rShiftTo(1,d)):(b.subTo(d,b),b.rShiftTo(1,b));0<f&&b.lShiftTo(f,b);return b};p.prototype.isProbablePrime=function(b){var d,e=this.abs();if(1==e.t&&e[0]<=H[H.length-1]){for(d=0;d<H.length;++d)if(e[0]==H[d])return!0; -return!1}if(e.isEven())return!1;for(d=1;d<H.length;){for(var f=H[d],n=d+1;n<H.length&&f<Zb;)f*=H[n++];for(f=e.modInt(f);d<n;)if(0==f%H[d++])return!1}return e.millerRabin(b)};p.prototype.square=function(){var b=E();this.squareTo(b);return b};p.prototype.IsNegative=function(){return-1==this.compareTo(p.ZERO)?!0:!1};p.op_Equality=function(b,d){return 0==b.compareTo(d)?!0:!1};p.op_Inequality=function(b,d){return 0!=b.compareTo(d)?!0:!1};p.op_GreaterThan=function(b,d){return 0<b.compareTo(d)?!0:!1};p.op_LessThan= -function(b,d){return 0>b.compareTo(d)?!0:!1};p.op_Addition=function(b,d){return(new p(b)).add(new p(d))};p.op_Subtraction=function(b,d){return(new p(b)).subtract(new p(d))};p.Int128Mul=function(b,d){return(new p(b)).multiply(new p(d))};p.op_Division=function(b,d){return b.divide(d)};p.prototype.ToDouble=function(){return parseFloat(this.toString())};V=function(b,d){var e;if("undefined"==typeof Object.getOwnPropertyNames)for(e in d.prototype){if("undefined"==typeof b.prototype[e]||b.prototype[e]== -Object.prototype[e])b.prototype[e]=d.prototype[e]}else for(var f=Object.getOwnPropertyNames(d.prototype),n=0;n<f.length;n++)"undefined"==typeof Object.getOwnPropertyDescriptor(b.prototype,f[n])&&Object.defineProperty(b.prototype,f[n],Object.getOwnPropertyDescriptor(d.prototype,f[n]));for(e in d)"undefined"==typeof b[e]&&(b[e]=d[e]);b.$baseCtor=d};f.Path=function(){return[]};f.Paths=function(){return[]};f.DoublePoint=function(){var b=arguments;this.Y=this.X=0;1==b.length?(this.X=b[0].X,this.Y=b[0].Y): -2==b.length&&(this.X=b[0],this.Y=b[1])};f.DoublePoint0=function(){this.Y=this.X=0};f.DoublePoint1=function(b){this.X=b.X;this.Y=b.Y};f.DoublePoint2=function(b,d){this.X=b;this.Y=d};f.PolyNode=function(){this.m_Parent=null;this.m_polygon=new f.Path;this.m_endtype=this.m_jointype=this.m_Index=0;this.m_Childs=[];this.IsOpen=!1};f.PolyNode.prototype.IsHoleNode=function(){for(var b=!0,d=this.m_Parent;null!==d;)b=!b,d=d.m_Parent;return b};f.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length}; -f.PolyNode.prototype.Contour=function(){return this.m_polygon};f.PolyNode.prototype.AddChild=function(b){var d=this.m_Childs.length;this.m_Childs.push(b);b.m_Parent=this;b.m_Index=d};f.PolyNode.prototype.GetNext=function(){return 0<this.m_Childs.length?this.m_Childs[0]:this.GetNextSiblingUp()};f.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index==this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]};f.PolyNode.prototype.Childs= -function(){return this.m_Childs};f.PolyNode.prototype.Parent=function(){return this.m_Parent};f.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()};f.PolyTree=function(){this.m_AllPolys=[];f.PolyNode.call(this)};f.PolyTree.prototype.Clear=function(){for(var b=0,d=this.m_AllPolys.length;b<d;b++)this.m_AllPolys[b]=null;this.m_AllPolys.length=0;this.m_Childs.length=0};f.PolyTree.prototype.GetFirst=function(){return 0<this.m_Childs.length?this.m_Childs[0]:null};f.PolyTree.prototype.Total=function(){var b= -this.m_AllPolys.length;0<b&&this.m_Childs[0]!=this.m_AllPolys[0]&&b--;return b};V(f.PolyTree,f.PolyNode);f.Math_Abs_Int64=f.Math_Abs_Int32=f.Math_Abs_Double=function(b){return Math.abs(b)};f.Math_Max_Int32_Int32=function(b,d){return Math.max(b,d)};f.Cast_Int32=Y||Qa||Xb?function(b){return b|0}:function(b){return~~b};f.Cast_Int64=I?function(b){return-2147483648>b||2147483647<b?0>b?Math.ceil(b):Math.floor(b):~~b}:Jb&&"function"==typeof Number.toInteger?function(b){return Number.toInteger(b)}:xb||ab? -function(b){return parseInt(b,10)}:Y?function(b){return-2147483648>b||2147483647<b?0>b?Math.ceil(b):Math.floor(b):b|0}:function(b){return 0>b?Math.ceil(b):Math.floor(b)};f.Clear=function(b){b.length=0};f.PI=3.141592653589793;f.PI2=6.283185307179586;f.IntPoint=function(){var b=arguments,d=b.length;this.Y=this.X=0;f.use_xyz?(this.Z=0,3==d?(this.X=b[0],this.Y=b[1],this.Z=b[2]):2==d?(this.X=b[0],this.Y=b[1],this.Z=0):1==d?b[0]instanceof f.DoublePoint?(b=b[0],this.X=f.Clipper.Round(b.X),this.Y=f.Clipper.Round(b.Y), -this.Z=0):(b=b[0],"undefined"==typeof b.Z&&(b.Z=0),this.X=b.X,this.Y=b.Y,this.Z=b.Z):this.Z=this.Y=this.X=0):2==d?(this.X=b[0],this.Y=b[1]):1==d?b[0]instanceof f.DoublePoint?(b=b[0],this.X=f.Clipper.Round(b.X),this.Y=f.Clipper.Round(b.Y)):(b=b[0],this.X=b.X,this.Y=b.Y):this.Y=this.X=0};f.IntPoint.op_Equality=function(b,d){return b.X==d.X&&b.Y==d.Y};f.IntPoint.op_Inequality=function(b,d){return b.X!=d.X||b.Y!=d.Y};f.use_xyz?(f.IntPoint0=function(){this.Z=this.Y=this.X=0},f.IntPoint1=function(b){this.X= -b.X;this.Y=b.Y;this.Z=b.Z},f.IntPoint1dp=function(b){this.X=f.Clipper.Round(b.X);this.Y=f.Clipper.Round(b.Y);this.Z=0},f.IntPoint2=function(b,d){this.X=b;this.Y=d;this.Z=0},f.IntPoint3=function(b,d,e){this.X=b;this.Y=d;this.Z=e}):(f.IntPoint0=function(){this.Y=this.X=0},f.IntPoint1=function(b){this.X=b.X;this.Y=b.Y},f.IntPoint1dp=function(b){this.X=f.Clipper.Round(b.X);this.Y=f.Clipper.Round(b.Y)},f.IntPoint2=function(b,d){this.X=b;this.Y=d});f.IntRect=function(){var b=arguments,d=b.length;4==d?(this.left= -b[0],this.top=b[1],this.right=b[2],this.bottom=b[3]):1==d?(this.left=b[0].left,this.top=b[0].top,this.right=b[0].right,this.bottom=b[0].bottom):this.bottom=this.right=this.top=this.left=0};f.IntRect0=function(){this.bottom=this.right=this.top=this.left=0};f.IntRect1=function(b){this.left=b.left;this.top=b.top;this.right=b.right;this.bottom=b.bottom};f.IntRect4=function(b,d,e,f){this.left=b;this.top=d;this.right=e;this.bottom=f};f.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3};f.PolyType= -{ptSubject:0,ptClip:1};f.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3};f.JoinType={jtSquare:0,jtRound:1,jtMiter:2};f.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4};f.EdgeSide={esLeft:0,esRight:1};f.Direction={dRightToLeft:0,dLeftToRight:1};f.TEdge=function(){this.Bot=new f.IntPoint;this.Curr=new f.IntPoint;this.Top=new f.IntPoint;this.Delta=new f.IntPoint;this.Dx=0;this.PolyTyp=f.PolyType.ptSubject;this.Side=f.EdgeSide.esLeft;this.OutIdx= -this.WindCnt2=this.WindCnt=this.WindDelta=0;this.PrevInSEL=this.NextInSEL=this.PrevInAEL=this.NextInAEL=this.NextInLML=this.Prev=this.Next=null};f.IntersectNode=function(){this.Edge2=this.Edge1=null;this.Pt=new f.IntPoint};f.MyIntersectNodeSort=function(){};f.MyIntersectNodeSort.Compare=function(b,d){var e=d.Pt.Y-b.Pt.Y;return 0<e?1:0>e?-1:0};f.LocalMinima=function(){this.Y=0;this.Next=this.RightBound=this.LeftBound=null};f.Scanbeam=function(){this.Y=0;this.Next=null};f.OutRec=function(){this.Idx= -0;this.IsOpen=this.IsHole=!1;this.PolyNode=this.BottomPt=this.Pts=this.FirstLeft=null};f.OutPt=function(){this.Idx=0;this.Pt=new f.IntPoint;this.Prev=this.Next=null};f.Join=function(){this.OutPt2=this.OutPt1=null;this.OffPt=new f.IntPoint};f.ClipperBase=function(){this.m_CurrentLM=this.m_MinimaList=null;this.m_edges=[];this.PreserveCollinear=this.m_HasOpenPaths=this.m_UseFullRange=!1;this.m_CurrentLM=this.m_MinimaList=null;this.m_HasOpenPaths=this.m_UseFullRange=!1};f.ClipperBase.horizontal=-9007199254740992; -f.ClipperBase.Skip=-2;f.ClipperBase.Unassigned=-1;f.ClipperBase.tolerance=1E-20;f.ClipperBase.loRange=47453132;f.ClipperBase.hiRange=0xfffffffffffff;f.ClipperBase.near_zero=function(b){return b>-f.ClipperBase.tolerance&&b<f.ClipperBase.tolerance};f.ClipperBase.IsHorizontal=function(b){return 0===b.Delta.Y};f.ClipperBase.prototype.PointIsVertex=function(b,d){var e=d;do{if(f.IntPoint.op_Equality(e.Pt,b))return!0;e=e.Next}while(e!=d);return!1};f.ClipperBase.prototype.PointOnLineSegment=function(b,d, -e,f){return f?b.X==d.X&&b.Y==d.Y||b.X==e.X&&b.Y==e.Y||b.X>d.X==b.X<e.X&&b.Y>d.Y==b.Y<e.Y&&p.op_Equality(p.Int128Mul(b.X-d.X,e.Y-d.Y),p.Int128Mul(e.X-d.X,b.Y-d.Y)):b.X==d.X&&b.Y==d.Y||b.X==e.X&&b.Y==e.Y||b.X>d.X==b.X<e.X&&b.Y>d.Y==b.Y<e.Y&&(b.X-d.X)*(e.Y-d.Y)==(e.X-d.X)*(b.Y-d.Y)};f.ClipperBase.prototype.PointOnPolygon=function(b,d,e){for(var f=d;;){if(this.PointOnLineSegment(b,f.Pt,f.Next.Pt,e))return!0;f=f.Next;if(f==d)break}return!1};f.ClipperBase.prototype.SlopesEqual=f.ClipperBase.SlopesEqual= -function(){var b=arguments,d=b.length,e,q,n;if(3==d)return d=b[0],e=b[1],b[2]?p.op_Equality(p.Int128Mul(d.Delta.Y,e.Delta.X),p.Int128Mul(d.Delta.X,e.Delta.Y)):f.Cast_Int64(d.Delta.Y*e.Delta.X)==f.Cast_Int64(d.Delta.X*e.Delta.Y);if(4==d)return d=b[0],e=b[1],q=b[2],b[3]?p.op_Equality(p.Int128Mul(d.Y-e.Y,e.X-q.X),p.Int128Mul(d.X-e.X,e.Y-q.Y)):0===f.Cast_Int64((d.Y-e.Y)*(e.X-q.X))-f.Cast_Int64((d.X-e.X)*(e.Y-q.Y));d=b[0];e=b[1];q=b[2];n=b[3];return b[4]?p.op_Equality(p.Int128Mul(d.Y-e.Y,q.X-n.X),p.Int128Mul(d.X- -e.X,q.Y-n.Y)):0===f.Cast_Int64((d.Y-e.Y)*(q.X-n.X))-f.Cast_Int64((d.X-e.X)*(q.Y-n.Y))};f.ClipperBase.SlopesEqual3=function(b,d,e){return e?p.op_Equality(p.Int128Mul(b.Delta.Y,d.Delta.X),p.Int128Mul(b.Delta.X,d.Delta.Y)):f.Cast_Int64(b.Delta.Y*d.Delta.X)==f.Cast_Int64(b.Delta.X*d.Delta.Y)};f.ClipperBase.SlopesEqual4=function(b,d,e,q){return q?p.op_Equality(p.Int128Mul(b.Y-d.Y,d.X-e.X),p.Int128Mul(b.X-d.X,d.Y-e.Y)):0===f.Cast_Int64((b.Y-d.Y)*(d.X-e.X))-f.Cast_Int64((b.X-d.X)*(d.Y-e.Y))};f.ClipperBase.SlopesEqual5= -function(b,d,e,q,n){return n?p.op_Equality(p.Int128Mul(b.Y-d.Y,e.X-q.X),p.Int128Mul(b.X-d.X,e.Y-q.Y)):0===f.Cast_Int64((b.Y-d.Y)*(e.X-q.X))-f.Cast_Int64((b.X-d.X)*(e.Y-q.Y))};f.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var b=0,d=this.m_edges.length;b<d;++b){for(var e=0,q=this.m_edges[b].length;e<q;++e)this.m_edges[b][e]=null;f.Clear(this.m_edges[b])}f.Clear(this.m_edges);this.m_HasOpenPaths=this.m_UseFullRange=!1};f.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!== -this.m_MinimaList;){var b=this.m_MinimaList.Next;this.m_MinimaList=null;this.m_MinimaList=b}this.m_CurrentLM=null};f.ClipperBase.prototype.RangeTest=function(b,d){if(d.Value)(b.X>f.ClipperBase.hiRange||b.Y>f.ClipperBase.hiRange||-b.X>f.ClipperBase.hiRange||-b.Y>f.ClipperBase.hiRange)&&f.Error("Coordinate outside allowed range in RangeTest().");else if(b.X>f.ClipperBase.loRange||b.Y>f.ClipperBase.loRange||-b.X>f.ClipperBase.loRange||-b.Y>f.ClipperBase.loRange)d.Value=!0,this.RangeTest(b,d)};f.ClipperBase.prototype.InitEdge= -function(b,d,e,q){b.Next=d;b.Prev=e;b.Curr.X=q.X;b.Curr.Y=q.Y;f.use_xyz&&(b.Curr.Z=q.Z);b.OutIdx=-1};f.ClipperBase.prototype.InitEdge2=function(b,d){b.Curr.Y>=b.Next.Curr.Y?(b.Bot.X=b.Curr.X,b.Bot.Y=b.Curr.Y,f.use_xyz&&(b.Bot.Z=b.Curr.Z),b.Top.X=b.Next.Curr.X,b.Top.Y=b.Next.Curr.Y,f.use_xyz&&(b.Top.Z=b.Next.Curr.Z)):(b.Top.X=b.Curr.X,b.Top.Y=b.Curr.Y,f.use_xyz&&(b.Top.Z=b.Curr.Z),b.Bot.X=b.Next.Curr.X,b.Bot.Y=b.Next.Curr.Y,f.use_xyz&&(b.Bot.Z=b.Next.Curr.Z));this.SetDx(b);b.PolyTyp=d};f.ClipperBase.prototype.FindNextLocMin= -function(b){for(var d;;){for(;f.IntPoint.op_Inequality(b.Bot,b.Prev.Bot)||f.IntPoint.op_Equality(b.Curr,b.Top);)b=b.Next;if(b.Dx!=f.ClipperBase.horizontal&&b.Prev.Dx!=f.ClipperBase.horizontal)break;for(;b.Prev.Dx==f.ClipperBase.horizontal;)b=b.Prev;for(d=b;b.Dx==f.ClipperBase.horizontal;)b=b.Next;if(b.Top.Y!=b.Prev.Bot.Y){d.Prev.Bot.X<b.Bot.X&&(b=d);break}}return b};f.ClipperBase.prototype.ProcessBound=function(b,d){var e,q=b,n;if(q.OutIdx==f.ClipperBase.Skip){b=q;if(d){for(;b.Top.Y==b.Next.Bot.Y;)b= -b.Next;for(;b!=q&&b.Dx==f.ClipperBase.horizontal;)b=b.Prev}else{for(;b.Top.Y==b.Prev.Bot.Y;)b=b.Prev;for(;b!=q&&b.Dx==f.ClipperBase.horizontal;)b=b.Next}b==q?q=d?b.Next:b.Prev:(b=d?q.Next:q.Prev,e=new f.LocalMinima,e.Next=null,e.Y=b.Bot.Y,e.LeftBound=null,e.RightBound=b,b.WindDelta=0,q=this.ProcessBound(b,d),this.InsertLocalMinima(e));return q}b.Dx==f.ClipperBase.horizontal&&(e=d?b.Prev:b.Next,e.OutIdx!=f.ClipperBase.Skip&&(e.Dx==f.ClipperBase.horizontal?e.Bot.X!=b.Bot.X&&e.Top.X!=b.Bot.X&&this.ReverseHorizontal(b): -e.Bot.X!=b.Bot.X&&this.ReverseHorizontal(b)));e=b;if(d){for(;q.Top.Y==q.Next.Bot.Y&&q.Next.OutIdx!=f.ClipperBase.Skip;)q=q.Next;if(q.Dx==f.ClipperBase.horizontal&&q.Next.OutIdx!=f.ClipperBase.Skip){for(n=q;n.Prev.Dx==f.ClipperBase.horizontal;)n=n.Prev;n.Prev.Top.X==q.Next.Top.X?d||(q=n.Prev):n.Prev.Top.X>q.Next.Top.X&&(q=n.Prev)}for(;b!=q;)b.NextInLML=b.Next,b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!=b.Prev.Top.X&&this.ReverseHorizontal(b),b=b.Next;b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!= -b.Prev.Top.X&&this.ReverseHorizontal(b);q=q.Next}else{for(;q.Top.Y==q.Prev.Bot.Y&&q.Prev.OutIdx!=f.ClipperBase.Skip;)q=q.Prev;if(q.Dx==f.ClipperBase.horizontal&&q.Prev.OutIdx!=f.ClipperBase.Skip){for(n=q;n.Next.Dx==f.ClipperBase.horizontal;)n=n.Next;n.Next.Top.X==q.Prev.Top.X?d||(q=n.Next):n.Next.Top.X>q.Prev.Top.X&&(q=n.Next)}for(;b!=q;)b.NextInLML=b.Prev,b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!=b.Next.Top.X&&this.ReverseHorizontal(b),b=b.Prev;b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!= -b.Next.Top.X&&this.ReverseHorizontal(b);q=q.Prev}return q};f.ClipperBase.prototype.AddPath=function(b,d,e){f.use_lines?e||d!=f.PolyType.ptClip||f.Error("AddPath: Open paths must be subject."):e||f.Error("AddPath: Open paths have been disabled.");var q=b.length-1;if(e)for(;0<q&&f.IntPoint.op_Equality(b[q],b[0]);)--q;for(;0<q&&f.IntPoint.op_Equality(b[q],b[q-1]);)--q;if(e&&2>q||!e&&1>q)return!1;for(var n=[],k=0;k<=q;k++)n.push(new f.TEdge);var v=!0;n[1].Curr.X=b[1].X;n[1].Curr.Y=b[1].Y;f.use_xyz&&(n[1].Curr.Z= -b[1].Z);var C={Value:this.m_UseFullRange};this.RangeTest(b[0],C);this.m_UseFullRange=C.Value;C.Value=this.m_UseFullRange;this.RangeTest(b[q],C);this.m_UseFullRange=C.Value;this.InitEdge(n[0],n[1],n[q],b[0]);this.InitEdge(n[q],n[0],n[q-1],b[q]);for(k=q-1;1<=k;--k)C.Value=this.m_UseFullRange,this.RangeTest(b[k],C),this.m_UseFullRange=C.Value,this.InitEdge(n[k],n[k+1],n[k-1],b[k]);for(k=b=q=n[0];;)if(b.Curr!=b.Next.Curr||!e&&b.Next==q){if(b.Prev==b.Next)break;else if(e&&f.ClipperBase.SlopesEqual(b.Prev.Curr, -b.Curr,b.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(b.Prev.Curr,b.Curr,b.Next.Curr))){b==q&&(q=b.Next);b=this.RemoveEdge(b);k=b=b.Prev;continue}b=b.Next;if(b==k||!e&&b.Next==q)break}else{if(b==b.Next)break;b==q&&(q=b.Next);k=b=this.RemoveEdge(b)}if(!e&&b==b.Next||e&&b.Prev==b.Next)return!1;e||(this.m_HasOpenPaths=!0,q.Prev.OutIdx=f.ClipperBase.Skip);b=q;do this.InitEdge2(b,d),b=b.Next,v&&b.Curr.Y!=q.Curr.Y&&(v=!1);while(b!=q);if(v){if(e)return!1;b.Prev.OutIdx= -f.ClipperBase.Skip;b.Prev.Bot.X<b.Prev.Top.X&&this.ReverseHorizontal(b.Prev);d=new f.LocalMinima;d.Next=null;d.Y=b.Bot.Y;d.LeftBound=null;d.RightBound=b;d.RightBound.Side=f.EdgeSide.esRight;for(d.RightBound.WindDelta=0;b.Next.OutIdx!=f.ClipperBase.Skip;)b.NextInLML=b.Next,b.Bot.X!=b.Prev.Top.X&&this.ReverseHorizontal(b),b=b.Next;this.InsertLocalMinima(d);this.m_edges.push(n);return!0}this.m_edges.push(n);v=null;for(f.IntPoint.op_Equality(b.Prev.Bot,b.Prev.Top)&&(b=b.Next);;){b=this.FindNextLocMin(b); -if(b==v)break;else null==v&&(v=b);d=new f.LocalMinima;d.Next=null;d.Y=b.Bot.Y;b.Dx<b.Prev.Dx?(d.LeftBound=b.Prev,d.RightBound=b,n=!1):(d.LeftBound=b,d.RightBound=b.Prev,n=!0);d.LeftBound.Side=f.EdgeSide.esLeft;d.RightBound.Side=f.EdgeSide.esRight;d.LeftBound.WindDelta=e?d.LeftBound.Next==d.RightBound?-1:1:0;d.RightBound.WindDelta=-d.LeftBound.WindDelta;b=this.ProcessBound(d.LeftBound,n);b.OutIdx==f.ClipperBase.Skip&&(b=this.ProcessBound(b,n));q=this.ProcessBound(d.RightBound,!n);q.OutIdx==f.ClipperBase.Skip&& -(q=this.ProcessBound(q,!n));d.LeftBound.OutIdx==f.ClipperBase.Skip?d.LeftBound=null:d.RightBound.OutIdx==f.ClipperBase.Skip&&(d.RightBound=null);this.InsertLocalMinima(d);n||(b=q)}return!0};f.ClipperBase.prototype.AddPaths=function(b,d,e){for(var f=!1,n=0,k=b.length;n<k;++n)this.AddPath(b[n],d,e)&&(f=!0);return f};f.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(b,d,e){return f.IntPoint.op_Equality(b,e)||f.IntPoint.op_Equality(b,d)||f.IntPoint.op_Equality(e,d)?!1:b.X!=e.X?d.X>b.X==d.X<e.X:d.Y> -b.Y==d.Y<e.Y};f.ClipperBase.prototype.RemoveEdge=function(b){b.Prev.Next=b.Next;b.Next.Prev=b.Prev;var d=b.Next;b.Prev=null;return d};f.ClipperBase.prototype.SetDx=function(b){b.Delta.X=b.Top.X-b.Bot.X;b.Delta.Y=b.Top.Y-b.Bot.Y;b.Dx=0===b.Delta.Y?f.ClipperBase.horizontal:b.Delta.X/b.Delta.Y};f.ClipperBase.prototype.InsertLocalMinima=function(b){if(null===this.m_MinimaList)this.m_MinimaList=b;else if(b.Y>=this.m_MinimaList.Y)b.Next=this.m_MinimaList,this.m_MinimaList=b;else{for(var d=this.m_MinimaList;null!== -d.Next&&b.Y<d.Next.Y;)d=d.Next;b.Next=d.Next;d.Next=b}};f.ClipperBase.prototype.PopLocalMinima=function(){null!==this.m_CurrentLM&&(this.m_CurrentLM=this.m_CurrentLM.Next)};f.ClipperBase.prototype.ReverseHorizontal=function(b){var d=b.Top.X;b.Top.X=b.Bot.X;b.Bot.X=d;f.use_xyz&&(d=b.Top.Z,b.Top.Z=b.Bot.Z,b.Bot.Z=d)};f.ClipperBase.prototype.Reset=function(){this.m_CurrentLM=this.m_MinimaList;if(null!=this.m_CurrentLM)for(var b=this.m_MinimaList;null!=b;){var d=b.LeftBound;null!=d&&(d.Curr.X=d.Bot.X, -d.Curr.Y=d.Bot.Y,f.use_xyz&&(d.Curr.Z=d.Bot.Z),d.Side=f.EdgeSide.esLeft,d.OutIdx=f.ClipperBase.Unassigned);d=b.RightBound;null!=d&&(d.Curr.X=d.Bot.X,d.Curr.Y=d.Bot.Y,f.use_xyz&&(d.Curr.Z=d.Bot.Z),d.Side=f.EdgeSide.esRight,d.OutIdx=f.ClipperBase.Unassigned);b=b.Next}};f.Clipper=function(b){"undefined"==typeof b&&(b=0);this.m_PolyOuts=null;this.m_ClipType=f.ClipType.ctIntersection;this.m_IntersectNodeComparer=this.m_IntersectList=this.m_SortedEdges=this.m_ActiveEdges=this.m_Scanbeam=null;this.m_ExecuteLocked= -!1;this.m_SubjFillType=this.m_ClipFillType=f.PolyFillType.pftEvenOdd;this.m_GhostJoins=this.m_Joins=null;this.StrictlySimple=this.ReverseSolution=this.m_UsingPolyTree=!1;f.ClipperBase.call(this);this.m_SortedEdges=this.m_ActiveEdges=this.m_Scanbeam=null;this.m_IntersectList=[];this.m_IntersectNodeComparer=f.MyIntersectNodeSort.Compare;this.m_UsingPolyTree=this.m_ExecuteLocked=!1;this.m_PolyOuts=[];this.m_Joins=[];this.m_GhostJoins=[];this.ReverseSolution=0!==(1&b);this.StrictlySimple=0!==(2&b);this.PreserveCollinear= -0!==(4&b);f.use_xyz&&(this.ZFillFunction=null)};f.Clipper.ioReverseSolution=1;f.Clipper.ioStrictlySimple=2;f.Clipper.ioPreserveCollinear=4;f.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),f.ClipperBase.prototype.Clear.call(this))};f.Clipper.prototype.DisposeScanbeamList=function(){for(;null!==this.m_Scanbeam;){var b=this.m_Scanbeam.Next;this.m_Scanbeam=null;this.m_Scanbeam=b}};f.Clipper.prototype.Reset=function(){f.ClipperBase.prototype.Reset.call(this);this.m_SortedEdges= -this.m_ActiveEdges=this.m_Scanbeam=null;for(var b=this.m_MinimaList;null!==b;)this.InsertScanbeam(b.Y),b=b.Next};f.Clipper.prototype.InsertScanbeam=function(b){if(null===this.m_Scanbeam)this.m_Scanbeam=new f.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=b;else if(b>this.m_Scanbeam.Y){var d=new f.Scanbeam;d.Y=b;d.Next=this.m_Scanbeam;this.m_Scanbeam=d}else{for(var e=this.m_Scanbeam;null!==e.Next&&b<=e.Next.Y;)e=e.Next;b!=e.Y&&(d=new f.Scanbeam,d.Y=b,d.Next=e.Next,e.Next=d)}};f.Clipper.prototype.Execute= -function(){var b=arguments,d=b.length,e=b[1]instanceof f.PolyTree;if(4!=d||e){if(4==d&&e){var d=b[0],q=b[1],e=b[2],b=b[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0;this.m_SubjFillType=e;this.m_ClipFillType=b;this.m_ClipType=d;this.m_UsingPolyTree=!0;try{(n=this.ExecuteInternal())&&this.BuildResult2(q)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return n}if(2==d&&!e||2==d&&e)return d=b[0],q=b[1],this.Execute(d,q,f.PolyFillType.pftEvenOdd,f.PolyFillType.pftEvenOdd)}else{d= -b[0];q=b[1];e=b[2];b=b[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&f.Error("Error: PolyTree struct is need for open path clipping.");this.m_ExecuteLocked=!0;f.Clear(q);this.m_SubjFillType=e;this.m_ClipFillType=b;this.m_ClipType=d;this.m_UsingPolyTree=!1;try{var n=this.ExecuteInternal();n&&this.BuildResult(q)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return n}};f.Clipper.prototype.FixHoleLinkage=function(b){if(null!==b.FirstLeft&&(b.IsHole==b.FirstLeft.IsHole||null===b.FirstLeft.Pts)){for(var d= -b.FirstLeft;null!==d&&(d.IsHole==b.IsHole||null===d.Pts);)d=d.FirstLeft;b.FirstLeft=d}};f.Clipper.prototype.ExecuteInternal=function(){try{this.Reset();if(null===this.m_CurrentLM)return!1;var b=this.PopScanbeam();do{this.InsertLocalMinimaIntoAEL(b);f.Clear(this.m_GhostJoins);this.ProcessHorizontals(!1);if(null===this.m_Scanbeam)break;var d=this.PopScanbeam();if(!this.ProcessIntersections(d))return!1;this.ProcessEdgesAtTopOfScanbeam(d);b=d}while(null!==this.m_Scanbeam||null!==this.m_CurrentLM);for(var b= -0,e=this.m_PolyOuts.length;b<e;b++){var q=this.m_PolyOuts[b];null===q.Pts||q.IsOpen||(q.IsHole^this.ReverseSolution)==0<this.Area(q)&&this.ReversePolyPtLinks(q.Pts)}this.JoinCommonEdges();b=0;for(e=this.m_PolyOuts.length;b<e;b++)q=this.m_PolyOuts[b],null===q.Pts||q.IsOpen||this.FixupOutPolygon(q);this.StrictlySimple&&this.DoSimplePolygons();return!0}finally{f.Clear(this.m_Joins),f.Clear(this.m_GhostJoins)}};f.Clipper.prototype.PopScanbeam=function(){var b=this.m_Scanbeam.Y;this.m_Scanbeam=this.m_Scanbeam.Next; -return b};f.Clipper.prototype.DisposeAllPolyPts=function(){for(var b=0,d=this.m_PolyOuts.length;b<d;++b)this.DisposeOutRec(b);f.Clear(this.m_PolyOuts)};f.Clipper.prototype.DisposeOutRec=function(b){this.m_PolyOuts[b].Pts=null;this.m_PolyOuts[b]=null};f.Clipper.prototype.AddJoin=function(b,d,e){var q=new f.Join;q.OutPt1=b;q.OutPt2=d;q.OffPt.X=e.X;q.OffPt.Y=e.Y;f.use_xyz&&(q.OffPt.Z=e.Z);this.m_Joins.push(q)};f.Clipper.prototype.AddGhostJoin=function(b,d){var e=new f.Join;e.OutPt1=b;e.OffPt.X=d.X;e.OffPt.Y= -d.Y;f.use_xyz&&(e.OffPt.Z=d.Z);this.m_GhostJoins.push(e)};f.Clipper.prototype.SetZ=function(b,d,e){null!==this.ZFillFunction&&0==b.Z&&null!==this.ZFillFunction&&(f.IntPoint.op_Equality(b,d.Bot)?b.Z=d.Bot.Z:f.IntPoint.op_Equality(b,d.Top)?b.Z=d.Top.Z:f.IntPoint.op_Equality(b,e.Bot)?b.Z=e.Bot.Z:f.IntPoint.op_Equality(b,e.Top)?b.Z=e.Top.Z:this.ZFillFunction(d.Bot,d.Top,e.Bot,e.Top,b))};f.Clipper.prototype.InsertLocalMinimaIntoAEL=function(b){for(;null!==this.m_CurrentLM&&this.m_CurrentLM.Y==b;){var d= -this.m_CurrentLM.LeftBound,e=this.m_CurrentLM.RightBound;this.PopLocalMinima();var q=null;null===d?(this.InsertEdgeIntoAEL(e,null),this.SetWindingCount(e),this.IsContributing(e)&&(q=this.AddOutPt(e,e.Bot))):(null==e?(this.InsertEdgeIntoAEL(d,null),this.SetWindingCount(d),this.IsContributing(d)&&(q=this.AddOutPt(d,d.Bot))):(this.InsertEdgeIntoAEL(d,null),this.InsertEdgeIntoAEL(e,d),this.SetWindingCount(d),e.WindCnt=d.WindCnt,e.WindCnt2=d.WindCnt2,this.IsContributing(d)&&(q=this.AddLocalMinPoly(d,e, -d.Bot))),this.InsertScanbeam(d.Top.Y));null!=e&&(f.ClipperBase.IsHorizontal(e)?this.AddEdgeToSEL(e):this.InsertScanbeam(e.Top.Y));if(null!=d&&null!=e){if(null!==q&&f.ClipperBase.IsHorizontal(e)&&0<this.m_GhostJoins.length&&0!==e.WindDelta)for(var n=0,k=this.m_GhostJoins.length;n<k;n++){var v=this.m_GhostJoins[n];this.HorzSegmentsOverlap(v.OutPt1.Pt.X,v.OffPt.X,e.Bot.X,e.Top.X)&&this.AddJoin(v.OutPt1,q,v.OffPt)}0<=d.OutIdx&&null!==d.PrevInAEL&&d.PrevInAEL.Curr.X==d.Bot.X&&0<=d.PrevInAEL.OutIdx&&f.ClipperBase.SlopesEqual(d.PrevInAEL, -d,this.m_UseFullRange)&&0!==d.WindDelta&&0!==d.PrevInAEL.WindDelta&&(n=this.AddOutPt(d.PrevInAEL,d.Bot),this.AddJoin(q,n,d.Top));if(d.NextInAEL!=e&&(0<=e.OutIdx&&0<=e.PrevInAEL.OutIdx&&f.ClipperBase.SlopesEqual(e.PrevInAEL,e,this.m_UseFullRange)&&0!==e.WindDelta&&0!==e.PrevInAEL.WindDelta&&(n=this.AddOutPt(e.PrevInAEL,e.Bot),this.AddJoin(q,n,e.Top)),q=d.NextInAEL,null!==q))for(;q!=e;)this.IntersectEdges(e,q,d.Curr,!1),q=q.NextInAEL}}};f.Clipper.prototype.InsertEdgeIntoAEL=function(b,d){if(null=== -this.m_ActiveEdges)b.PrevInAEL=null,b.NextInAEL=null,this.m_ActiveEdges=b;else if(null===d&&this.E2InsertsBeforeE1(this.m_ActiveEdges,b))b.PrevInAEL=null,b.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges=this.m_ActiveEdges.PrevInAEL=b;else{for(null===d&&(d=this.m_ActiveEdges);null!==d.NextInAEL&&!this.E2InsertsBeforeE1(d.NextInAEL,b);)d=d.NextInAEL;b.NextInAEL=d.NextInAEL;null!==d.NextInAEL&&(d.NextInAEL.PrevInAEL=b);b.PrevInAEL=d;d.NextInAEL=b}};f.Clipper.prototype.E2InsertsBeforeE1=function(b,d){return d.Curr.X== -b.Curr.X?d.Top.Y>b.Top.Y?d.Top.X<f.Clipper.TopX(b,d.Top.Y):b.Top.X>f.Clipper.TopX(d,b.Top.Y):d.Curr.X<b.Curr.X};f.Clipper.prototype.IsEvenOddFillType=function(b){return b.PolyTyp==f.PolyType.ptSubject?this.m_SubjFillType==f.PolyFillType.pftEvenOdd:this.m_ClipFillType==f.PolyFillType.pftEvenOdd};f.Clipper.prototype.IsEvenOddAltFillType=function(b){return b.PolyTyp==f.PolyType.ptSubject?this.m_ClipFillType==f.PolyFillType.pftEvenOdd:this.m_SubjFillType==f.PolyFillType.pftEvenOdd};f.Clipper.prototype.IsContributing= -function(b){var d,e;b.PolyTyp==f.PolyType.ptSubject?(d=this.m_SubjFillType,e=this.m_ClipFillType):(d=this.m_ClipFillType,e=this.m_SubjFillType);switch(d){case f.PolyFillType.pftEvenOdd:if(0===b.WindDelta&&1!=b.WindCnt)return!1;break;case f.PolyFillType.pftNonZero:if(1!=Math.abs(b.WindCnt))return!1;break;case f.PolyFillType.pftPositive:if(1!=b.WindCnt)return!1;break;default:if(-1!=b.WindCnt)return!1}switch(this.m_ClipType){case f.ClipType.ctIntersection:switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0!== -b.WindCnt2;case f.PolyFillType.pftPositive:return 0<b.WindCnt2;default:return 0>b.WindCnt2}case f.ClipType.ctUnion:switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2;default:return 0<=b.WindCnt2}case f.ClipType.ctDifference:if(b.PolyTyp==f.PolyType.ptSubject)switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2; -default:return 0<=b.WindCnt2}else switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0!==b.WindCnt2;case f.PolyFillType.pftPositive:return 0<b.WindCnt2;default:return 0>b.WindCnt2}case f.ClipType.ctXor:if(0===b.WindDelta)switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2;default:return 0<=b.WindCnt2}}return!0};f.Clipper.prototype.SetWindingCount=function(b){for(var d=b.PrevInAEL;null!== -d&&(d.PolyTyp!=b.PolyTyp||0===d.WindDelta);)d=d.PrevInAEL;if(null===d)b.WindCnt=0===b.WindDelta?1:b.WindDelta,b.WindCnt2=0,d=this.m_ActiveEdges;else{if(0===b.WindDelta&&this.m_ClipType!=f.ClipType.ctUnion)b.WindCnt=1;else if(this.IsEvenOddFillType(b))if(0===b.WindDelta){for(var e=!0,q=d.PrevInAEL;null!==q;)q.PolyTyp==d.PolyTyp&&0!==q.WindDelta&&(e=!e),q=q.PrevInAEL;b.WindCnt=e?0:1}else b.WindCnt=b.WindDelta;else b.WindCnt=0>d.WindCnt*d.WindDelta?1<Math.abs(d.WindCnt)?0>d.WindDelta*b.WindDelta?d.WindCnt: -d.WindCnt+b.WindDelta:0===b.WindDelta?1:b.WindDelta:0===b.WindDelta?0>d.WindCnt?d.WindCnt-1:d.WindCnt+1:0>d.WindDelta*b.WindDelta?d.WindCnt:d.WindCnt+b.WindDelta;b.WindCnt2=d.WindCnt2;d=d.NextInAEL}if(this.IsEvenOddAltFillType(b))for(;d!=b;)0!==d.WindDelta&&(b.WindCnt2=0===b.WindCnt2?1:0),d=d.NextInAEL;else for(;d!=b;)b.WindCnt2+=d.WindDelta,d=d.NextInAEL};f.Clipper.prototype.AddEdgeToSEL=function(b){null===this.m_SortedEdges?(this.m_SortedEdges=b,b.PrevInSEL=null,b.NextInSEL=null):(b.NextInSEL=this.m_SortedEdges, -b.PrevInSEL=null,this.m_SortedEdges=this.m_SortedEdges.PrevInSEL=b)};f.Clipper.prototype.CopyAELToSEL=function(){var b=this.m_ActiveEdges;for(this.m_SortedEdges=b;null!==b;)b.PrevInSEL=b.PrevInAEL,b=b.NextInSEL=b.NextInAEL};f.Clipper.prototype.SwapPositionsInAEL=function(b,d){if(b.NextInAEL!=b.PrevInAEL&&d.NextInAEL!=d.PrevInAEL){if(b.NextInAEL==d){var e=d.NextInAEL;null!==e&&(e.PrevInAEL=b);var f=b.PrevInAEL;null!==f&&(f.NextInAEL=d);d.PrevInAEL=f;d.NextInAEL=b;b.PrevInAEL=d;b.NextInAEL=e}else d.NextInAEL== -b?(e=b.NextInAEL,null!==e&&(e.PrevInAEL=d),f=d.PrevInAEL,null!==f&&(f.NextInAEL=b),b.PrevInAEL=f,b.NextInAEL=d,d.PrevInAEL=b,d.NextInAEL=e):(e=b.NextInAEL,f=b.PrevInAEL,b.NextInAEL=d.NextInAEL,null!==b.NextInAEL&&(b.NextInAEL.PrevInAEL=b),b.PrevInAEL=d.PrevInAEL,null!==b.PrevInAEL&&(b.PrevInAEL.NextInAEL=b),d.NextInAEL=e,null!==d.NextInAEL&&(d.NextInAEL.PrevInAEL=d),d.PrevInAEL=f,null!==d.PrevInAEL&&(d.PrevInAEL.NextInAEL=d));null===b.PrevInAEL?this.m_ActiveEdges=b:null===d.PrevInAEL&&(this.m_ActiveEdges= -d)}};f.Clipper.prototype.SwapPositionsInSEL=function(b,d){if(null!==b.NextInSEL||null!==b.PrevInSEL)if(null!==d.NextInSEL||null!==d.PrevInSEL){if(b.NextInSEL==d){var e=d.NextInSEL;null!==e&&(e.PrevInSEL=b);var f=b.PrevInSEL;null!==f&&(f.NextInSEL=d);d.PrevInSEL=f;d.NextInSEL=b;b.PrevInSEL=d;b.NextInSEL=e}else d.NextInSEL==b?(e=b.NextInSEL,null!==e&&(e.PrevInSEL=d),f=d.PrevInSEL,null!==f&&(f.NextInSEL=b),b.PrevInSEL=f,b.NextInSEL=d,d.PrevInSEL=b,d.NextInSEL=e):(e=b.NextInSEL,f=b.PrevInSEL,b.NextInSEL= -d.NextInSEL,null!==b.NextInSEL&&(b.NextInSEL.PrevInSEL=b),b.PrevInSEL=d.PrevInSEL,null!==b.PrevInSEL&&(b.PrevInSEL.NextInSEL=b),d.NextInSEL=e,null!==d.NextInSEL&&(d.NextInSEL.PrevInSEL=d),d.PrevInSEL=f,null!==d.PrevInSEL&&(d.PrevInSEL.NextInSEL=d));null===b.PrevInSEL?this.m_SortedEdges=b:null===d.PrevInSEL&&(this.m_SortedEdges=d)}};f.Clipper.prototype.AddLocalMaxPoly=function(b,d,e){this.AddOutPt(b,e);0==d.WindDelta&&this.AddOutPt(d,e);b.OutIdx==d.OutIdx?(b.OutIdx=-1,d.OutIdx=-1):b.OutIdx<d.OutIdx? -this.AppendPolygon(b,d):this.AppendPolygon(d,b)};f.Clipper.prototype.AddLocalMinPoly=function(b,d,e){var q,n;f.ClipperBase.IsHorizontal(d)||b.Dx>d.Dx?(q=this.AddOutPt(b,e),d.OutIdx=b.OutIdx,b.Side=f.EdgeSide.esLeft,d.Side=f.EdgeSide.esRight,n=b,b=n.PrevInAEL==d?d.PrevInAEL:n.PrevInAEL):(q=this.AddOutPt(d,e),b.OutIdx=d.OutIdx,b.Side=f.EdgeSide.esRight,d.Side=f.EdgeSide.esLeft,n=d,b=n.PrevInAEL==b?b.PrevInAEL:n.PrevInAEL);null!==b&&0<=b.OutIdx&&f.Clipper.TopX(b,e.Y)==f.Clipper.TopX(n,e.Y)&&f.ClipperBase.SlopesEqual(n, -b,this.m_UseFullRange)&&0!==n.WindDelta&&0!==b.WindDelta&&(e=this.AddOutPt(b,e),this.AddJoin(q,e,n.Top));return q};f.Clipper.prototype.CreateOutRec=function(){var b=new f.OutRec;b.Idx=-1;b.IsHole=!1;b.IsOpen=!1;b.FirstLeft=null;b.Pts=null;b.BottomPt=null;b.PolyNode=null;this.m_PolyOuts.push(b);b.Idx=this.m_PolyOuts.length-1;return b};f.Clipper.prototype.AddOutPt=function(b,d){var e=b.Side==f.EdgeSide.esLeft;if(0>b.OutIdx){var q=this.CreateOutRec();q.IsOpen=0===b.WindDelta;var n=new f.OutPt;q.Pts= -n;n.Idx=q.Idx;n.Pt.X=d.X;n.Pt.Y=d.Y;f.use_xyz&&(n.Pt.Z=d.Z);n.Next=n;n.Prev=n;q.IsOpen||this.SetHoleState(b,q);b.OutIdx=q.Idx}else{var q=this.m_PolyOuts[b.OutIdx],k=q.Pts;if(e&&f.IntPoint.op_Equality(d,k.Pt))return k;if(!e&&f.IntPoint.op_Equality(d,k.Prev.Pt))return k.Prev;n=new f.OutPt;n.Idx=q.Idx;n.Pt.X=d.X;n.Pt.Y=d.Y;f.use_xyz&&(n.Pt.Z=d.Z);n.Next=k;n.Prev=k.Prev;n.Prev.Next=n;k.Prev=n;e&&(q.Pts=n)}return n};f.Clipper.prototype.SwapPoints=function(b,d){var e=new f.IntPoint(b.Value);b.Value.X=d.Value.X; -b.Value.Y=d.Value.Y;f.use_xyz&&(b.Value.Z=d.Value.Z);d.Value.X=e.X;d.Value.Y=e.Y;f.use_xyz&&(d.Value.Z=e.Z)};f.Clipper.prototype.HorzSegmentsOverlap=function(b,d,e,f){var n;b>d&&(n=b,b=d,d=n);e>f&&(n=e,e=f,f=n);return b<f&&e<d};f.Clipper.prototype.SetHoleState=function(b,d){for(var e=!1,f=b.PrevInAEL;null!==f;)0<=f.OutIdx&&0!=f.WindDelta&&(e=!e,null===d.FirstLeft&&(d.FirstLeft=this.m_PolyOuts[f.OutIdx])),f=f.PrevInAEL;e&&(d.IsHole=!0)};f.Clipper.prototype.GetDx=function(b,d){return b.Y==d.Y?f.ClipperBase.horizontal: -(d.X-b.X)/(d.Y-b.Y)};f.Clipper.prototype.FirstIsBottomPt=function(b,d){for(var e=b.Prev;f.IntPoint.op_Equality(e.Pt,b.Pt)&&e!=b;)e=e.Prev;for(var q=Math.abs(this.GetDx(b.Pt,e.Pt)),e=b.Next;f.IntPoint.op_Equality(e.Pt,b.Pt)&&e!=b;)e=e.Next;for(var n=Math.abs(this.GetDx(b.Pt,e.Pt)),e=d.Prev;f.IntPoint.op_Equality(e.Pt,d.Pt)&&e!=d;)e=e.Prev;for(var k=Math.abs(this.GetDx(d.Pt,e.Pt)),e=d.Next;f.IntPoint.op_Equality(e.Pt,d.Pt)&&e!=d;)e=e.Next;e=Math.abs(this.GetDx(d.Pt,e.Pt));return q>=k&&q>=e||n>=k&&n>= -e};f.Clipper.prototype.GetBottomPt=function(b){for(var d=null,e=b.Next;e!=b;)e.Pt.Y>b.Pt.Y?(b=e,d=null):e.Pt.Y==b.Pt.Y&&e.Pt.X<=b.Pt.X&&(e.Pt.X<b.Pt.X?(d=null,b=e):e.Next!=b&&e.Prev!=b&&(d=e)),e=e.Next;if(null!==d)for(;d!=e;)for(this.FirstIsBottomPt(e,d)||(b=d),d=d.Next;f.IntPoint.op_Inequality(d.Pt,b.Pt);)d=d.Next;return b};f.Clipper.prototype.GetLowermostRec=function(b,d){null===b.BottomPt&&(b.BottomPt=this.GetBottomPt(b.Pts));null===d.BottomPt&&(d.BottomPt=this.GetBottomPt(d.Pts));var e=b.BottomPt, -f=d.BottomPt;return e.Pt.Y>f.Pt.Y?b:e.Pt.Y<f.Pt.Y?d:e.Pt.X<f.Pt.X?b:e.Pt.X>f.Pt.X?d:e.Next==e?d:f.Next==f?b:this.FirstIsBottomPt(e,f)?b:d};f.Clipper.prototype.Param1RightOfParam2=function(b,d){do if(b=b.FirstLeft,b==d)return!0;while(null!==b);return!1};f.Clipper.prototype.GetOutRec=function(b){for(b=this.m_PolyOuts[b];b!=this.m_PolyOuts[b.Idx];)b=this.m_PolyOuts[b.Idx];return b};f.Clipper.prototype.AppendPolygon=function(b,d){var e=this.m_PolyOuts[b.OutIdx],q=this.m_PolyOuts[d.OutIdx],n;n=this.Param1RightOfParam2(e, -q)?q:this.Param1RightOfParam2(q,e)?e:this.GetLowermostRec(e,q);var k=e.Pts,v=k.Prev,C=q.Pts,p=C.Prev;b.Side==f.EdgeSide.esLeft?(d.Side==f.EdgeSide.esLeft?(this.ReversePolyPtLinks(C),C.Next=k,k.Prev=C,v.Next=p,p.Prev=v,e.Pts=p):(p.Next=k,k.Prev=p,C.Prev=v,v.Next=C,e.Pts=C),k=f.EdgeSide.esLeft):(d.Side==f.EdgeSide.esRight?(this.ReversePolyPtLinks(C),v.Next=p,p.Prev=v,C.Next=k,k.Prev=C):(v.Next=C,C.Prev=v,k.Prev=p,p.Next=k),k=f.EdgeSide.esRight);e.BottomPt=null;n==q&&(q.FirstLeft!=e&&(e.FirstLeft=q.FirstLeft), -e.IsHole=q.IsHole);q.Pts=null;q.BottomPt=null;q.FirstLeft=e;n=b.OutIdx;v=d.OutIdx;b.OutIdx=-1;d.OutIdx=-1;for(C=this.m_ActiveEdges;null!==C;){if(C.OutIdx==v){C.OutIdx=n;C.Side=k;break}C=C.NextInAEL}q.Idx=e.Idx};f.Clipper.prototype.ReversePolyPtLinks=function(b){if(null!==b){var d,e;d=b;do e=d.Next,d.Next=d.Prev,d=d.Prev=e;while(d!=b)}};f.Clipper.SwapSides=function(b,d){var e=b.Side;b.Side=d.Side;d.Side=e};f.Clipper.SwapPolyIndexes=function(b,d){var e=b.OutIdx;b.OutIdx=d.OutIdx;d.OutIdx=e};f.Clipper.prototype.IntersectEdges= -function(b,d,e){var q=0<=b.OutIdx,n=0<=d.OutIdx;f.use_xyz&&this.SetZ(e,b,d);if(!f.use_lines||0!==b.WindDelta&&0!==d.WindDelta){if(b.PolyTyp==d.PolyTyp)if(this.IsEvenOddFillType(b)){var k=b.WindCnt;b.WindCnt=d.WindCnt;d.WindCnt=k}else b.WindCnt=0===b.WindCnt+d.WindDelta?-b.WindCnt:b.WindCnt+d.WindDelta,d.WindCnt=0===d.WindCnt-b.WindDelta?-d.WindCnt:d.WindCnt-b.WindDelta;else this.IsEvenOddFillType(d)?b.WindCnt2=0===b.WindCnt2?1:0:b.WindCnt2+=d.WindDelta,this.IsEvenOddFillType(b)?d.WindCnt2=0===d.WindCnt2? -1:0:d.WindCnt2-=b.WindDelta;var v,C,p;b.PolyTyp==f.PolyType.ptSubject?(v=this.m_SubjFillType,p=this.m_ClipFillType):(v=this.m_ClipFillType,p=this.m_SubjFillType);d.PolyTyp==f.PolyType.ptSubject?(C=this.m_SubjFillType,k=this.m_ClipFillType):(C=this.m_ClipFillType,k=this.m_SubjFillType);switch(v){case f.PolyFillType.pftPositive:v=b.WindCnt;break;case f.PolyFillType.pftNegative:v=-b.WindCnt;break;default:v=Math.abs(b.WindCnt)}switch(C){case f.PolyFillType.pftPositive:C=d.WindCnt;break;case f.PolyFillType.pftNegative:C= --d.WindCnt;break;default:C=Math.abs(d.WindCnt)}if(q&&n)0!=v&&1!=v||0!=C&&1!=C||b.PolyTyp!=d.PolyTyp&&this.m_ClipType!=f.ClipType.ctXor?this.AddLocalMaxPoly(b,d,e):(this.AddOutPt(b,e),this.AddOutPt(d,e),f.Clipper.SwapSides(b,d),f.Clipper.SwapPolyIndexes(b,d));else if(q){if(0===C||1==C)this.AddOutPt(b,e),f.Clipper.SwapSides(b,d),f.Clipper.SwapPolyIndexes(b,d)}else if(n){if(0===v||1==v)this.AddOutPt(d,e),f.Clipper.SwapSides(b,d),f.Clipper.SwapPolyIndexes(b,d)}else if(!(0!=v&&1!=v||0!=C&&1!=C)){switch(p){case f.PolyFillType.pftPositive:q= -b.WindCnt2;break;case f.PolyFillType.pftNegative:q=-b.WindCnt2;break;default:q=Math.abs(b.WindCnt2)}switch(k){case f.PolyFillType.pftPositive:n=d.WindCnt2;break;case f.PolyFillType.pftNegative:n=-d.WindCnt2;break;default:n=Math.abs(d.WindCnt2)}if(b.PolyTyp!=d.PolyTyp)this.AddLocalMinPoly(b,d,e);else if(1==v&&1==C)switch(this.m_ClipType){case f.ClipType.ctIntersection:0<q&&0<n&&this.AddLocalMinPoly(b,d,e);break;case f.ClipType.ctUnion:0>=q&&0>=n&&this.AddLocalMinPoly(b,d,e);break;case f.ClipType.ctDifference:(b.PolyTyp== -f.PolyType.ptClip&&0<q&&0<n||b.PolyTyp==f.PolyType.ptSubject&&0>=q&&0>=n)&&this.AddLocalMinPoly(b,d,e);break;case f.ClipType.ctXor:this.AddLocalMinPoly(b,d,e)}else f.Clipper.SwapSides(b,d)}}else if(0!=b.WindDelta||0!=d.WindDelta)b.PolyTyp==d.PolyTyp&&b.WindDelta!=d.WindDelta&&this.m_ClipType==f.ClipType.ctUnion?0===b.WindDelta?n&&(this.AddOutPt(b,e),q&&(b.OutIdx=-1)):q&&(this.AddOutPt(d,e),n&&(d.OutIdx=-1)):b.PolyTyp!=d.PolyTyp&&(0!==b.WindDelta||1!=Math.abs(d.WindCnt)||this.m_ClipType==f.ClipType.ctUnion&& -0!==d.WindCnt2?0!==d.WindDelta||1!=Math.abs(b.WindCnt)||this.m_ClipType==f.ClipType.ctUnion&&0!==b.WindCnt2||(this.AddOutPt(d,e),n&&(d.OutIdx=-1)):(this.AddOutPt(b,e),q&&(b.OutIdx=-1)))};f.Clipper.prototype.DeleteFromAEL=function(b){var d=b.PrevInAEL,e=b.NextInAEL;if(null!==d||null!==e||b==this.m_ActiveEdges)null!==d?d.NextInAEL=e:this.m_ActiveEdges=e,null!==e&&(e.PrevInAEL=d),b.NextInAEL=null,b.PrevInAEL=null};f.Clipper.prototype.DeleteFromSEL=function(b){var d=b.PrevInSEL,e=b.NextInSEL;if(null!== -d||null!==e||b==this.m_SortedEdges)null!==d?d.NextInSEL=e:this.m_SortedEdges=e,null!==e&&(e.PrevInSEL=d),b.NextInSEL=null,b.PrevInSEL=null};f.Clipper.prototype.UpdateEdgeIntoAEL=function(b){null===b.NextInLML&&f.Error("UpdateEdgeIntoAEL: invalid call");var d=b.PrevInAEL,e=b.NextInAEL;b.NextInLML.OutIdx=b.OutIdx;null!==d?d.NextInAEL=b.NextInLML:this.m_ActiveEdges=b.NextInLML;null!==e&&(e.PrevInAEL=b.NextInLML);b.NextInLML.Side=b.Side;b.NextInLML.WindDelta=b.WindDelta;b.NextInLML.WindCnt=b.WindCnt; -b.NextInLML.WindCnt2=b.WindCnt2;b=b.NextInLML;b.Curr.X=b.Bot.X;b.Curr.Y=b.Bot.Y;f.use_xyz&&(b.Curr.Z=b.Bot.Z);b.PrevInAEL=d;b.NextInAEL=e;f.ClipperBase.IsHorizontal(b)||this.InsertScanbeam(b.Top.Y);return b};f.Clipper.prototype.ProcessHorizontals=function(b){for(var d=this.m_SortedEdges;null!==d;)this.DeleteFromSEL(d),this.ProcessHorizontal(d,b),d=this.m_SortedEdges};f.Clipper.prototype.GetHorzDirection=function(b,d){b.Bot.X<b.Top.X?(d.Left=b.Bot.X,d.Right=b.Top.X,d.Dir=f.Direction.dLeftToRight): -(d.Left=b.Top.X,d.Right=b.Bot.X,d.Dir=f.Direction.dRightToLeft)};f.Clipper.prototype.ProcessHorizontal=function(b,d){var e={Dir:null,Left:null,Right:null};this.GetHorzDirection(b,e);for(var q=e.Dir,n=e.Left,k=e.Right,v=b,C=null;null!==v.NextInLML&&f.ClipperBase.IsHorizontal(v.NextInLML);)v=v.NextInLML;for(null===v.NextInLML&&(C=this.GetMaximaPair(v));;){for(var p=b==v,F=this.GetNextInAEL(b,q);null!==F&&!(F.Curr.X==b.Top.X&&null!==b.NextInLML&&F.Dx<b.NextInLML.Dx);){e=this.GetNextInAEL(F,q);if(q== -f.Direction.dLeftToRight&&F.Curr.X<=k||q==f.Direction.dRightToLeft&&F.Curr.X>=n){if(F==C&&p){if(0<=b.OutIdx){q=this.AddOutPt(b,b.Top);for(e=this.m_SortedEdges;null!==e;)0<=e.OutIdx&&this.HorzSegmentsOverlap(b.Bot.X,b.Top.X,e.Bot.X,e.Top.X)&&(n=this.AddOutPt(e,e.Bot),this.AddJoin(n,q,e.Top)),e=e.NextInSEL;this.AddGhostJoin(q,b.Bot);this.AddLocalMaxPoly(b,C,b.Top)}this.DeleteFromAEL(b);this.DeleteFromAEL(C);return}if(q==f.Direction.dLeftToRight){var E=new f.IntPoint(F.Curr.X,b.Curr.Y);this.IntersectEdges(b, -F,E)}else E=new f.IntPoint(F.Curr.X,b.Curr.Y),this.IntersectEdges(F,b,E);this.SwapPositionsInAEL(b,F)}else if(q==f.Direction.dLeftToRight&&F.Curr.X>=k||q==f.Direction.dRightToLeft&&F.Curr.X<=n)break;F=e}if(null!==b.NextInLML&&f.ClipperBase.IsHorizontal(b.NextInLML))b=this.UpdateEdgeIntoAEL(b),0<=b.OutIdx&&this.AddOutPt(b,b.Bot),e={Dir:q,Left:n,Right:k},this.GetHorzDirection(b,e),q=e.Dir,n=e.Left,k=e.Right;else break}null!==b.NextInLML?0<=b.OutIdx?(q=this.AddOutPt(b,b.Top),d&&this.AddGhostJoin(q,b.Bot), -b=this.UpdateEdgeIntoAEL(b),0!==b.WindDelta&&(C=b.PrevInAEL,e=b.NextInAEL,null!==C&&C.Curr.X==b.Bot.X&&C.Curr.Y==b.Bot.Y&&0!==C.WindDelta&&0<=C.OutIdx&&C.Curr.Y>C.Top.Y&&f.ClipperBase.SlopesEqual(b,C,this.m_UseFullRange)?(n=this.AddOutPt(C,b.Bot),this.AddJoin(q,n,b.Top)):null!==e&&e.Curr.X==b.Bot.X&&e.Curr.Y==b.Bot.Y&&0!==e.WindDelta&&0<=e.OutIdx&&e.Curr.Y>e.Top.Y&&f.ClipperBase.SlopesEqual(b,e,this.m_UseFullRange)&&(n=this.AddOutPt(e,b.Bot),this.AddJoin(q,n,b.Top)))):this.UpdateEdgeIntoAEL(b):(0<= -b.OutIdx&&this.AddOutPt(b,b.Top),this.DeleteFromAEL(b))};f.Clipper.prototype.GetNextInAEL=function(b,d){return d==f.Direction.dLeftToRight?b.NextInAEL:b.PrevInAEL};f.Clipper.prototype.IsMinima=function(b){return null!==b&&b.Prev.NextInLML!=b&&b.Next.NextInLML!=b};f.Clipper.prototype.IsMaxima=function(b,d){return null!==b&&b.Top.Y==d&&null===b.NextInLML};f.Clipper.prototype.IsIntermediate=function(b,d){return b.Top.Y==d&&null!==b.NextInLML};f.Clipper.prototype.GetMaximaPair=function(b){var d=null; -f.IntPoint.op_Equality(b.Next.Top,b.Top)&&null===b.Next.NextInLML?d=b.Next:f.IntPoint.op_Equality(b.Prev.Top,b.Top)&&null===b.Prev.NextInLML&&(d=b.Prev);return null===d||-2!=d.OutIdx&&(d.NextInAEL!=d.PrevInAEL||f.ClipperBase.IsHorizontal(d))?d:null};f.Clipper.prototype.ProcessIntersections=function(b){if(null==this.m_ActiveEdges)return!0;try{this.BuildIntersectList(b);if(0==this.m_IntersectList.length)return!0;if(1==this.m_IntersectList.length||this.FixupIntersectionOrder())this.ProcessIntersectList(); -else return!1}catch(d){this.m_SortedEdges=null,this.m_IntersectList.length=0,f.Error("ProcessIntersections error")}this.m_SortedEdges=null;return!0};f.Clipper.prototype.BuildIntersectList=function(b){if(null!==this.m_ActiveEdges){var d=this.m_ActiveEdges;for(this.m_SortedEdges=d;null!==d;)d.PrevInSEL=d.PrevInAEL,d.NextInSEL=d.NextInAEL,d.Curr.X=f.Clipper.TopX(d,b),d=d.NextInAEL;for(var e=!0;e&&null!==this.m_SortedEdges;){e=!1;for(d=this.m_SortedEdges;null!==d.NextInSEL;){b=d.NextInSEL;var q=new f.IntPoint; -d.Curr.X>b.Curr.X?(this.IntersectPoint(d,b,q),e=new f.IntersectNode,e.Edge1=d,e.Edge2=b,e.Pt.X=q.X,e.Pt.Y=q.Y,f.use_xyz&&(e.Pt.Z=q.Z),this.m_IntersectList.push(e),this.SwapPositionsInSEL(d,b),e=!0):d=b}if(null!==d.PrevInSEL)d.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}};f.Clipper.prototype.EdgesAdjacent=function(b){return b.Edge1.NextInSEL==b.Edge2||b.Edge1.PrevInSEL==b.Edge2};f.Clipper.IntersectNodeSort=function(b,d){return d.Pt.Y-b.Pt.Y};f.Clipper.prototype.FixupIntersectionOrder= -function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer);this.CopyAELToSEL();for(var b=this.m_IntersectList.length,d=0;d<b;d++){if(!this.EdgesAdjacent(this.m_IntersectList[d])){for(var e=d+1;e<b&&!this.EdgesAdjacent(this.m_IntersectList[e]);)e++;if(e==b)return!1;var f=this.m_IntersectList[d];this.m_IntersectList[d]=this.m_IntersectList[e];this.m_IntersectList[e]=f}this.SwapPositionsInSEL(this.m_IntersectList[d].Edge1,this.m_IntersectList[d].Edge2)}return!0};f.Clipper.prototype.ProcessIntersectList= -function(){for(var b=0,d=this.m_IntersectList.length;b<d;b++){var e=this.m_IntersectList[b];this.IntersectEdges(e.Edge1,e.Edge2,e.Pt);this.SwapPositionsInAEL(e.Edge1,e.Edge2)}this.m_IntersectList.length=0};I=function(b){return 0>b?Math.ceil(b-.5):Math.round(b)};Jb=function(b){return 0>b?Math.ceil(b-.5):Math.floor(b+.5)};Qa=function(b){return 0>b?-Math.round(Math.abs(b)):Math.round(b)};ab=function(b){if(0>b)return b-=.5,-2147483648>b?Math.ceil(b):b|0;b+=.5;return 2147483647<b?Math.floor(b):b|0};f.Clipper.Round= -Y?I:nb?Qa:Xb?ab:Jb;f.Clipper.TopX=function(b,d){return d==b.Top.Y?b.Top.X:b.Bot.X+f.Clipper.Round(b.Dx*(d-b.Bot.Y))};f.Clipper.prototype.IntersectPoint=function(b,d,e){e.X=0;e.Y=0;var q,n;if(b.Dx==d.Dx)e.Y=b.Curr.Y,e.X=f.Clipper.TopX(b,e.Y);else{if(0===b.Delta.X)e.X=b.Bot.X,f.ClipperBase.IsHorizontal(d)?e.Y=d.Bot.Y:(n=d.Bot.Y-d.Bot.X/d.Dx,e.Y=f.Clipper.Round(e.X/d.Dx+n));else if(0===d.Delta.X)e.X=d.Bot.X,f.ClipperBase.IsHorizontal(b)?e.Y=b.Bot.Y:(q=b.Bot.Y-b.Bot.X/b.Dx,e.Y=f.Clipper.Round(e.X/b.Dx+ -q));else{q=b.Bot.X-b.Bot.Y*b.Dx;n=d.Bot.X-d.Bot.Y*d.Dx;var k=(n-q)/(b.Dx-d.Dx);e.Y=f.Clipper.Round(k);e.X=Math.abs(b.Dx)<Math.abs(d.Dx)?f.Clipper.Round(b.Dx*k+q):f.Clipper.Round(d.Dx*k+n)}if(e.Y<b.Top.Y||e.Y<d.Top.Y){if(b.Top.Y>d.Top.Y)return e.Y=b.Top.Y,e.X=f.Clipper.TopX(d,b.Top.Y),e.X<b.Top.X;e.Y=d.Top.Y;e.X=Math.abs(b.Dx)<Math.abs(d.Dx)?f.Clipper.TopX(b,e.Y):f.Clipper.TopX(d,e.Y)}e.Y>b.Curr.Y&&(e.Y=b.Curr.Y,e.X=Math.abs(b.Dx)>Math.abs(d.Dx)?f.Clipper.TopX(d,e.Y):f.Clipper.TopX(b,e.Y))}};f.Clipper.prototype.ProcessEdgesAtTopOfScanbeam= -function(b){for(var d=this.m_ActiveEdges;null!==d;){var e=this.IsMaxima(d,b);e&&(e=this.GetMaximaPair(d),e=null===e||!f.ClipperBase.IsHorizontal(e));if(e){var q=d.PrevInAEL;this.DoMaxima(d);d=null===q?this.m_ActiveEdges:q.NextInAEL}else{this.IsIntermediate(d,b)&&f.ClipperBase.IsHorizontal(d.NextInLML)?(d=this.UpdateEdgeIntoAEL(d),0<=d.OutIdx&&this.AddOutPt(d,d.Bot),this.AddEdgeToSEL(d)):(d.Curr.X=f.Clipper.TopX(d,b),d.Curr.Y=b);if(this.StrictlySimple&&(q=d.PrevInAEL,0<=d.OutIdx&&0!==d.WindDelta&& -null!==q&&0<=q.OutIdx&&q.Curr.X==d.Curr.X&&0!==q.WindDelta)){var n=new f.IntPoint(d.Curr);f.use_xyz&&this.SetZ(n,q,d);e=this.AddOutPt(q,n);q=this.AddOutPt(d,n);this.AddJoin(e,q,n)}d=d.NextInAEL}}this.ProcessHorizontals(!0);for(d=this.m_ActiveEdges;null!==d;)this.IsIntermediate(d,b)&&(e=null,0<=d.OutIdx&&(e=this.AddOutPt(d,d.Top)),d=this.UpdateEdgeIntoAEL(d),q=d.PrevInAEL,n=d.NextInAEL,null!==q&&q.Curr.X==d.Bot.X&&q.Curr.Y==d.Bot.Y&&null!==e&&0<=q.OutIdx&&q.Curr.Y>q.Top.Y&&f.ClipperBase.SlopesEqual(d, -q,this.m_UseFullRange)&&0!==d.WindDelta&&0!==q.WindDelta?(q=this.AddOutPt(q,d.Bot),this.AddJoin(e,q,d.Top)):null!==n&&n.Curr.X==d.Bot.X&&n.Curr.Y==d.Bot.Y&&null!==e&&0<=n.OutIdx&&n.Curr.Y>n.Top.Y&&f.ClipperBase.SlopesEqual(d,n,this.m_UseFullRange)&&0!==d.WindDelta&&0!==n.WindDelta&&(q=this.AddOutPt(n,d.Bot),this.AddJoin(e,q,d.Top))),d=d.NextInAEL};f.Clipper.prototype.DoMaxima=function(b){var d=this.GetMaximaPair(b);if(null===d)0<=b.OutIdx&&this.AddOutPt(b,b.Top),this.DeleteFromAEL(b);else{for(var e= -b.NextInAEL;null!==e&&e!=d;)this.IntersectEdges(b,e,b.Top),this.SwapPositionsInAEL(b,e),e=b.NextInAEL;-1==b.OutIdx&&-1==d.OutIdx?(this.DeleteFromAEL(b),this.DeleteFromAEL(d)):0<=b.OutIdx&&0<=d.OutIdx?(0<=b.OutIdx&&this.AddLocalMaxPoly(b,d,b.Top),this.DeleteFromAEL(b),this.DeleteFromAEL(d)):f.use_lines&&0===b.WindDelta?(0<=b.OutIdx&&(this.AddOutPt(b,b.Top),b.OutIdx=-1),this.DeleteFromAEL(b),0<=d.OutIdx&&(this.AddOutPt(d,b.Top),d.OutIdx=-1),this.DeleteFromAEL(d)):f.Error("DoMaxima error")}};f.Clipper.ReversePaths= -function(b){for(var d=0,e=b.length;d<e;d++)b[d].reverse()};f.Clipper.Orientation=function(b){return 0<=f.Clipper.Area(b)};f.Clipper.prototype.PointCount=function(b){if(null===b)return 0;var d=0,e=b;do d++,e=e.Next;while(e!=b);return d};f.Clipper.prototype.BuildResult=function(b){f.Clear(b);for(var d=0,e=this.m_PolyOuts.length;d<e;d++){var q=this.m_PolyOuts[d];if(null!==q.Pts){var q=q.Pts.Prev,n=this.PointCount(q);if(!(2>n)){for(var k=Array(n),v=0;v<n;v++)k[v]=q.Pt,q=q.Prev;b.push(k)}}}};f.Clipper.prototype.BuildResult2= -function(b){b.Clear();for(var d=0,e=this.m_PolyOuts.length;d<e;d++){var q=this.m_PolyOuts[d],n=this.PointCount(q.Pts);if(!(q.IsOpen&&2>n||!q.IsOpen&&3>n)){this.FixHoleLinkage(q);var k=new f.PolyNode;b.m_AllPolys.push(k);q.PolyNode=k;k.m_polygon.length=n;for(var q=q.Pts.Prev,v=0;v<n;v++)k.m_polygon[v]=q.Pt,q=q.Prev}}d=0;for(e=this.m_PolyOuts.length;d<e;d++)q=this.m_PolyOuts[d],null!==q.PolyNode&&(q.IsOpen?(q.PolyNode.IsOpen=!0,b.AddChild(q.PolyNode)):null!==q.FirstLeft&&null!=q.FirstLeft.PolyNode? -q.FirstLeft.PolyNode.AddChild(q.PolyNode):b.AddChild(q.PolyNode))};f.Clipper.prototype.FixupOutPolygon=function(b){var d=null;b.BottomPt=null;for(var e=b.Pts;;){if(e.Prev==e||e.Prev==e.Next){b.Pts=null;return}if(f.IntPoint.op_Equality(e.Pt,e.Next.Pt)||f.IntPoint.op_Equality(e.Pt,e.Prev.Pt)||f.ClipperBase.SlopesEqual(e.Prev.Pt,e.Pt,e.Next.Pt,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(e.Prev.Pt,e.Pt,e.Next.Pt)))d=null,e.Prev.Next=e.Next,e=e.Next.Prev=e.Prev;else if(e== -d)break;else null===d&&(d=e),e=e.Next}b.Pts=e};f.Clipper.prototype.DupOutPt=function(b,d){var e=new f.OutPt;e.Pt.X=b.Pt.X;e.Pt.Y=b.Pt.Y;f.use_xyz&&(e.Pt.Z=b.Pt.Z);e.Idx=b.Idx;d?(e.Next=b.Next,e.Prev=b,b.Next.Prev=e,b.Next=e):(e.Prev=b.Prev,e.Next=b,b.Prev.Next=e,b.Prev=e);return e};f.Clipper.prototype.GetOverlap=function(b,d,e,f,n){b<d?e<f?(n.Left=Math.max(b,e),n.Right=Math.min(d,f)):(n.Left=Math.max(b,f),n.Right=Math.min(d,e)):e<f?(n.Left=Math.max(d,e),n.Right=Math.min(b,f)):(n.Left=Math.max(d,f), -n.Right=Math.min(b,e));return n.Left<n.Right};f.Clipper.prototype.JoinHorz=function(b,d,e,q,n,k){var v=b.Pt.X>d.Pt.X?f.Direction.dRightToLeft:f.Direction.dLeftToRight;q=e.Pt.X>q.Pt.X?f.Direction.dRightToLeft:f.Direction.dLeftToRight;if(v==q)return!1;if(v==f.Direction.dLeftToRight){for(;b.Next.Pt.X<=n.X&&b.Next.Pt.X>=b.Pt.X&&b.Next.Pt.Y==n.Y;)b=b.Next;k&&b.Pt.X!=n.X&&(b=b.Next);d=this.DupOutPt(b,!k);f.IntPoint.op_Inequality(d.Pt,n)&&(b=d,b.Pt.X=n.X,b.Pt.Y=n.Y,f.use_xyz&&(b.Pt.Z=n.Z),d=this.DupOutPt(b, -!k))}else{for(;b.Next.Pt.X>=n.X&&b.Next.Pt.X<=b.Pt.X&&b.Next.Pt.Y==n.Y;)b=b.Next;k||b.Pt.X==n.X||(b=b.Next);d=this.DupOutPt(b,k);f.IntPoint.op_Inequality(d.Pt,n)&&(b=d,b.Pt.X=n.X,b.Pt.Y=n.Y,f.use_xyz&&(b.Pt.Z=n.Z),d=this.DupOutPt(b,k))}if(q==f.Direction.dLeftToRight){for(;e.Next.Pt.X<=n.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y==n.Y;)e=e.Next;k&&e.Pt.X!=n.X&&(e=e.Next);q=this.DupOutPt(e,!k);f.IntPoint.op_Inequality(q.Pt,n)&&(e=q,e.Pt.X=n.X,e.Pt.Y=n.Y,f.use_xyz&&(e.Pt.Z=n.Z),q=this.DupOutPt(e,!k))}else{for(;e.Next.Pt.X>= -n.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y==n.Y;)e=e.Next;k||e.Pt.X==n.X||(e=e.Next);q=this.DupOutPt(e,k);f.IntPoint.op_Inequality(q.Pt,n)&&(e=q,e.Pt.X=n.X,e.Pt.Y=n.Y,f.use_xyz&&(e.Pt.Z=n.Z),q=this.DupOutPt(e,k))}v==f.Direction.dLeftToRight==k?(b.Prev=e,e.Next=b,d.Next=q,q.Prev=d):(b.Next=e,e.Prev=b,d.Prev=q,q.Next=d);return!0};f.Clipper.prototype.JoinPoints=function(b,d,e){var q=b.OutPt1,n;new f.OutPt;var k=b.OutPt2,v;new f.OutPt;if((v=b.OutPt1.Pt.Y==b.OffPt.Y)&&f.IntPoint.op_Equality(b.OffPt,b.OutPt1.Pt)&& -f.IntPoint.op_Equality(b.OffPt,b.OutPt2.Pt)){if(d!=e)return!1;for(n=b.OutPt1.Next;n!=q&&f.IntPoint.op_Equality(n.Pt,b.OffPt);)n=n.Next;n=n.Pt.Y>b.OffPt.Y;for(v=b.OutPt2.Next;v!=k&&f.IntPoint.op_Equality(v.Pt,b.OffPt);)v=v.Next;if(n==v.Pt.Y>b.OffPt.Y)return!1;n?(n=this.DupOutPt(q,!1),v=this.DupOutPt(k,!0),q.Prev=k,k.Next=q,n.Next=v,v.Prev=n):(n=this.DupOutPt(q,!0),v=this.DupOutPt(k,!1),q.Next=k,k.Prev=q,n.Prev=v,v.Next=n);b.OutPt1=q;b.OutPt2=n;return!0}if(v){for(n=q;q.Prev.Pt.Y==q.Pt.Y&&q.Prev!=n&& -q.Prev!=k;)q=q.Prev;for(;n.Next.Pt.Y==n.Pt.Y&&n.Next!=q&&n.Next!=k;)n=n.Next;if(n.Next==q||n.Next==k)return!1;for(v=k;k.Prev.Pt.Y==k.Pt.Y&&k.Prev!=v&&k.Prev!=n;)k=k.Prev;for(;v.Next.Pt.Y==v.Pt.Y&&v.Next!=k&&v.Next!=q;)v=v.Next;if(v.Next==k||v.Next==q)return!1;e={Left:null,Right:null};if(!this.GetOverlap(q.Pt.X,n.Pt.X,k.Pt.X,v.Pt.X,e))return!1;d=e.Left;var C=e.Right;e=new f.IntPoint;q.Pt.X>=d&&q.Pt.X<=C?(e.X=q.Pt.X,e.Y=q.Pt.Y,f.use_xyz&&(e.Z=q.Pt.Z),d=q.Pt.X>n.Pt.X):k.Pt.X>=d&&k.Pt.X<=C?(e.X=k.Pt.X, -e.Y=k.Pt.Y,f.use_xyz&&(e.Z=k.Pt.Z),d=k.Pt.X>v.Pt.X):n.Pt.X>=d&&n.Pt.X<=C?(e.X=n.Pt.X,e.Y=n.Pt.Y,f.use_xyz&&(e.Z=n.Pt.Z),d=n.Pt.X>q.Pt.X):(e.X=v.Pt.X,e.Y=v.Pt.Y,f.use_xyz&&(e.Z=v.Pt.Z),d=v.Pt.X>k.Pt.X);b.OutPt1=q;b.OutPt2=k;return this.JoinHorz(q,n,k,v,e,d)}for(n=q.Next;f.IntPoint.op_Equality(n.Pt,q.Pt)&&n!=q;)n=n.Next;if(C=n.Pt.Y>q.Pt.Y||!f.ClipperBase.SlopesEqual(q.Pt,n.Pt,b.OffPt,this.m_UseFullRange)){for(n=q.Prev;f.IntPoint.op_Equality(n.Pt,q.Pt)&&n!=q;)n=n.Prev;if(n.Pt.Y>q.Pt.Y||!f.ClipperBase.SlopesEqual(q.Pt, -n.Pt,b.OffPt,this.m_UseFullRange))return!1}for(v=k.Next;f.IntPoint.op_Equality(v.Pt,k.Pt)&&v!=k;)v=v.Next;var p=v.Pt.Y>k.Pt.Y||!f.ClipperBase.SlopesEqual(k.Pt,v.Pt,b.OffPt,this.m_UseFullRange);if(p){for(v=k.Prev;f.IntPoint.op_Equality(v.Pt,k.Pt)&&v!=k;)v=v.Prev;if(v.Pt.Y>k.Pt.Y||!f.ClipperBase.SlopesEqual(k.Pt,v.Pt,b.OffPt,this.m_UseFullRange))return!1}if(n==q||v==k||n==v||d==e&&C==p)return!1;C?(n=this.DupOutPt(q,!1),v=this.DupOutPt(k,!0),q.Prev=k,k.Next=q,n.Next=v,v.Prev=n):(n=this.DupOutPt(q,!0), -v=this.DupOutPt(k,!1),q.Next=k,k.Prev=q,n.Prev=v,v.Next=n);b.OutPt1=q;b.OutPt2=n;return!0};f.Clipper.GetBounds=function(b){for(var d=0,e=b.length;d<e&&0==b[d].length;)d++;if(d==e)return new f.IntRect(0,0,0,0);var q=new f.IntRect;q.left=b[d][0].X;q.right=q.left;q.top=b[d][0].Y;for(q.bottom=q.top;d<e;d++)for(var k=0,N=b[d].length;k<N;k++)b[d][k].X<q.left?q.left=b[d][k].X:b[d][k].X>q.right&&(q.right=b[d][k].X),b[d][k].Y<q.top?q.top=b[d][k].Y:b[d][k].Y>q.bottom&&(q.bottom=b[d][k].Y);return q};f.Clipper.prototype.GetBounds2= -function(b){var d=b,e=new f.IntRect;e.left=b.Pt.X;e.right=b.Pt.X;e.top=b.Pt.Y;e.bottom=b.Pt.Y;for(b=b.Next;b!=d;)b.Pt.X<e.left&&(e.left=b.Pt.X),b.Pt.X>e.right&&(e.right=b.Pt.X),b.Pt.Y<e.top&&(e.top=b.Pt.Y),b.Pt.Y>e.bottom&&(e.bottom=b.Pt.Y),b=b.Next;return e};f.Clipper.PointInPolygon=function(b,d){var e=0,f=d.length;if(3>f)return 0;for(var k=d[0],N=1;N<=f;++N){var v=N==f?d[0]:d[N];if(v.Y==b.Y&&(v.X==b.X||k.Y==b.Y&&v.X>b.X==k.X<b.X))return-1;if(k.Y<b.Y!=v.Y<b.Y)if(k.X>=b.X)if(v.X>b.X)e=1-e;else{var C= -(k.X-b.X)*(v.Y-b.Y)-(v.X-b.X)*(k.Y-b.Y);if(0==C)return-1;0<C==v.Y>k.Y&&(e=1-e)}else if(v.X>b.X){C=(k.X-b.X)*(v.Y-b.Y)-(v.X-b.X)*(k.Y-b.Y);if(0==C)return-1;0<C==v.Y>k.Y&&(e=1-e)}k=v}return e};f.Clipper.prototype.PointInPolygon=function(b,d){var e=0,f=d,k=b.X,N=b.Y,v=d.Pt.X,C=d.Pt.Y;do{d=d.Next;var p=d.Pt.X,F=d.Pt.Y;if(F==N&&(p==k||C==N&&p>k==v<k))return-1;if(C<N!=F<N)if(v>=k)if(p>k)e=1-e;else{v=(v-k)*(F-N)-(p-k)*(C-N);if(0==v)return-1;0<v==F>C&&(e=1-e)}else if(p>k){v=(v-k)*(F-N)-(p-k)*(C-N);if(0== -v)return-1;0<v==F>C&&(e=1-e)}v=p;C=F}while(f!=d);return e};f.Clipper.prototype.Poly2ContainsPoly1=function(b,d){var e=b;do{var f=this.PointInPolygon(e.Pt,d);if(0<=f)return 0<f;e=e.Next}while(e!=b);return!0};f.Clipper.prototype.FixupFirstLefts1=function(b,d){for(var e=0,f=this.m_PolyOuts.length;e<f;e++){var k=this.m_PolyOuts[e];null!=k.Pts&&null!=k.FirstLeft&&this.ParseFirstLeft(k.FirstLeft)==b&&this.Poly2ContainsPoly1(k.Pts,d.Pts)&&(k.FirstLeft=d)}};f.Clipper.prototype.FixupFirstLefts2=function(b, -d){for(var e=0,f=this.m_PolyOuts,k=f.length,p=f[e];e<k;e++,p=f[e])p.FirstLeft==b&&(p.FirstLeft=d)};f.Clipper.ParseFirstLeft=function(b){for(;null!=b&&null==b.Pts;)b=b.FirstLeft;return b};f.Clipper.prototype.JoinCommonEdges=function(){for(var b=0,d=this.m_Joins.length;b<d;b++){var e=this.m_Joins[b],k=this.GetOutRec(e.OutPt1.Idx),n=this.GetOutRec(e.OutPt2.Idx);if(null!=k.Pts&&null!=n.Pts){var p;p=k==n?k:this.Param1RightOfParam2(k,n)?n:this.Param1RightOfParam2(n,k)?k:this.GetLowermostRec(k,n);if(this.JoinPoints(e, -k,n))if(k==n){k.Pts=e.OutPt1;k.BottomPt=null;n=this.CreateOutRec();n.Pts=e.OutPt2;this.UpdateOutPtIdxs(n);if(this.m_UsingPolyTree){p=0;for(var v=this.m_PolyOuts.length;p<v-1;p++){var C=this.m_PolyOuts[p];null!=C.Pts&&f.Clipper.ParseFirstLeft(C.FirstLeft)==k&&C.IsHole!=k.IsHole&&this.Poly2ContainsPoly1(C.Pts,e.OutPt2)&&(C.FirstLeft=n)}}this.Poly2ContainsPoly1(n.Pts,k.Pts)?(n.IsHole=!k.IsHole,n.FirstLeft=k,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,k),(n.IsHole^this.ReverseSolution)==0<this.Area(n)&& -this.ReversePolyPtLinks(n.Pts)):this.Poly2ContainsPoly1(k.Pts,n.Pts)?(n.IsHole=k.IsHole,k.IsHole=!n.IsHole,n.FirstLeft=k.FirstLeft,k.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(k,n),(k.IsHole^this.ReverseSolution)==0<this.Area(k)&&this.ReversePolyPtLinks(k.Pts)):(n.IsHole=k.IsHole,n.FirstLeft=k.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(k,n))}else n.Pts=null,n.BottomPt=null,n.Idx=k.Idx,k.IsHole=p.IsHole,p==n&&(k.FirstLeft=n.FirstLeft),n.FirstLeft=k,this.m_UsingPolyTree&&this.FixupFirstLefts2(n, -k)}}};f.Clipper.prototype.UpdateOutPtIdxs=function(b){var d=b.Pts;do d.Idx=b.Idx,d=d.Prev;while(d!=b.Pts)};f.Clipper.prototype.DoSimplePolygons=function(){for(var b=0;b<this.m_PolyOuts.length;){var d=this.m_PolyOuts[b++],e=d.Pts;if(null!=e&&!d.IsOpen){do{for(var k=e.Next;k!=d.Pts;){if(f.IntPoint.op_Equality(e.Pt,k.Pt)&&k.Next!=e&&k.Prev!=e){var n=e.Prev,p=k.Prev;e.Prev=p;p.Next=e;k.Prev=n;n.Next=k;d.Pts=e;n=this.CreateOutRec();n.Pts=k;this.UpdateOutPtIdxs(n);this.Poly2ContainsPoly1(n.Pts,d.Pts)?(n.IsHole= -!d.IsHole,n.FirstLeft=d,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,d)):this.Poly2ContainsPoly1(d.Pts,n.Pts)?(n.IsHole=d.IsHole,d.IsHole=!n.IsHole,n.FirstLeft=d.FirstLeft,d.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(d,n)):(n.IsHole=d.IsHole,n.FirstLeft=d.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(d,n));k=e}k=k.Next}e=e.Next}while(e!=d.Pts)}}};f.Clipper.Area=function(b){var d=b.length;if(3>d)return 0;for(var e=0,f=0,k=d-1;f<d;++f)e+=(b[k].X+b[f].X)*(b[k].Y-b[f].Y),k=f;return.5* --e};f.Clipper.prototype.Area=function(b){var d=b.Pts;if(null==d)return 0;var e=0;do e+=(d.Prev.Pt.X+d.Pt.X)*(d.Prev.Pt.Y-d.Pt.Y),d=d.Next;while(d!=b.Pts);return.5*e};f.Clipper.SimplifyPolygon=function(b,d){var e=[],k=new f.Clipper(0);k.StrictlySimple=!0;k.AddPath(b,f.PolyType.ptSubject,!0);k.Execute(f.ClipType.ctUnion,e,d,d);return e};f.Clipper.SimplifyPolygons=function(b,d){"undefined"==typeof d&&(d=f.PolyFillType.pftEvenOdd);var e=[],k=new f.Clipper(0);k.StrictlySimple=!0;k.AddPaths(b,f.PolyType.ptSubject, -!0);k.Execute(f.ClipType.ctUnion,e,d,d);return e};f.Clipper.DistanceSqrd=function(b,d){var e=b.X-d.X,f=b.Y-d.Y;return e*e+f*f};f.Clipper.DistanceFromLineSqrd=function(b,d,e){var f=d.Y-e.Y;e=e.X-d.X;d=f*d.X+e*d.Y;d=f*b.X+e*b.Y-d;return d*d/(f*f+e*e)};f.Clipper.SlopesNearCollinear=function(b,d,e,k){return Math.abs(b.X-d.X)>Math.abs(b.Y-d.Y)?b.X>d.X==b.X<e.X?f.Clipper.DistanceFromLineSqrd(b,d,e)<k:d.X>b.X==d.X<e.X?f.Clipper.DistanceFromLineSqrd(d,b,e)<k:f.Clipper.DistanceFromLineSqrd(e,b,d)<k:b.Y>d.Y== -b.Y<e.Y?f.Clipper.DistanceFromLineSqrd(b,d,e)<k:d.Y>b.Y==d.Y<e.Y?f.Clipper.DistanceFromLineSqrd(d,b,e)<k:f.Clipper.DistanceFromLineSqrd(e,b,d)<k};f.Clipper.PointsAreClose=function(b,d,e){var f=b.X-d.X;b=b.Y-d.Y;return f*f+b*b<=e};f.Clipper.ExcludeOp=function(b){var d=b.Prev;d.Next=b.Next;b.Next.Prev=d;d.Idx=0;return d};f.Clipper.CleanPolygon=function(b,d){"undefined"==typeof d&&(d=1.415);var e=b.length;if(0==e)return[];for(var k=Array(e),n=0;n<e;++n)k[n]=new f.OutPt;for(n=0;n<e;++n)k[n].Pt=b[n],k[n].Next= -k[(n+1)%e],k[n].Next.Prev=k[n],k[n].Idx=0;n=d*d;for(k=k[0];0==k.Idx&&k.Next!=k.Prev;)f.Clipper.PointsAreClose(k.Pt,k.Prev.Pt,n)?(k=f.Clipper.ExcludeOp(k),e--):f.Clipper.PointsAreClose(k.Prev.Pt,k.Next.Pt,n)?(f.Clipper.ExcludeOp(k.Next),k=f.Clipper.ExcludeOp(k),e-=2):f.Clipper.SlopesNearCollinear(k.Prev.Pt,k.Pt,k.Next.Pt,n)?(k=f.Clipper.ExcludeOp(k),e--):(k.Idx=1,k=k.Next);3>e&&(e=0);for(var p=Array(e),n=0;n<e;++n)p[n]=new f.IntPoint(k.Pt),k=k.Next;return p};f.Clipper.CleanPolygons=function(b,d){for(var e= -Array(b.length),k=0,n=b.length;k<n;k++)e[k]=f.Clipper.CleanPolygon(b[k],d);return e};f.Clipper.Minkowski=function(b,d,e,k){k=k?1:0;var n=b.length,p=d.length,v=[];if(e)for(e=0;e<p;e++){for(var C=Array(n),F=0,E=b.length,H=b[F];F<E;F++,H=b[F])C[F]=new f.IntPoint(d[e].X+H.X,d[e].Y+H.Y);v.push(C)}else for(e=0;e<p;e++){C=Array(n);F=0;E=b.length;for(H=b[F];F<E;F++,H=b[F])C[F]=new f.IntPoint(d[e].X-H.X,d[e].Y-H.Y);v.push(C)}b=[];for(e=0;e<p-1+k;e++)for(F=0;F<n;F++)d=[],d.push(v[e%p][F%n]),d.push(v[(e+1)% -p][F%n]),d.push(v[(e+1)%p][(F+1)%n]),d.push(v[e%p][(F+1)%n]),f.Clipper.Orientation(d)||d.reverse(),b.push(d);return b};f.Clipper.MinkowskiSum=function(b,d,e){if(d[0]instanceof Array){v=d;d=new f.Paths;for(var k=new f.Clipper,n=0;n<v.length;++n){var p=f.Clipper.Minkowski(b,v[n],!0,e);k.AddPaths(p,f.PolyType.ptSubject,!0);e&&(p=f.Clipper.TranslatePath(v[n],b[0]),k.AddPath(p,f.PolyType.ptClip,!0))}k.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftNonZero,f.PolyFillType.pftNonZero);return d}var v=f.Clipper.Minkowski(b, -d,!0,e),k=new f.Clipper;k.AddPaths(v,f.PolyType.ptSubject,!0);k.Execute(f.ClipType.ctUnion,v,f.PolyFillType.pftNonZero,f.PolyFillType.pftNonZero);return v};f.Clipper.TranslatePath=function(b,d){for(var e=new f.Path,k=0;k<b.length;k++)e.push(new f.IntPoint(b[k].X+d.X,b[k].Y+d.Y));return e};f.Clipper.MinkowskiDiff=function(b,d){var e=f.Clipper.Minkowski(b,d,!1,!0),k=new f.Clipper;k.AddPaths(e,f.PolyType.ptSubject,!0);k.Execute(f.ClipType.ctUnion,e,f.PolyFillType.pftNonZero,f.PolyFillType.pftNonZero); -return e};f.Clipper.PolyTreeToPaths=function(b){var d=[];f.Clipper.AddPolyNodeToPaths(b,f.Clipper.NodeType.ntAny,d);return d};f.Clipper.AddPolyNodeToPaths=function(b,d,e){var k=!0;switch(d){case f.Clipper.NodeType.ntOpen:return;case f.Clipper.NodeType.ntClosed:k=!b.IsOpen}0<b.m_polygon.length&&k&&e.push(b.m_polygon);k=0;b=b.Childs();for(var n=b.length,p=b[k];k<n;k++,p=b[k])f.Clipper.AddPolyNodeToPaths(p,d,e)};f.Clipper.OpenPathsFromPolyTree=function(b){for(var d=new f.Paths,e=0,k=b.ChildCount();e< -k;e++)b.Childs()[e].IsOpen&&d.push(b.Childs()[e].m_polygon);return d};f.Clipper.ClosedPathsFromPolyTree=function(b){var d=new f.Paths;f.Clipper.AddPolyNodeToPaths(b,f.Clipper.NodeType.ntClosed,d);return d};V(f.Clipper,f.ClipperBase);f.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2};f.ClipperOffset=function(b,d){"undefined"==typeof b&&(b=2);"undefined"==typeof d&&(d=f.ClipperOffset.def_arc_tolerance);this.m_destPolys=new f.Paths;this.m_srcPoly=new f.Path;this.m_destPoly=new f.Path;this.m_normals=[]; -this.m_StepsPerRad=this.m_miterLim=this.m_cos=this.m_sin=this.m_sinA=this.m_delta=0;this.m_lowest=new f.IntPoint;this.m_polyNodes=new f.PolyNode;this.MiterLimit=b;this.ArcTolerance=d;this.m_lowest.X=-1};f.ClipperOffset.two_pi=6.28318530717959;f.ClipperOffset.def_arc_tolerance=.25;f.ClipperOffset.prototype.Clear=function(){f.Clear(this.m_polyNodes.Childs());this.m_lowest.X=-1};f.ClipperOffset.Round=f.Clipper.Round;f.ClipperOffset.prototype.AddPath=function(b,d,e){var k=b.length-1;if(!(0>k)){var n= -new f.PolyNode;n.m_jointype=d;n.m_endtype=e;if(e==f.EndType.etClosedLine||e==f.EndType.etClosedPolygon)for(;0<k&&f.IntPoint.op_Equality(b[0],b[k]);)k--;n.m_polygon.push(b[0]);var p=0;d=0;for(var v=1;v<=k;v++)f.IntPoint.op_Inequality(n.m_polygon[p],b[v])&&(p++,n.m_polygon.push(b[v]),b[v].Y>n.m_polygon[d].Y||b[v].Y==n.m_polygon[d].Y&&b[v].X<n.m_polygon[d].X)&&(d=p);if(!(e==f.EndType.etClosedPolygon&&2>p)&&(this.m_polyNodes.AddChild(n),e==f.EndType.etClosedPolygon))if(0>this.m_lowest.X)this.m_lowest= -new f.IntPoint(this.m_polyNodes.ChildCount()-1,d);else if(b=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y],n.m_polygon[d].Y>b.Y||n.m_polygon[d].Y==b.Y&&n.m_polygon[d].X<b.X)this.m_lowest=new f.IntPoint(this.m_polyNodes.ChildCount()-1,d)}};f.ClipperOffset.prototype.AddPaths=function(b,d,e){for(var f=0,k=b.length;f<k;f++)this.AddPath(b[f],d,e)};f.ClipperOffset.prototype.FixOrientations=function(){if(0<=this.m_lowest.X&&!f.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var b= -0;b<this.m_polyNodes.ChildCount();b++){var d=this.m_polyNodes.Childs()[b];(d.m_endtype==f.EndType.etClosedPolygon||d.m_endtype==f.EndType.etClosedLine&&f.Clipper.Orientation(d.m_polygon))&&d.m_polygon.reverse()}else for(b=0;b<this.m_polyNodes.ChildCount();b++)d=this.m_polyNodes.Childs()[b],d.m_endtype!=f.EndType.etClosedLine||f.Clipper.Orientation(d.m_polygon)||d.m_polygon.reverse()};f.ClipperOffset.GetUnitNormal=function(b,d){var e=d.X-b.X,k=d.Y-b.Y;if(0==e&&0==k)return new f.DoublePoint(0,0);var n= -1/Math.sqrt(e*e+k*k);return new f.DoublePoint(k*n,-(e*n))};f.ClipperOffset.prototype.DoOffset=function(b){this.m_destPolys=[];this.m_delta=b;if(f.ClipperBase.near_zero(b))for(var d=0;d<this.m_polyNodes.ChildCount();d++){var e=this.m_polyNodes.Childs()[d];e.m_endtype==f.EndType.etClosedPolygon&&this.m_destPolys.push(e.m_polygon)}else{this.m_miterLim=2<this.MiterLimit?2/(this.MiterLimit*this.MiterLimit):.5;var k=3.14159265358979/Math.acos(1-(0>=this.ArcTolerance?f.ClipperOffset.def_arc_tolerance:this.ArcTolerance> -Math.abs(b)*f.ClipperOffset.def_arc_tolerance?Math.abs(b)*f.ClipperOffset.def_arc_tolerance:this.ArcTolerance)/Math.abs(b));this.m_sin=Math.sin(f.ClipperOffset.two_pi/k);this.m_cos=Math.cos(f.ClipperOffset.two_pi/k);this.m_StepsPerRad=k/f.ClipperOffset.two_pi;0>b&&(this.m_sin=-this.m_sin);for(d=0;d<this.m_polyNodes.ChildCount();d++){e=this.m_polyNodes.Childs()[d];this.m_srcPoly=e.m_polygon;var n=this.m_srcPoly.length;if(!(0==n||0>=b&&(3>n||e.m_endtype!=f.EndType.etClosedPolygon))){this.m_destPoly= -[];if(1==n)if(e.m_jointype==f.JoinType.jtRound)for(var e=1,n=0,p=1;p<=k;p++){this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+e*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+n*b)));var v=e,e=e*this.m_cos-this.m_sin*n,n=v*this.m_sin+n*this.m_cos}else for(n=e=-1,p=0;4>p;++p)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+e*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+n*b))),0>e?e=1:0>n?n=1:e=-1;else{for(p=this.m_normals.length=0;p<n-1;p++)this.m_normals.push(f.ClipperOffset.GetUnitNormal(this.m_srcPoly[p], -this.m_srcPoly[p+1]));e.m_endtype==f.EndType.etClosedLine||e.m_endtype==f.EndType.etClosedPolygon?this.m_normals.push(f.ClipperOffset.GetUnitNormal(this.m_srcPoly[n-1],this.m_srcPoly[0])):this.m_normals.push(new f.DoublePoint(this.m_normals[n-2]));if(e.m_endtype==f.EndType.etClosedPolygon)for(v=n-1,p=0;p<n;p++)v=this.OffsetPoint(p,v,e.m_jointype);else if(e.m_endtype==f.EndType.etClosedLine){v=n-1;for(p=0;p<n;p++)v=this.OffsetPoint(p,v,e.m_jointype);this.m_destPolys.push(this.m_destPoly);this.m_destPoly= -[];v=this.m_normals[n-1];for(p=n-1;0<p;p--)this.m_normals[p]=new f.DoublePoint(-this.m_normals[p-1].X,-this.m_normals[p-1].Y);this.m_normals[0]=new f.DoublePoint(-v.X,-v.Y);v=0;for(p=n-1;0<=p;p--)v=this.OffsetPoint(p,v,e.m_jointype)}else{v=0;for(p=1;p<n-1;++p)v=this.OffsetPoint(p,v,e.m_jointype);e.m_endtype==f.EndType.etOpenButt?(p=n-1,v=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[p].X+this.m_normals[p].X*b),f.ClipperOffset.Round(this.m_srcPoly[p].Y+this.m_normals[p].Y*b)),this.m_destPoly.push(v), -v=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[p].X-this.m_normals[p].X*b),f.ClipperOffset.Round(this.m_srcPoly[p].Y-this.m_normals[p].Y*b)),this.m_destPoly.push(v)):(p=n-1,v=n-2,this.m_sinA=0,this.m_normals[p]=new f.DoublePoint(-this.m_normals[p].X,-this.m_normals[p].Y),e.m_endtype==f.EndType.etOpenSquare?this.DoSquare(p,v):this.DoRound(p,v));for(p=n-1;0<p;p--)this.m_normals[p]=new f.DoublePoint(-this.m_normals[p-1].X,-this.m_normals[p-1].Y);this.m_normals[0]=new f.DoublePoint(-this.m_normals[1].X, --this.m_normals[1].Y);v=n-1;for(p=v-1;0<p;--p)v=this.OffsetPoint(p,v,e.m_jointype);e.m_endtype==f.EndType.etOpenButt?(v=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*b)),this.m_destPoly.push(v),v=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*b)),this.m_destPoly.push(v)):(this.m_sinA=0,e.m_endtype==f.EndType.etOpenSquare? -this.DoSquare(0,1):this.DoRound(0,1))}}this.m_destPolys.push(this.m_destPoly)}}}};f.ClipperOffset.prototype.Execute=function(){var b=arguments;if(b[0]instanceof f.PolyTree)if(d=b[0],e=b[1],d.Clear(),this.FixOrientations(),this.DoOffset(e),b=new f.Clipper(0),b.AddPaths(this.m_destPolys,f.PolyType.ptSubject,!0),0<e)b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftPositive,f.PolyFillType.pftPositive);else if(e=f.Clipper.GetBounds(this.m_destPolys),k=new f.Path,k.push(new f.IntPoint(e.left-10,e.bottom+ -10)),k.push(new f.IntPoint(e.right+10,e.bottom+10)),k.push(new f.IntPoint(e.right+10,e.top-10)),k.push(new f.IntPoint(e.left-10,e.top-10)),b.AddPath(k,f.PolyType.ptSubject,!0),b.ReverseSolution=!0,b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftNegative,f.PolyFillType.pftNegative),1==d.ChildCount()&&0<d.Childs()[0].ChildCount())for(b=d.Childs()[0],d.Childs()[0]=b.Childs()[0],d.Childs()[0].m_Parent=d,e=1;e<b.ChildCount();e++)d.AddChild(b.Childs()[e]);else d.Clear();else{var d=b[0],e=b[1];f.Clear(d); -this.FixOrientations();this.DoOffset(e);b=new f.Clipper(0);b.AddPaths(this.m_destPolys,f.PolyType.ptSubject,!0);if(0<e)b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftPositive,f.PolyFillType.pftPositive);else{var e=f.Clipper.GetBounds(this.m_destPolys),k=new f.Path;k.push(new f.IntPoint(e.left-10,e.bottom+10));k.push(new f.IntPoint(e.right+10,e.bottom+10));k.push(new f.IntPoint(e.right+10,e.top-10));k.push(new f.IntPoint(e.left-10,e.top-10));b.AddPath(k,f.PolyType.ptSubject,!0);b.ReverseSolution= -!0;b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftNegative,f.PolyFillType.pftNegative);0<d.length&&d.splice(0,1)}}};f.ClipperOffset.prototype.OffsetPoint=function(b,d,e){this.m_sinA=this.m_normals[d].X*this.m_normals[b].Y-this.m_normals[b].X*this.m_normals[d].Y;if(1>Math.abs(this.m_sinA*this.m_delta)){if(0<this.m_normals[d].X*this.m_normals[b].X+this.m_normals[b].Y*this.m_normals[d].Y)return this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[d].X*this.m_delta), -f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[d].Y*this.m_delta))),d}else 1<this.m_sinA?this.m_sinA=1:-1>this.m_sinA&&(this.m_sinA=-1);if(0>this.m_sinA*this.m_delta)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[d].X*this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[d].Y*this.m_delta))),this.m_destPoly.push(new f.IntPoint(this.m_srcPoly[b])),this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[b].X* -this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[b].Y*this.m_delta)));else switch(e){case f.JoinType.jtMiter:e=1+(this.m_normals[b].X*this.m_normals[d].X+this.m_normals[b].Y*this.m_normals[d].Y);e>=this.m_miterLim?this.DoMiter(b,d,e):this.DoSquare(b,d);break;case f.JoinType.jtSquare:this.DoSquare(b,d);break;case f.JoinType.jtRound:this.DoRound(b,d)}return b};f.ClipperOffset.prototype.DoSquare=function(b,d){var e=Math.tan(Math.atan2(this.m_sinA,this.m_normals[d].X*this.m_normals[b].X+ -this.m_normals[d].Y*this.m_normals[b].Y)/4);this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_delta*(this.m_normals[d].X-this.m_normals[d].Y*e)),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_delta*(this.m_normals[d].Y+this.m_normals[d].X*e))));this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_delta*(this.m_normals[b].X+this.m_normals[b].Y*e)),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_delta*(this.m_normals[b].Y-this.m_normals[b].X* -e))))};f.ClipperOffset.prototype.DoMiter=function(b,d,e){e=this.m_delta/e;this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+(this.m_normals[d].X+this.m_normals[b].X)*e),f.ClipperOffset.Round(this.m_srcPoly[b].Y+(this.m_normals[d].Y+this.m_normals[b].Y)*e)))};f.ClipperOffset.prototype.DoRound=function(b,d){for(var e=Math.max(f.Cast_Int32(f.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(Math.atan2(this.m_sinA,this.m_normals[d].X*this.m_normals[b].X+this.m_normals[d].Y*this.m_normals[b].Y)))), -1),k=this.m_normals[d].X,n=this.m_normals[d].Y,p,v=0;v<e;++v)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+k*this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+n*this.m_delta))),p=k,k=k*this.m_cos-this.m_sin*n,n=p*this.m_sin+n*this.m_cos;this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[b].X*this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[b].Y*this.m_delta)))};f.Error=function(b){try{throw Error(b); -}catch(d){alert(d.message)}};f.JS={};f.JS.AreaOfPolygon=function(b,d){d||(d=1);return f.Clipper.Area(b)/(d*d)};f.JS.AreaOfPolygons=function(b,d){d||(d=1);for(var e=0,k=0;k<b.length;k++)e+=f.Clipper.Area(b[k]);return e/(d*d)};f.JS.BoundsOfPath=function(b,d){return f.JS.BoundsOfPaths([b],d)};f.JS.BoundsOfPaths=function(b,d){d||(d=1);var e=f.Clipper.GetBounds(b);e.left/=d;e.bottom/=d;e.right/=d;e.top/=d;return e};f.JS.Clean=function(b,d){if(!(b instanceof Array))return[];var e=b[0]instanceof Array;b= -f.JS.Clone(b);if("number"!=typeof d||null===d)return f.Error("Delta is not a number in Clean()."),b;if(0===b.length||1==b.length&&0===b[0].length||0>d)return b;e||(b=[b]);for(var k=b.length,n,p,v,F,E,H,K,I=[],ea=0;ea<k;ea++)if(p=b[ea],n=p.length,0!==n)if(3>n)v=p,I.push(v);else{v=p;F=d*d;E=p[0];for(K=H=1;K<n;K++)(p[K].X-E.X)*(p[K].X-E.X)+(p[K].Y-E.Y)*(p[K].Y-E.Y)<=F||(v[H]=p[K],E=p[K],H++);E=p[H-1];(p[0].X-E.X)*(p[0].X-E.X)+(p[0].Y-E.Y)*(p[0].Y-E.Y)<=F&&H--;H<n&&v.splice(H,n-H);v.length&&I.push(v)}!e&& -I.length?I=I[0]:e||0!==I.length?e&&0===I.length&&(I=[[]]):I=[];return I};f.JS.Clone=function(b){if(!(b instanceof Array)||0===b.length)return[];if(1==b.length&&0===b[0].length)return[[]];var d=b[0]instanceof Array;d||(b=[b]);var e=b.length,f,k,p,v,F=Array(e);for(k=0;k<e;k++){f=b[k].length;v=Array(f);for(p=0;p<f;p++)v[p]={X:b[k][p].X,Y:b[k][p].Y};F[k]=v}d||(F=F[0]);return F};f.JS.Lighten=function(b,d){if(!(b instanceof Array))return[];if("number"!=typeof d||null===d)return f.Error("Tolerance is not a number in Lighten()."), -f.JS.Clone(b);if(0===b.length||1==b.length&&0===b[0].length||0>d)return f.JS.Clone(b);b[0]instanceof Array||(b=[b]);var e,k,n,p,v,F,E,H,K,I,ea,U,W,V,Y,Ea=b.length,ja=d*d,aa=[];for(e=0;e<Ea;e++)if(n=b[e],F=n.length,0!=F){for(p=0;1E6>p;p++){v=[];F=n.length;n[F-1].X!=n[0].X||n[F-1].Y!=n[0].Y?(ea=1,n.push({X:n[0].X,Y:n[0].Y}),F=n.length):ea=0;I=[];for(k=0;k<F-2;k++){E=n[k];K=n[k+1];H=n[k+2];V=E.X;Y=E.Y;E=H.X-V;U=H.Y-Y;if(0!==E||0!==U)W=((K.X-V)*E+(K.Y-Y)*U)/(E*E+U*U),1<W?(V=H.X,Y=H.Y):0<W&&(V+=E*W,Y+= -U*W);E=K.X-V;U=K.Y-Y;H=E*E+U*U;H<=ja&&(I[k+1]=1,k++)}v.push({X:n[0].X,Y:n[0].Y});for(k=1;k<F-1;k++)I[k]||v.push({X:n[k].X,Y:n[k].Y});v.push({X:n[F-1].X,Y:n[F-1].Y});ea&&n.pop();if(I.length)n=v;else break}F=v.length;v[F-1].X==v[0].X&&v[F-1].Y==v[0].Y&&v.pop();2<v.length&&aa.push(v)}b[0]instanceof Array||(aa=aa[0]);"undefined"==typeof aa&&(aa=[[]]);return aa};f.JS.PerimeterOfPath=function(b,d,e){if("undefined"==typeof b)return 0;var f=Math.sqrt,k=0,p,v,F,E,H=b.length;if(2>H)return 0;for(d&&(b[H]=b[0], -H++);--H;)p=b[H],F=p.X,p=p.Y,v=b[H-1],E=v.X,v=v.Y,k+=f((F-E)*(F-E)+(p-v)*(p-v));d&&b.pop();return k/e};f.JS.PerimeterOfPaths=function(b,d,e){e||(e=1);for(var k=0,n=0;n<b.length;n++)k+=f.JS.PerimeterOfPath(b[n],d,e);return k};f.JS.ScaleDownPath=function(b,d){var e,f;d||(d=1);for(e=b.length;e--;)f=b[e],f.X/=d,f.Y/=d};f.JS.ScaleDownPaths=function(b,d){var e,f,k;d||(d=1);for(e=b.length;e--;)for(f=b[e].length;f--;)k=b[e][f],k.X/=d,k.Y/=d};f.JS.ScaleUpPath=function(b,d){var e,f,k=Math.round;d||(d=1);for(e= -b.length;e--;)f=b[e],f.X=k(f.X*d),f.Y=k(f.Y*d)};f.JS.ScaleUpPaths=function(b,d){var e,f,k,p=Math.round;d||(d=1);for(e=b.length;e--;)for(f=b[e].length;f--;)k=b[e][f],k.X=p(k.X*d),k.Y=p(k.Y*d)};f.ExPolygons=function(){return[]};f.ExPolygon=function(){this.holes=this.outer=null};f.JS.AddOuterPolyNodeToExPolygons=function(b,d){var e=new f.ExPolygon;e.outer=b.Contour();var k=b.Childs(),n=k.length;e.holes=Array(n);var p,v,F,E,H;for(v=0;v<n;v++)for(p=k[v],e.holes[v]=p.Contour(),F=0,E=p.Childs(),H=E.length;F< -H;F++)p=E[F],f.JS.AddOuterPolyNodeToExPolygons(p,d);d.push(e)};f.JS.ExPolygonsToPaths=function(b){var d,e,k,n,p=new f.Paths;d=0;for(k=b.length;d<k;d++)for(p.push(b[d].outer),e=0,n=b[d].holes.length;e<n;e++)p.push(b[d].holes[e]);return p};f.JS.PolyTreeToExPolygons=function(b){var d=new f.ExPolygons,e,k,n;e=0;k=b.Childs();for(n=k.length;e<n;e++)b=k[e],f.JS.AddOuterPolyNodeToExPolygons(b,d);return d}})(); -var CindyJS=function(){function p(k){if(0===ja)return console.error("Waiting for "+k+" after we finished waiting."),function(){};0>ja&&(ja=0);++ja;return function(){--ja;0>ja&&console.error("Wait count mismatch: "+k);if(0===ja)for(var p=0,E=Ca.length;p<E;)Ca[p++].startup()}}function E(k){var p=E.newInstance(k);0>=ja?p.startup():!1!==k.autostart&&Ca.push(p);return p}var ja=-1,Ca=[];"undefined"===typeof document||"undefined"===typeof window||"undefined"===typeof document.addEventListener||"undefined"!== -typeof window.cindyDontWait&&!0===window.cindyDontWait||document.addEventListener("DOMContentLoaded",p("DOMContentLoaded"));var pa=null,Da=null,aa={};E.getBaseDir=function(){if(null!==pa)return pa;for(var k=document.getElementsByTagName("script"),p=0;p<k.length;++p){var E=k[p],U=E.src;if(U){var W=/Cindy\.js$/.exec(U);if(W)return pa=U.substr(0,W.index),console.log("Will load extensions from "+pa),Da=E,pa}}console.error("Could not find <script> tag for Cindy.js");return pa=Da=!1};E.addNewScript=function(k, -p){p||console.error.bind(console);var K=E.getBaseDir();if(!1===K)return!1;var U=document.createElement("script");U.src=K+k;var K=Da.nextSibling,W=Da.parentElement;K?W.insertBefore(U,K):W.appendChild(U);return U};E.loadScript=function(k,p,K,U){if(window[k])return K(),!0;U||(U=console.error.bind(console));var W=aa[k];if(!W){W=E.addNewScript(p,U);if(!1===W)return U("Can't load additional components."),!1;aa[k]=W}W.addEventListener("load",K);W.addEventListener("error",U);return null};E._autoLoadingPlugin= -{};E.autoLoadPlugin=function(k,p,K){if(E._pluginRegistry[k])return K(),!0;var U=E._autoLoadingPlugin[k];if(!U){p||(p=k+"-plugin.js");U=E._autoLoadingPlugin[k]=[];k=E.addNewScript(p);if(!1===k)return!1;k.addEventListener("error",console.error.bind(console))}U.push(K);return null};var k={ctype:"undefined"};E.waitFor=p;E._pluginRegistry={};E.instances=[];E.registerPlugin=function(k,p,K){if(1!==k)return console.error("Plugin API version "+k+" not supported"),!1;E._pluginRegistry[p]=K;(E._autoLoadingPlugin[p]|| -[]).forEach(function(k){k()})};var Oa=0;E.dumpState=function(k){k=E.instances[k||0].saveState();console.log(JSON.stringify(k))};E.debugState=function(k){E.instances.map(function(k){var p=k.config,p=JSON.parse(JSON.stringify(p)),F=k.saveState();console.log(JSON.stringify(F));for(var E in F)p[E]=F[E];k.shutdown();return p}).forEach(function(k){E(k)})};E.newInstance=function(p){function E(){ka.width=da=ka.clientWidth;ka.height=ca=ka.clientHeight;y.setTransform(1,0,0,1,0,0);z.setMat(25,0,0,25,250.5,250.5); -if(yb)for(var a=0;a<yb.length;a++){var h=yb[a],c=Object.keys(h)[0];"scale"===c&&(Kb=h.scale,z[c](h.scale));if("translate"===c)z[c](h.translate[0],h.translate[1]);"scaleAndOrigin"===c&&(Kb=h[c][0]/25,z[c].apply(null,h[c]));"visibleRect"===c&&(z[c].apply(null,h[c]),Kb=z.drawingstate.initialmatrix.a/25)}z.createnewbackup();z.greset();a=1;"undefined"!==typeof window&&window.devicePixelRatio&&(a=window.devicePixelRatio);h=y.webkitBackingStorePixelRatio||y.mozBackingStorePixelRatio||y.msBackingStorePixelRatio|| -y.oBackingStorePixelRatio||y.backingStorePixelRatio||1;a!==h&&(a/=h,ka.width=da*a,ka.height=ca*a,y.scale(a,a))}function K(a){var h;if("canvas"!==a.tagName.toLowerCase())for(h=a,ka=document.createElement("canvas");h.firstChild;)h.removeChild(h.firstChild);else{ka=a;h=document.createElement("div");var c=null,r=null;Array.prototype.slice.call(ka.attributes).forEach(function(a){"width"===a.name?c=a.value:"height"===a.name?r=a.value:h.setAttributeNodeNS(ka.removeAttributeNode(a))});null===c||h.style.width|| -(h.style.width=c+"px");null===r||h.style.height||(h.style.height=r+"px");ka.parentNode.replaceChild(h,ka)}h.classList.add("CindyJS-widget");a=ka.style;a.position="absolute";a.border="none";a.margin=a.padding=a.left=a.top="0px";a.width=a.height="100%";a="static";window.getComputedStyle&&(a=window.getComputedStyle(h).getPropertyValue("position"),a=String(a||"static"));"static"===a&&(h.style.position="relative");h.appendChild(ka);return ka}function U(){var a=p.cinderella;if(!a||!a.version)return!1;for(var h= -0;h<arguments.length;++h){var c=a.version[h],r=arguments[h];if(c!==r)return typeof c===typeof r&&c<r}return!1}function W(){ac=!0;if(0===Lb){if(p.exclusive)for(b=wa.instances.length;0<b;)wa.instances[--b].shutdown();void 0!==p.csconsole&&(ia=p.csconsole);ia=null===ia?new qa:!0===ia?new xb:"string"===typeof ia?new cb(ia):"object"===typeof ia&&"function"===typeof ia.appendChild?new cb(ia):new qa;ta=[100,100];var a=null;yb=p.transform;if(p.ports&&0<p.ports.length){b=p.ports[0];(a=b.element)||(a=document.getElementById(b.id)); -var a=K(a),h=a.parentNode.style;"window"===b.fill?(h.width="100vw",h.height="100vh"):"parent"===b.fill?(h.width="100%",h.height="100%"):b.width&&b.height&&(h.width=b.width+"px",h.height=b.height+"px");b.background&&(a.style.backgroundColor=b.background);void 0!==b.transform&&(yb=b.transform);Fa(b.grid)&&0<b.grid&&(Wa=b.grid);Fa(b.tgrid)&&0<b.tgrid&&(bc=b.tgrid);b.snap&&(cc=!0);b.axes&&(zb=!0)}a||(a=p.canvas,a||"undefined"===typeof document||(a=document.getElementById(p.canvasname))&&(a=K(a)));a&& -(ka=a,y=a.getContext("2d"),E(),y.setLineDash||(y.setLineDash=function(){}),(p.animation?p.animation.controls:p.animcontrols)&&ja(p),p.animation&&Fa(p.animation.speed)&&(void 0===p.animation.accuracy&&U(2,9,1875)?sa(.5*p.animation.speed):sa(p.animation.speed)),p.animation&&Fa(p.animation.accuracy)&&(Mb=p.animation.accuracy));p.statusbar&&(dc="string"===typeof p.statusbar?document.getElementById(p.statusbar):p.statusbar);var c=p.scripts,r=null;"string"===typeof c&&c.search(/\*/)&&(r=c);"object"!==typeof c&& -(c=null);"move keydown keyup keytyped keytype mousedown mouseup mousedrag mousemove mouseclick init tick draw simulationstep simulationstart simulationstop ondrop".split(" ").forEach(function(a){var h;if(null!==c&&c[a])h=c[a];else{h=a+"script";if(p[h])h=document.getElementById(p[h]);else if(r){if(h=document.getElementById(r.replace(/\*/,a)),!h)return}else return;h=h.text}h=Ra(h,!1);"error"===h.ctype?console.error("Error compiling "+a+" script: "+h.message):S[a]=h});U(2,9,1888)&&!S.keydown&&(S.keydown= -S.keytyped,S.keytyped=S.keytype,S.keytype=void 0);Fa(p.grid)&&0<p.grid&&(Wa=p.grid);p.snap&&(cc=!0);u={};var b=0;Xa={};p.geometry||(p.geometry=[]);Md(p.geometry);p.behavior||(p.behavior=[]);"function"===typeof ec&&ec(p.behavior);for(var d in p.images)b=aa(p.images[d],!1),b!==k&&(Xa[d]=b);for(var g in p.videos)d=aa(p.videos[g],!0),d!==k&&(Xa[g]=d);oa.canvas=a;if(p.oninit)p.oninit(oa);wa.instances.push(oa);p.use&&p.use.forEach(function(a){t.use$1([w.wrap(a)],{})});Nc.convexhull3d$1&&pa("QuickHull3D", -"QuickHull3D.js");V()}}function aa(a,h){var c;"string"===typeof a?(h?(c=document.createElement("video"),c.preload="auto",c.loop=!0,c.setAttribute("playsinline",""),enableInlineVideo(c)):c=new Image,c.src=a):c=a;if(!c.tagName)return console.error("Not a valid image element",c),k;var r={img:c,width:NaN,height:NaN,ready:!0,live:!1,generation:0,whenReady:f},b=c.tagName.toLowerCase(),d=[];if("img"===b)c.complete?(r.width=c.width,r.height=c.height):(r.ready=!1,c.addEventListener("load",function(){r.width= -c.width;r.height=c.height;r.ready=!0;r.whenReady=f;d.forEach(f);e()}),r.whenReady=d.push.bind(d));else if("video"===b)r.live=!0,c.readyState>=c.HAVE_METADATA?(r.width=c.videoWidth,r.height=c.videoHeight):(r.ready=!1,c.addEventListener("loadedmetadata",function(){r.width=c.videoWidth;r.height=c.videoHeight;r.ready=!0;r.whenReady=f;d.forEach(f);e()}),r.whenReady=d.push.bind(d));else if("canvas"===b)r.width=c.width,r.height=c.height;else return console.error("Not a valid image element",b,c),k;return{ctype:"image", -value:r}}function ja(a){function h(a,c){var h=document.createElement("button"),r=document.createElement("img");h.appendChild(r);l.appendChild(h);Ab(r,a);h.addEventListener("click",c);Sa[a]=function(a){a?h.classList.add("CindyJS-active"):h.classList.remove("CindyJS-active")}}function c(a){if(k){var c=e.getBoundingClientRect();sa(g*(a.clientX-c.left-e.clientLeft+.5)/c.width+b)}}var r=document.createElement("div");r.className="CindyJS-animcontrols";ka.parentNode.appendChild(r);var b=0,d=1,g=1;a.animation&& -a.animation.speedRange&&Fa(a.animation.speedRange[0])&&Fa(a.animation.speedRange[1])&&(b=a.animation.speedRange[0],d=a.animation.speedRange[1],g=d-b);var e=document.createElement("div");e.className="CindyJS-animspeed";r.appendChild(e);var f=document.createElement("div");e.appendChild(f);H(e,"mousedown",function(a){k=!0;c(a)});H(e,"mousemove",c);H(ka.parentNode,"mouseup",function(a){k=!1},!0);var l=document.createElement("div");l.className="CindyJS-animbuttons";r.appendChild(l);h("play",I);h("pause", -Ca);h("stop",Da);Sa.stop(!0);gc=function(a){a=(a-b)/g;a=Math.max(0,Math.min(1,a));a=.1*Math.round(1E3*a);f.style.width=a+"%"};var k=!1}function sa(a){Oc=a;gc&&gc(a)}function f(a){return a()}function pa(a,h){var c=null;p.plugins&&(c=p.plugins[a]);c||(c=wa._pluginRegistry[a]);c?t.use$1([w.wrap(a)],{}):(++Pc,wa.autoLoadPlugin(a,h,function(){t.use$1([w.wrap(a)],{});V()}))}function V(){0===--Pc&&(A(S.init),(p.animation||p).autoplay&&I(),oa.canvas&&Zb(oa.canvas,p))}function Y(){null!==Bb&&(ma.set(Bb.state), -Object.keys(Bb.speeds).forEach(function(a){var h=u.csnames[a];"undefined"!==typeof h.behavior&&(a=Bb.speeds[a],h.behavior.vx=a[0],h.behavior.vy=a[1],h.behavior.vz=a[2],h.behavior.fx=0,h.behavior.fy=0,h.behavior.fz=0)}),Nd())}function I(){if(!Ya){if(Ob){var a=db.backup;a.set(ma);for(var h={},c=0;c<u.points.length;c++){var r=u.points[c];"undefined"!==typeof r.behavior&&(h[r.name]=[r.behavior.vx,r.behavior.vy,r.behavior.vz])}Bb={state:a,speeds:h};Cb=0;Ob=!1;Sa.stop(!1)}else Sa.pause(!1);hc=Date.now(); -Sa.play(!0);"function"===typeof ec&&ic&&Od();Ya=!0;A(S.simulationstart);e()}}function Ca(){Ya&&(Sa.play(!1),Sa.pause(!0),Ya=!1)}function Da(){Ob||(Ya?(A(S.simulationstop),Ya=!1,Sa.play(!1)):Sa.pause(!1),Sa.stop(!0),Ob=!0,Y())}function Qa(){if(!jc){jc=!0;for(var a=wa.instances.length;0<a;)if(wa.instances[--a]===oa){wa.instances.splice(a,1);break}for(a=jb.length;0<a;)try{jb[--a]()}catch(h){console.error(h)}}}function ab(a){this["in"]=function(a,c){console.log(a);c?this.append(this.createTextNode("span", -"blue",a)):this.append(this.createTextNode("p","blue",a))};this.out=function(a,c){console.log(a);c?this.append(this.createTextNode("span","red",a)):this.append(this.createTextNode("p","red",a))};this.err=function(a,c){console.log(a);c?this.append(this.createTextNode("span","red",a)):this.append(this.createTextNode("p","red",a))};this.createTextNode=function(a,c,r){return"undefined"!==typeof document?(a=document.createElement(a),a.appendChild(document.createTextNode(r)),a.style.color=c,a):r+"\n"}} -function xb(){var a=this,h,c=document.createElement("div"),r;c.innerHTML='<div id="console" style="border-top: 1px solid #333333; bottom: 0px; position: absolute; width: 100%;"><div id="log" style="height: 150px; overflow-y: auto;"></div><input id="cmd" type="text" style="box-sizing: border-box; height: 30px; width: 100%;"></div>';document.body.appendChild(c);h=document.getElementById("cmd");r=document.getElementById("log");h.onkeydown=function(c){13===c.keyCode&&""!==h.value&&(a["in"](h.value),c= -t.parse$1([w.wrap(h.value)],[]),c=A(c),console.log(ba(c)),"undefined"!==c.ctype&&ia.out(ba(c)),h.value="",r.scrollTop=r.scrollHeight)};this.append=function(a){r.appendChild(a)};this.clear=function(){r.innerHTML=""}}function cb(a){var h=a;"string"===typeof a&&(h=document.getElementById(a));this.append=function(a){h.appendChild(a)};this.clear=function(){h.innerHTML=""}}function qa(){this.append=function(a){};this.clear=function(){}}function H(a,h,c,r){void 0===r&&(r=!1);jb.push(function(){a.removeEventListener(h, -c,r)});a.addEventListener(h,c,r)}function Zb(a,h){function c(c){var h=a.getBoundingClientRect();c=z.to(c.clientX-h.left-a.clientLeft+.5,c.clientY-h.top-a.clientTop+.5);X.prevx=X.x;X.prevy=X.y;X.x=c[0];X.y=c[1];ta[0]=X.x;ta[1]=X.y;e()}function r(a){for(var c=a.changedTouches,h=!1,r=0;r<c.length;r++)c[r].identifier===Q&&(h=!0);h&&(Q=-1,X.down=!1,fa=void 0,A(S.mouseup),qb("mouseup"),e(),a.preventDefault())}var b=null;"undefined"!==typeof MutationObserver&&(b=MutationObserver);b||"undefined"===typeof WebKitMutationObserver|| -(b=WebKitMutationObserver);b?(b=new b(function(c){document.body.contains(a)||Qa()}),b.observe(document.documentElement,{childList:!0,subtree:!0}),jb.push(function(){b.disconnect()})):(H(a,"DOMNodeRemovedFromDocument",Qa),H(a,"DOMNodeRemoved",Qa));if(!0===h.keylistener)H(document,"keydown",function(a){N(a,S.keydown);return!1}),H(document,"keyup",function(a){N(a,S.keyup);return!1}),H(document,"keypress",function(a){N(a,S.keytyped);return!1});else if(S.keydown||S.keyup||S.keytyped)a.setAttribute("tabindex", -"0"),H(a,"mousedown",function(){a.focus()}),H(a,"keydown",function(a){9!==a.keyCode&&(N(a,S.keydown),S.keytyped||a.preventDefault())}),H(a,"keyup",function(a){N(a,S.keyup);a.preventDefault()}),H(a,"keypress",function(a){9!==a.keyCode&&(N(a,S.keytyped),a.preventDefault())});H(a,"mousedown",function(a){X.button=a.which;c(a);A(S.mousedown);qb("mousedown");X.down=!0;a.preventDefault()});H(a,"mouseup",function(a){X.down=!1;fa=void 0;A(S.mouseup);qb("mouseup");e();a.preventDefault()});H(a,"mousemove",function(a){c(a); -X.down?A(S.mousedrag):A(S.mousemove);qb("mousemove");a.preventDefault()});H(a,"click",function(a){c(a);A(S.mouseclick);a.preventDefault()});H(a,"dragenter",function(a){a.preventDefault()});H(a,"dragover",function(a){a.preventDefault()});H(a,"drop",function(c){function h(a,c){function g(){e.readyState===XMLHttpRequest.DONE&&(200!==e.status?(console.error("GET request for "+a+" failed: "+(e.responseText||"(no error message)")),d(c,k)):b(c,e.responseText))}var Q=a.replace(/[?#][^]*/,""),Q=Q.replace(/[^]*\/([^\/])/, -"$1");f[c]={type:"",name:Q};var e=new XMLHttpRequest;e.onreadystatechange=function(){if(e.readyState===XMLHttpRequest.DONE)if(200!==e.status)console.error("HEAD request for "+a+" failed: "+(e.responseText||"(no error message)")),d(c,k);else{var h=e.getResponseHeader("Content-Type");f[c].type=h;/^image\//.test(h)?na(c,a):r(h)?(e=new XMLHttpRequest,e.onreadystatechange=g,e.open("GET",a),e.send()):d(c,k)}};e.open("HEAD",a);e.send()}function r(a){a=a.replace(/;[^]*/,"");return/^text\//.test(a)?1:"application/json"=== -a?2:0}function b(a,c){switch(r(f[a].type)){case 1:d(a,w.string(c));break;case 2:var h,na;try{h=JSON.parse(c),na=w.wrapJSON(h)}catch(g){console.error(g),na=k}d(a,na);break;default:d(a,k)}}function na(a,c){var h=new Image,r=!1;h.onload=function(){r||(r=!0,d(a,aa(h,!1)))};h.onerror=function(c){r||(r=!0,console.error(c),d(a,k))};h.src=c}function d(a,c,h){l[a]=g.turnIntoCSList([c,w.string(h||c.ctype),w.string(f[a].type),w.string(f[a].name)]);0===--m&&(a=p,kc=g.turnIntoCSList(l),lc=a,A(S.ondrop),lc=kc= -k,e())}c.preventDefault();var Q=c.dataTransfer,f=Q.files,l=Array(f.length),m=f.length,n=c.currentTarget.getBoundingClientRect(),p=g.realVector(z.to(c.clientX-n.left-a.clientLeft+.5,c.clientY-n.top-a.clientTop+.5));if(0<f.length)Array.prototype.forEach.call(f,function(a,c){var h=new FileReader;r(a.type)?(h.onload=function(){b(c,h.result)},h.readAsText(a)):/^image\//.test(a.type)?(h.onload=function(){na(c,h.result)},h.readAsDataURL(a)):(console.log("Unknown MIME type: "+a.type),d(c,k))});else if(c= -Q.getData("text/uri-list"))c=c.split("\n").filter(function(a){return!/^\s*(#|$)/.test(a)}),m=c.length,l=Array(m),f=Array(m),c.forEach(h)});var Q=-1;H(a,"touchstart",function(a){if(-1===Q){var h=a.changedTouches;0!==h.length&&(Q=h[0].identifier,c(a.targetTouches[0]),A(S.mousedown),X.down=!0,qb("mousedown"),a.preventDefault())}},!1);H(a,"touchmove",function(a){for(var h=a.changedTouches,r=!1,b=0;b<h.length;b++)h[b].identifier===Q&&(r=!0);r&&(c(a.targetTouches[0]),X.down?A(S.mousedrag):A(S.mousemove), -qb("mousemove"),a.preventDefault())},!0);H(a,"touchend",r,!1);"undefined"!==typeof document&&document.body&&H(document.body,"touchcancel",r,!1);"undefined"!==typeof window&&H(window,"resize",function(){Pb(function(){E();e()})},!1);d(a.parentNode);e()}function b(a,h){var c=document.createElement("div");c.setAttribute("style",h);a.appendChild(c);return c}function d(a){function h(){r.scrollLeft=r.scrollTop=na.scrollLeft=na.scrollTop=1E5}function c(){if(d!==a.clientWidth||g!==a.clientHeight)d=a.clientWidth, -g=a.clientHeight,f||(f=!0,Pb(function(){f=!1;E();e()}));h()}if("undefined"!==typeof document){var r=b(a,"position: absolute; transition: 0s; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;");b(r,"position: absolute; transition: 0s; left: 0; top: 0; width: 100000px; height: 100000px");var na=b(a,"position: absolute; transition: 0s; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;");b(na,"position: absolute; transition: 0s; left: 0; top: 0; width: 200%; height: 200%"); -h();var d=a.clientWidth,g=a.clientHeight,f=!1;r.addEventListener("scroll",c);na.addEventListener("scroll",c)}}function e(){mc||(mc=Pb(q))}function q(){mc=null;if(!jc){if(Ya){var a=Date.now(),h=Math.min(50,a-hc)*Oc*Pd;hc=a;a=Cb+h;ic&&"undefined"!==typeof ra&&ra.tick(h);Cb=a;Ya&&A(S.tick)}n();Ya&&e()}}function n(){z.reset();y.save();y.clearRect(0,0,da,ca);var a=z.drawingstate.matrix,h,c,r,b,d;if(0!==Wa){y.beginPath();y.strokeStyle="rgba(0,0,0,0.1)";y.lineWidth=1;y.lineCap="butt";h=Wa*a.a;for(b=Math.ceil(-a.tx/ -h);(d=b*h+a.tx)<da;){if(b||!zb)y.moveTo(d,0),y.lineTo(d,ca);b++}for(b=Math.floor(a.ty/h);(d=b*h-a.ty)<ca;){if(b||!zb)y.moveTo(0,d),y.lineTo(da,d);b++}y.stroke()}if(0!==bc){y.beginPath();y.strokeStyle="rgba(0,0,0,0.1)";y.lineWidth=1;y.lineCap="butt";h=bc*a.a;var e=Math.sqrt(3);c=a.ty/e;r=(ca+a.ty)/e;for(b=Math.ceil(-(a.tx+r)/h);(d=b*h+a.tx)+c<da;)y.moveTo(d+c,0),y.lineTo(d+r,ca),b++;for(b=Math.ceil(-(a.tx-c)/h);(d=b*h+a.tx)-r<da;)y.moveTo(d-c,0),y.lineTo(d-r,ca),b++;h*=.5*e;for(b=Math.floor(a.ty/h);(d= -b*h-a.ty)<ca;){if(b||!zb)y.moveTo(0,d),y.lineTo(da,d);b++}y.stroke()}zb&&(y.beginPath(),y.strokeStyle="rgba(0,0,0,0.2)",y.lineWidth=3,y.lineCap="butt",y.lineJoin="miter",y.miterLimit=10,y.beginPath(),y.moveTo(0,-a.ty),y.lineTo(da-6,-a.ty),y.moveTo(da-13,-5-a.ty),y.lineTo(da-3,-a.ty),y.lineTo(da-13,5-a.ty),y.moveTo(a.tx,ca),y.lineTo(a.tx,6),y.moveTo(a.tx-5,13),y.lineTo(a.tx,3),y.lineTo(a.tx+5,13),y.stroke());Qd();z.greset();Rd();for(a=0;a<u.polygons.length;a++)h=u.polygons[a],h.isshowing&&!1!==h.visible&& -(c={color:h.color,alpha:h.alpha,fillcolor:h.fillcolor,fillalpha:h.fillalpha,size:h.size,lineJoin:w.string("miter"),fillrule:w.string(h.fillrule)},D.drawpolygon([h.vertices],c,"D",!0));for(a=0;a<u.conics.length;a++)u.conics[a].isArc?(h=u.conics[a],h.isshowing&&!1!==h.visible&&(c={},c.color=h.color,c.alpha=h.alpha,c.size=h.size,D.drawarc(h,c,h.filled?"F":"D"))):(h=u.conics[a],h.isshowing&&!1!==h.visible&&(c={},c.color=h.color,c.alpha=h.alpha,c.size=h.size,D.drawconic(h.matrix,c)));for(a=0;a<u.lines.length;a++)a:if(h= -u.lines[a],h.isshowing&&!1!==h.visible&&g._helper.isAlmostReal(h.homog))if("S"===h.kind)c={overhang:h.overhang,dashtype:h.dashtype,size:h.size,color:h.color,alpha:h.alpha,arrow:h.arrow,arrowsize:h.arrowsize,arrowposition:h.arrowposition,arrowshape:h.arrowshape,arrowsides:h.arrowsides},0<=l.mult(h.startpos.value[2],l.conjugate(h.endpos.value[2])).value.real?t.draw$2([h.startpos,h.endpos],c):(x.handleModifs(c,x.lineModifs),x.drawRaySegment(h.startpos,h.endpos));else if("end"===h.clip.value&&"Join"=== -h.type)b=u.csnames[h.args[0]],c=u.csnames[h.args[1]],t.draw$2([b.homog,c.homog],{overhang:h.overhang,dashtype:h.dashtype,size:h.size,color:h.color,alpha:h.alpha});else{if("inci"===h.clip.value){b=[1E6,0];c=[-1E6,0];d=[1E6,0];r=[-1E6,0];for(e=0;e<h.incidences.length;e++){var f=u.csnames[h.incidences[e]].homog,k=f.value[0],m=f.value[1],n=f.value[2];l._helper.isAlmostZero(n)||(k=l.div(k,n),m=l.div(m,n),l._helper.isAlmostReal(k)&&l._helper.isAlmostReal(m)&&(k.value.real<b[0]&&(b=[k.value.real,f]),k.value.real> -c[0]&&(c=[k.value.real,f]),m.value.real<d[0]&&(d=[m.value.real,f]),m.value.real>r[0]&&(r=[m.value.real,f])))}c[0]-b[0]>r[0]-d[0]?(b=b[1],c=c[1]):(b=d[1],c=r[1]);if(b!==c){t.draw$2([b,c],{dashtype:h.dashtype,size:h.size,color:h.color,alpha:h.alpha,overhang:h.overhang});break a}}t.draw$1([h.homog],{dashtype:h.dashtype,size:h.size,color:h.color,alpha:h.alpha})}for(a=0;a<u.points.length;a++)h=u.points[a],h.isshowing&&!1!==h.visible&&g._helper.isAlmostReal(h.homog)&&(c=h.color,h.behavior&&(c=h.color), -t.draw$1([h.homog],{size:h.size,color:c,alpha:h.alpha}),h.labeled&&!h.tmp&&(c=h.printname||h.name||"P",r=h.labelpos||{x:3,y:3},b=h.textsize||la.textsize,d=!0===h.textbold,e=!0===h.textitalics,f=h.text_fontfamily||la.fontFamily,k=r.x*r.x+r.y*r.y,m=1,0<k&&(m=1+h.size.value.real/Math.sqrt(k)),D.drawtext([h.homog,w.wrap(c)],{x_offset:w.wrap(m*r.x),y_offset:w.wrap(m*r.y),size:w.wrap(b),bold:w.wrap(d),italics:w.wrap(e),family:w.wrap(f)})));for(a=0;a<u.texts.length;a++)Sd(u.texts[a]);y.restore()}function N(a, -h){var c=window.event?event:a,c=c.charCode?c.charCode:c.keyCode;Qc=String.fromCharCode(c);Rc=c;A(h);e()}function v(a){var h=a.value;a=h[0].value;var c=h[1].value,h=h[2].value;return g.turnIntoCSList([a[0],l.add(a[1],c[0]),l.add(a[2],h[0]),c[1],l.add(c[2],h[1]),h[2]])}function C(a){var h=!0;return function(c,r){h&&(console.error("Operator "+a+" is not supported yet."),h=!1);return k}}function ba(a){if("undefined"===typeof a)return"_??_";if(null===a)return"_???_";if("undefined"===a.ctype)return"___"; -if("number"===a.ctype)return l.niceprint(a);if("string"===a.ctype||"boolean"===a.ctype)return a.value;if("list"===a.ctype){for(var h="[",c=0;c<a.value.length;c++)h+=ba(A(a.value[c])),c!==a.value.length-1&&(h+=", ");return h+"]"}return"dict"===a.ctype?Ka.niceprint(a):"function"===a.ctype?"FUNCTION":"infix"===a.ctype?"INFIX":"modifier"===a.ctype?a.key+"->"+ba(a.value):"shape"===a.ctype?a.type:"error"===a.ctype?"Error: "+a.message:"variable"===a.ctype?ba(J.getvar(a.name)):"geo"===a.ctype?a.value.name: -"image"===a.ctype?"IMAGE":"_?_"}function bb(a,h){var c="undefined"===a[0].ctype,r="undefined"===a[1].ctype,b=A(a[1]);if(c||r)return k;"variable"===a[0].ctype?J.setvar(a[0].name,b):"infix"===a[0].ctype?"_"===a[0].oper?D.assigntake(a[0],b):console.error("Can't use infix expression as lvalue"):"field"===a[0].ctype?D.assigndot(a[0],b):"function"===a[0].ctype&&"genList"===a[0].oper?"list"===b.ctype?D.assignlist(a[0].args,b.value):console.error("Expected list in rhs of assignment"):console.error("Left hand side of assignment is not a recognized lvalue"); -return b}function pb(a,h){var c=A(a[0]),r=A(a[1]);if(c.ctype===r.ctype){if("number"===c.ctype)return w.bool(c.value.real===r.value.real&&c.value.imag===r.value.imag);if("string"===c.ctype||"boolean"===c.ctype)return w.bool(c.value===r.value);if("list"===c.ctype)return g.equals(c,r);if("geo"===c.ctype)return w.bool(c.value===r.value)}return{ctype:"boolean",value:!1}}function Gc(a,h){return w.not(pb(a,h))}function Yb(a,h){var c=B(a[0]),r=B(a[1]);return"number"===c.ctype&&"number"===r.ctype?{ctype:"boolean", -value:l._helper.isAlmostEqual(c,r)}:"string"===c.ctype&&"string"===r.ctype||"boolean"===c.ctype&&"boolean"===r.ctype?{ctype:"boolean",value:c.value===r.value}:"list"===c.ctype&&"list"===r.ctype?g.almostequals(c,r):{ctype:"boolean",value:!1}}function Hc(a,h){var c=B(a[0]),r=B(a[1]);return"boolean"===c.ctype&&"boolean"===r.ctype?{ctype:"boolean",value:c.value&&r.value}:k}function Ic(a,h){var c=B(a[0]),r=B(a[1]);return"boolean"===c.ctype&&"boolean"===r.ctype?{ctype:"boolean",value:c.value||r.value}: -k}function Jc(a,h){var c=a[0];"void"!==c.ctype&&(c=B(c));var r=B(a[1]),b=w.add(c,r);"Angle"===c.usage&&"Angle"===r.usage&&(b=w.withUsage(b,"Angle"));return b}function $b(a,h){var c=a[0];"void"!==c.ctype&&(c=B(c));var r=B(a[1]),b=w.sub(c,r);"Angle"===c.usage&&"Angle"===r.usage&&(b=w.withUsage(b,"Angle"));return b}function Kc(a,h){var c=B(a[0]),r=B(a[1]),b=w.mult(c,r);"Angle"!==c.usage||r.usage?"Angle"!==r.usage||c.usage||(b=w.withUsage(b,"Angle")):b=w.withUsage(b,"Angle");return b}function Lc(a,h){var c= -B(a[0]),r=B(a[1]);"number"===r.ctype&&l._helper.isZero(r)&&ia.err("WARNING: Division by zero!");var b=w.div(c,r);"Angle"!==c.usage||r.usage?"Angle"!==r.usage||c.usage||(b=w.withUsage(b,"Angle")):b=w.withUsage(b,"Angle");return b}function Mc(a,h){var c=B(a[0]),r=B(a[1]);return"number"===c.ctype&&"number"===r.ctype?l.pow(c,r):k}function Sc(a,h){var c=M(a[0]),r=M(a[1]);if(c!==k&&r!==k){var b=g.cross(c,r);"Point"===c.usage&&"Point"===r.usage&&(b=w.withUsage(b,"Line"));"Line"===c.usage&&"Line"===r.usage&& -(b=w.withUsage(b,"Point"));return b}return k}function nc(a){var h=a.length;if(0===h)return[];if(1===h)return[0];if(2===h)return a[0][0]+a[1][1]<=a[0][1]+a[1][0]?[0,1]:[1,0];if(4<h)return Td(a);for(var c=Ud[h],r=Number.POSITIVE_INFINITY,b=c[0],d=0;d<c.length;++d){for(var g=c[d],e=0,f=0;f<h;++f)e+=a[f][g[f]];e<r&&(r=e,b=g)}return b}function Td(a){function h(){return{matched:-1,prev:-1,start:-1,cost:0,used:!1,leaf:!1}}function c(a){for(var h=0;h<d;++h)0<k[a][h]||l[h].used||(l[h].used=!0,c(l[h].matched))} -function r(a){for(var c=0;c<d;++c)0<k[c][a]||f[c].used||(f[c].used=!0,r(f[c].matched))}var b=Math.abs,d=a.length,g,e,f=Array(d),l=Array(d),k=Array(d);for(g=0;g<d;++g)k[g]=Array(d);for(g=0;g<d;++g)for(f[g]=h(),l[g]=h(),f[g].cost=a[g][0],e=1;e<d;++e)f[g].cost>a[g][e]&&(f[g].cost=a[g][e]);for(;;){for(g=0;g<d;++g)for(e=0;e<d;++e)k[g][e]=a[g][e]-f[g].cost-l[e].cost,k[g][e]<1E-14*(b(a[g][e])+b(f[g].cost)+b(l[e].cost))&&(k[g][e]=0);for(g=0;g<d;++g)f[g].matched=l[g].matched=-1;for(var m=0;;){for(g=0;g<d;++g)f[g].used= -f[g].leaf=l[g].used=l[g].leaf=!1,-1===f[g].matched&&(f[g].start=g,f[g].used=f[g].leaf=!0,f[g].prev=-1);for(var n=!1,p=!1;!p;){for(g=0;g<d;++g)if(f[g].leaf)for(f[g].leaf=!1,e=0;e<d;++e)if(!(l[e].used||0<k[g][e])&&f[g].matched!==e&&(l[e].prev=g,l[e].start=f[g].start,l[e].used=l[e].leaf=!0,-1===l[e].matched)){f[l[e].start].prev=e;n=!0;break}if(n)break;p=!0;for(e=0;e<d;++e)l[e].leaf&&(l[e].leaf=!1,g=l[e].matched,f[g].used||(f[g].prev=e,f[g].start=l[e].start,f[g].used=f[g].leaf=!0,p=!1))}if(!n)break;for(n= -0;n<d;++n)if(-1===f[n].matched&&-1!==f[n].prev){e=f[n].prev;do g=l[e].prev,l[e].matched=g,f[g].matched=e,e=f[g].prev;while(g!==n);++m}}if(m===d)break;for(g=0;g<d;++g)f[g].used=f[g].leaf=l[g].used=l[g].leaf=!1;for(g=0;g<d;++g)-1===f[g].matched&&c(g);for(e=0;e<d;++e)-1===l[e].matched&&r(e);for(g=0;g<d;++g)-1===f[g].matched||f[g].used||l[f[g].matched].used||(f[g].used=!0);m=Number.POSITIVE_INFINITY;for(g=0;g<d;++g)if(!f[g].used)for(e=0;e<d;++e)l[e].used||m>k[g][e]&&(m=k[g][e]);for(g=0;g<d;++g)f[g].used|| -(f[g].cost+=m),l[g].used&&(l[g].cost-=m)}a=Array(d);for(g=0;g<d;++g)e=f[g].matched,a[g]=e;return a}function oc(a,h){var c=A(a[0]),r=B(a[1]);"string"!==c.ctype&&(c=g.asList(c));if("number"===r.ctype){r=Math.floor(r.value.real);0>r&&(r=c.value.length+r+1);if(0<r&&r<c.value.length+1)return"list"===c.ctype?c.value[r-1]:{ctype:"string",value:c.value.charAt(r-1)};ia.err("WARNING: Index out of range!");return k}if("list"===r.ctype){for(var b=[],d=0;d<r.value.length;d++){var e=B(r.value[d]);b[d]=oc([c,e], -[])}return g.turnIntoCSList(b)}return k}function Tc(a,h){var c=A(a[0]),r=A(a[1]);if("shape"===c.ctype&&"shape"===r.ctype)return D.shapeconcat(c,r);c=g.asList(c);r=g.asList(r);return"list"===c.ctype&&"list"===r.ctype?g.concat(c,r):k}function Uc(a,h){var c=A(a[0]),r=A(a[1]);return"list"===c.ctype&&"list"===r.ctype?g.set(g.common(c,r)):"shape"===c.ctype&&"shape"===r.ctype?D.shapecommon(c,r):k}function Vc(a,h){var c=A(a[0]),r=A(a[1]);return"list"===c.ctype&&"list"===r.ctype?g.remove(c,r):"shape"===c.ctype&& -"shape"===r.ctype?D.shaperemove(c,r):k}function Wc(a,h){var c=A(a[0]),r=A(a[1]);return"list"===c.ctype?g.append(c,r):k}function Xc(a,h){var c=A(a[0]),r=A(a[1]);return"list"===r.ctype?g.prepend(c,r):k}function pc(a,h){a|=0;h|=0;if(0===a&&0===h)return 0;for(;0!==h;){var c=a;a=h;h=c%h|0}return a}function Vd(a){return 1===a?0:1}function Yc(a,h,c,r,b,d,g){if(-1!==h.indexOf("\n")){var e=Infinity,f=-Infinity,l=Infinity,k=-Infinity;h.split("\n").forEach(function(h){h=Yc(a,h,c,r,b,d);e>h.left&&(e=h.left); -f<h.right&&(f=h.right);l>h.top&&(l=h.top);k<h.bottom&&(k=h.bottom);r+=g});return{left:e,right:f,top:l,bottom:k}}var m=a.measureText(h);a.fillText(h,c-m.width*b,r);return{left:c-m.width*b,right:c+m.width*(1-b),top:r-.84*d,bottom:r+.36*d}}function La(a){return"image"===a.ctype?a.value:"string"===a.ctype&&Xa.hasOwnProperty(a.value)?Xa[a.value].value:null}function rb(a,h,c,r,b){var d=[];if(a.readPixels)d=a.readPixels(h,c,r,b);else{var g,e;if(a.img.getContext)e=a.img.getContext("2d"),g=e.getImageData(h, -c,r,b).data;else try{Db||(Db=document.createElement("canvas")),Db.width=r,Db.height=b,e=Db.getContext("2d"),e.drawImage(a.img,h,c,r,b,0,0,r,b),g=e.getImageData(0,0,r,b).data}catch(f){console.log(f)}for(var l in g)d.push(g[l]/255)}return d}function Zc(a){return a.replace(/[^A-Za-z0-9 \u0080-\uffff]/ig,"\\$&")}function ha(a,h,c){var r=a;h&&(r=r+" at "+h.row+":"+h.col);c&&(r=r+": \u2018"+c+"\u2019");r=Error(r);r.name="CindyScriptParseError";r.description=a;r.location=h;r.text=c;return r}function kb(a){this.input= -a;this.re=new RegExp($c,"g");for(var h=[],c=a.indexOf("\n")+1;c;)h.push(c),c=a.indexOf("\n",c)+1;h.push(a.length);this.bols=h;this.bol=this.pos=0;this.line=1}function Qb(a){var h=a[a.length-2],c=a[a.length-3],r=a[a.length-1];if(c){if(c.isSuperscript&&h.precedence<=c.precedence)throw ha("Operator not allowed after superscript",h.start,h.text);if(r){if(!h.op.infix)throw ha("Operator may not be used infix",h.start,h.text);}else if(!h.op.postfix)throw ha("Operator may not be used postfix",h.start,h.text); -}else if(r){if(!h.op.prefix)throw ha("Operator may not be used prefix",h.start,h.text);}else if(!h.op.bare)throw ha("Operator without operands",h.start,h.text);h.ctype="infix";h.oper=h.op.sym;h.args=[c,r];a.splice(a.length-3,3,h)}function ad(a,h,c,r){a.length&1||a.push(null);for(c=xa[c];3<=a.length&&a[a.length-2].precedence<=c.precedence;)Qb(a);a.push({op:c,precedence:c.precedence+(c.rassoc?1:0),start:h.start,end:h.end,text:h.text,rawtext:h.rawtext});c="";for(var b=h.text,d=0;d<b.length;++d)c+="0123456789+-".charAt(r.indexOf(b.charAt(d))); -h.ctype="number";h.value={real:+c,imag:0};a.push(h);Qb(a)}function bd(a,h){var c=[],r;a:for(;;)switch(r=a.next(),r.toktype){case "OP":var b=xa[r.text];"_"!==b.sym||!c.length||c.length&1||"OP"!==c[c.length-1].toktype||":="!==c[c.length-1].op.sym||(c.pop(),b=xa[":=_"],r.text=b.sym);r.op=b;r.precedence=b.precedence;for(c.length&1||c.push(null);3<=c.length&&c[c.length-2].precedence<=r.precedence;)Qb(c);b.rassoc&&r.precedence++;c.push(r);break;case "ID":r.ctype="variable";r.name=r.text;if(c.length&1)throw ha("Missing operator", -r.start,r.text);c.push(r);break;case "NUM":r.ctype="number";r.value={real:+r.text,imag:0};if(c.length&1)throw ha("Missing operator",r.start,r.text);c.push(r);break;case "STR":r.ctype="string";r.value=r.raw.substring(1,r.raw.length-1);if(c.length&1)throw ha("Missing operator",r.start,r.text);c.push(r);break;case "SUB":ad(c,r,"_","\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u208a\u208b");break;case "SUP":ad(c,r,"^","\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079\u207a\u207b"); -c[c.length-1].isSuperscript=!0;break;case "BRA":b="[](){}||".indexOf(r.text);if(r.text===h||b&1)break a;var b="[](){}||".charAt(b+1),d=bd(a,b),g=d.closedBy;if(g.text!==b)throw ha("Opening "+r.text+" at "+r.start.row+":"+r.start.col+" closed by "+(g.text||"EOF")+" at "+g.start.row+":"+g.start.col);g=r.text+g.text;b=[];if(d=d.expr){for(;d&&"infix"===d.ctype&&","===d.oper;)b.push(d.args[0]),d=d.args[1];b.push(d)}if(c.length&1){if("{}"===g)throw ha("{\u2026} reserved for future use",r.start);d=c[c.length- -1];if("variable"!==d.ctype)throw ha("Function name must be an identifier",d.start);if(2<c.length&&c[c.length-2].precedence<cd)throw ha("Function call in indexing construct must be enclosed in parentheses",r.start);d.ctype="function";r=d.args=[];for(var g=d.modifs={},e=0;e<b.length;++e){var f=b[e];if(f&&"infix"===f.ctype&&"->"===f.oper){var l=f.args[0];if("variable"!==l.ctype)throw ha("Modifier name must be an identifier",f.start);g[l.name]=f.args[1]}else r.push(f)}d.oper=d.name.toLowerCase()+"$"+ -d.args.length}else if("||"===g)if(1===b.length)c.push({ctype:"function",oper:"abs_infix",args:b,modifs:{}});else if(2===b.length)c.push({ctype:"function",oper:"dist_infix",args:b,modifs:{}});else throw ha("Don't support |\u2026| with "+b.length+" arguments",r.start);else{if("{}"===g)throw ha("{\u2026} reserved for future use",r.start);"[]"!==g&&1===b.length?c.push({ctype:"paren",args:b}):0===b.length?c.push({ctype:"list",value:[]}):c.push({ctype:"function",oper:"genList",args:b,modifs:{}})}break; -case "EOF":break a}for(c.length&1||c.push(null);3<=c.length;)Qb(c);return{expr:c[0],closedBy:r}}function Eb(a){this.usedFunctions={};this.usedVariables={}}function A(a){if(void 0===a)return k;if("infix"===a.ctype)return a.impl(a.args,{},a);if("variable"===a.ctype)return A(J.getvar(a.name));if("function"===a.ctype)return D.evaluate(a.oper,a.args,a.modifs);if("void"===a.ctype)return k;if("field"===a.ctype){var h=A(a.obj);return"geo"===h.ctype?ya.getField(h.value,a.key):"list"===h.ctype?g.getField(h, -a.key):k}return a}function B(a){a=A(a);if("geo"===a.ctype){var h=a.value;if("P"===h.kind)return ya.getField(h,"xy");if("V"===h.kind)return h.value}return a}function M(a){a=A(a);if("geo"===a.ctype){var h=a.value;if("P"===h.kind||"L"===h.kind)return ya.getField(h,"homog")}return g._helper.isNumberVecN(a,3)?a:g._helper.isNumberVecN(a,2)?(h=g.turnIntoCSList([a.value[0],a.value[1],l.real(1)]),a.usage&&(h=w.withUsage(h,a.usage)),h):k}function Ra(a){var h=new Eb;h.usedFunctions=Nc;h.infixmap=R;a=h.parse(a); -for(var c in h.usedVariables)J.create(c);return a}function dd(){this._path=[];this._defs=["<defs>"];this._imgcache=[];this._body=[];this._saveStack=[""];this._clipIndex=0;this._stroke=this._fill="#000";this._strokeOpacity=this._fillOpacity=null;this.height=this.width=0;this.lineWidth=1;this.lineCap="butt";this.lineJoin="miter";this.miterLimit=10;this.globalAlpha=1}function ed(){this._body=[];this._yPos=this._xPos=NaN;this._extGState={Af255:"<< /ca 1 >>",As255:"<< /CA 1 >>"};this._objects=[["%PDF-1.4\n"]]; -this._offset=this._objects[0][0].length;this._nextIndex=5;this._imgcache=[];this._xobjects={};this._pathUsed=-1;this._fillAlpha=this._strokeAlpha=this._globalAlpha=1;this.height=this.width=0;this.lineWidth=1;this.lineCap="butt";this.lineJoin="miter";this.miterLimit=10}function fd(a,h){var c=a.width,r=a.height,b=document.createElement("canvas");b.setAttribute("width",c);b.setAttribute("height",r);b.setAttribute("style","display:none;");var d=oa.canvas;d.parentNode.insertBefore(b,d.nextSibling);try{return b.getContext("2d").drawImage(a, -0,0,c,r),b.toDataURL(h||"image/png")}finally{b.parentNode.removeChild(b)}}function Wd(a){a=a.replace(RegExp("[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/]+","g"),"");var h=new Uint8Array(3*a.length>>2),c,r,b,d,g,e;for(r=c=0;c+3<a.length;c+=4)b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c)),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+1)),g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+ -2)),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+3)),h[r++]=b<<2|d>>4,h[r++]=d<<4|g>>2,h[r++]=g<<6|e;switch(a.length-c){case 0:break;case 2:b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c));d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+1));h[r++]=b<<2|d>>4;break;case 3:b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c));d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+ -1));g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+2));h[r++]=b<<2|d>>4;h[r++]=d<<4|g>>2;break;default:throw Error("Malformed Base64 input: "+(a.length-c)+" chars left: "+a.substr(c));}if(r!==h.length)throw Error("Failed assertion: "+r+" should be "+h.length);return h}function Xd(a){function h(c){return(a[c]<<24|a[c+1]<<16|a[c+2]<<8|a[c+3])>>>0}if(57>a.length)throw Error("Too short to be a PNG file");if(2303741511!==h(0)||218765834!==h(4))throw Error("PNG signature missing"); -for(var c=[],r=8;r<a.length;){if(r+12>a.length)throw Error("Incomplete chunk at offset 0x"+r.toString(16));var b=h(r);if(2147483648<=b)throw Error("Chunk too long");var d=r+12+b;if(d>a.length)throw Error("Incomplete chunk at offset 0x"+r.toString(16));var g=a.subarray(r+4,r+8),g=String.fromCharCode.apply(String,g);c.push({len:b,type:g,data:a.subarray(r+8,r+8+b),crc:h(r+8+b)});r=d}return c}function Rb(a,h){var c;if(c=/^rgba\(([0-9]+), *([0-9]+), *([0-9]+), *([0-9]+)\)$/.exec(a))h(+c[1],+c[2],+c[3], -+c[4]);else if(c=/^rgb\(([0-9]+), *([0-9]+), *([0-9]+)\)$/.exec(a))h(+c[1],+c[2],+c[3],1);else throw Error("Can't handle color style "+a);}function Yd(a){var h=1;Object.keys(Xa).forEach(function(c){var r=Xa[c].value.img;if(void 0===r.cachedDataURL&&r.src)if("data:"===r.src.substr(0,5))r.cachedDataURL=r.src;else{++h;r.cachedDataURL=null;var b=new XMLHttpRequest;b.responseType="blob";b.onreadystatechange=function(){if(b.readyState===XMLHttpRequest.DONE)if(200===b.status){var c=new FileReader;c.onloadend= -function(){r.cachedDataURL=c.result;console.log("Cached data for image "+r.src);0===--h&&a()};c.readAsDataURL(b.response)}else console.error("Failed to load "+r.src+": "+b.statusText),0===--h&&a()};b.open("GET",r.src,!0);b.send()}});0===--h&&a()}function lb(a,h,c){for(c||(c="0");a.length<h;)a=c+a;return a}function gd(){null!==Fb&&(window.URL.revokeObjectURL(Fb),Fb=null)}function hd(a){Yd(function(){var h=y;try{y=new a;y.width=da;y.height=ca;n();var c=y.toBlob();Fb=window.URL.createObjectURL(c);id(Fb)}finally{y= -h}})}function Gb(a){var h=null,c=1E6,r;console.log("getElementAtMouse");for(var b=0;b<u.gslp.length;b++){var d=u.gslp[b];if(!d.pinned&&!1!==d.visible&&!0!==d.tmp){var e,f,k,m=z.drawingstate.matrix.sdet;if("P"===d.kind){var n=g.normalizeZ(d.homog);if(!g._helper.isAlmostReal(n))continue;e=n.value[0].value.real-a.x;f=n.value[1].value.real-a.y;k=Math.sqrt(e*e+f*f);d.narrow&k>20/m&&(k=1E4)}else if("C"===d.kind)f=u.csnames[d.args[0]],k=0,"undefined"!==typeof d.radius&&(k=d.radius.value.real),e=l.div(f.homog.value[0], -f.homog.value[2]).value.real,f=l.div(f.homog.value[1],f.homog.value[2]).value.real,e-=a.x,f-=a.y,k=Math.sqrt(e*e+f*f)-k,f=e=0,0>k&&(k=-k),k+=30/m;else if("L"===d.kind||"S"===d.kind)e=d.homog,k=l,f=k.add(k.mult(e.value[0],k.conjugate(e.value[0])),k.mult(e.value[1],k.conjugate(e.value[1]))),f=g.scaldiv(k.sqrt(f),e),k=f.value[0].value.real*a.x+f.value[1].value.real*a.y+f.value[2].value.real,e=f.value[0].value.real*k,f=f.value[1].value.real*k,0>k&&(k=-k),k+=1;k<c+.2/m&&(c=k,h=d,r={x:e,y:f})}}return null=== -h?null:{mover:h,offset:r,prev:{x:a.x,y:a.y}}}function Ta(){return"P"+Zd++}function qb(a){var h=G[qc].actions;h[sb].event===a&&h[sb]["do"]()&&(e(),sb===h.length-1?(ua=[],sb=Ua=0):sb++)}function rc(a){return a&&.5>Math.abs(a.offset.x)&&.5>Math.abs(a.offset.y)&&!a.mover.tmp}function jd(a){return rc(a)&&"P"===a.mover.kind}function kd(a){return rc(a)&&("L"===a.mover.kind||"S"===a.mover.kind)}function sc(a){fa={mover:a,offset:{x:0,y:0},prev:{x:X.x,y:X.y}}}function mb(){var a=Gb(X);jd(a)?ua[Ua]=a.mover: -(ua[Ua]={type:"Free",name:Ta(),labeled:!0,pos:[ta[0],ta[1],1]},Ha(ua[Ua]));Ua++}function ld(){var a=Gb(X);return kd(a)?(ua[Ua]=a.mover,Ua++,!0):!1}function md(){var a=Gb(X),h;(h=kd(a))||(h=rc(a)&&"C"===a.mover.kind);return h?(ua[Ua]=a.mover,Ua++,!0):!1}function tb(){var a=Gb(X);if(jd(a))for(Hb.args[1]=a.mover.name,a=0;a<u.gslp.length;a++){var h=u.gslp[a];!0===h.tmp&&nd(h.name)}else for(a=0;a<u.gslp.length;a++)h=u.gslp[a],!0===h.tmp&&(h.tmp=!1)}function Sb(a){var h={type:"Free",name:Ta(),labeled:!0, -pos:[ta[0],ta[1],1],tmp:!0},h=Ha(h);Hb=Ha({type:a,name:Ta(),labeled:!0,args:[ua[0].name,h.name]});sc(h)}function $d(a){for(var h in a)null!==a[h]&&(la[h]=a[h])}function Md(a){Object.keys(m).forEach(function(a){var c=m[a];eb(c.signature||"_helper"===a,a+" has no signature");void 0!==c.updatePosition&&void 0===c.stateSize&&(c.stateSize=0)});u.gslp=[];u.csnames={};u.points=[];u.lines=[];u.conics=[];u.texts=[];u.free=[];u.polygons=[];a.forEach(od);pd()}function qd(a){"undefined"===typeof a.tracedim&& -(a.tracedim=1);"undefined"===typeof a.tracelength&&(a.tracelength=100);"undefined"===typeof a.traceskip&&(a.traceskip=1);a._traces=Array(a.tracelength);a._traces_index=0;a._traces_tick=0}function ae(a){void 0===a.size&&(a.size=la.pointSize);a.size=l.real(a.size);!a.movable||a.pinned?(a.color=g.realVector(a.color||la.pointColor),a.color=g.scalmult(l.real(la.dimDependent),a.color)):a.color=g.realVector(a.color||la.pointColor);void 0===a.alpha&&(a.alpha=la.alpha);a.alpha=l.real(a.alpha);a.drawtrace&& -qd(a)}function Tb(a){void 0===a.size&&(a.size=la.lineSize);a.size=l.real(a.size);a.color=g.realVector(a.color||la.lineColor);void 0===a.alpha&&(a.alpha=la.alpha);a.alpha=l.real(a.alpha);a.clip=w.string(a.clip||la.clip);void 0===a.overhang&&(a.overhang=la.overhangLine);a.overhang=l.real(a.overhang);a.dashtype&&(a.dashtype=w.wrap(a.dashtype))}function be(a){void 0===a.overhang&&(a.overhang=la.overhangSeg);a.arrow&&(a.arrow=w.bool(a.arrow));a.arrowsize&&(a.arrowsize=l.real(a.arrowsize));a.arrowposition&& -(a.arrowposition=l.real(a.arrowposition));a.arrowshape&&(a.arrowshape=w.string(a.arrowshape));a.arrowsides&&(a.arrowsides=w.string(a.arrowsides));Tb(a);a.clip=w.string("end")}function ce(a){a.size=void 0!==a.textsize?a.textsize:void 0!==a.size?a.size:la.textsize;a.size=l.real(+a.size)}function de(a){a.filled=void 0!==a.filled?w.bool(a.filled):w.bool(!0);a.fillcolor=void 0===a.fillcolor?k:g.realVector(a.fillcolor);void 0===a.fillalpha&&(a.fillalpha=0);a.fillalpha=l.real(a.fillalpha);Tb(a)}function Ha(a){a= -od(a);pd();return a}function od(a){var h;if(void 0!==u.csnames[a.name])return console.log("Element name '"+a.name+"' already exists"),h=u.csnames[a.name],m[h.type].isMovable&&"P"===m[h.type].kind&&Ia(h,a.pos,"homog"),{ctype:"geo",value:h};for(;tc.hasOwnProperty(a.type);)a.type=tc[a.type];if(h=rd[a.type]){var c=h(a),r=null;for(h=0;h<c.length;++h)r=Ha(c[h]);return r}var b=m[a.type],c=!1;if(!b)return console.error(a),console.error("Operation "+a.type+" not implemented yet"),null;if("**"!==b.signature)if(!Array.isArray(b.signature)&& -"*"===b.signature.charAt(1))c=!0,a.args.forEach(function(c){if(u.csnames[c].kind!==b.signature.charAt(0))return console.error("Not all elements in set are of same type: "+a.name+" expects "+b.signature+" but "+c+" is of kind "+u.csnames[c].kind),"undefined"!==typeof window&&window.alert("Not all elements in set are of same type: "+a.name),null});else if(b.signature.length!==(a.args?a.args.length:0))return console.error("Wrong number of arguments for "+a.name+" of type "+a.type),"undefined"!==typeof window&& -window.alert("Wrong number of arguments for "+a.name),null;if(a.args)for(h=0;h<a.args.length;++h){if(!u.csnames.hasOwnProperty(a.args[h]))return console.log("Dropping "+a.name+" due to missing argument "+a.args[h]),null;if("**"!==b.signature&&!c&&(r=u.csnames[a.args[h]].kind,b.signature[h]!==r&&("S"!==r||"L"!==b.signature[h])))return window.alert("Wrong argument kind "+r+" as argument "+h+" to element "+a.name+" of type "+a.type),null}b.signatureConstraints&&!b.signatureConstraints(a)&&window.alert("signature constraints violated for element "+ -a.name);u.gslp.push(a);u.csnames[a.name]=a;h=za.length;a.kind=b.kind;a.stateIdx=h;h+=b.stateSize;a.incidences=[];a.isshowing=!0;a.movable=!1;b.isMovable&&(a.movable=!0,u.free.push(a));"P"===a.kind&&(u.points.push(a),ae(a));"L"===a.kind&&(u.lines.push(a),Tb(a));"C"===a.kind&&(u.conics.push(a),Tb(a));"S"===a.kind&&(u.lines.push(a),be(a));"Text"===a.kind&&(u.texts.push(a),ce(a));"Poly"===a.kind&&(u.polygons.push(a),de(a));ee(h);ma=Ma=za;fb=!0;b.initialize&&(va=Aa=a.stateIdx,a.param=b.initialize(a),eb(Aa=== -a.stateIdx+b.stateSize,"State fully initialized"));va=Aa=a.stateIdx;b.updatePosition(a,!1);eb(va===a.stateIdx+b.stateSize,"State fully consumed");eb(Aa===a.stateIdx+b.stateSize,"State fully updated");fb=!1;ma=db["in"];ma.set(za);Ma=db.out;uc(a,b);Ub={};gb(a);return u.csnames[a.name]}function nd(a){var h,c;console.log("Remove element "+a);delete u.csnames[a];for(h=0;h<u.gslp.length;h++)c=u.gslp[h],c.name===a&&(console.log("Removed element from gslp "+a),u.gslp.splice(h,1));for(h=0;h<u.free.length;h++)c= -u.free[h],c.name===a&&(console.log("Removed element from free "+a),u.free.splice(h,1));for(h=0;h<u.points.length;h++)c=u.points[h],c.name===a&&(console.log("Removed element from points "+a),u.points.splice(h,1));for(h=0;h<u.lines.length;h++)c=u.lines[h],c.name===a&&(console.log("Removed element from lines "+a),u.lines.splice(h,1));for(h=0;h<u.conics.length;h++)c=u.conics[h],c.name===a&&(console.log("Removed element from conics "+a),u.conics.splice(h,1));Ub={}}function sd(a,h){var c=u.csnames[h.args[0]].homog, -r=u.csnames[h.args[1]].homog,b=a.homog,d=l.div(c.value[0],c.value[2]),c=l.div(c.value[1],c.value[2]),g=l.div(r.value[0],r.value[2]),r=l.div(r.value[1],r.value[2]),e=l.div(b.value[0],b.value[2]),b=l.div(b.value[1],b.value[2]);return l._helper.isAlmostReal(d)&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(g)&&l._helper.isAlmostReal(r)&&l._helper.isAlmostReal(e)&&l._helper.isAlmostReal(b)?(d=d.value.real,c=c.value.real,g=g.value.real,r=r.value.real,e=e.value.real,b=b.value.real,d=Math.sqrt((d-g)* -(d-g)+(c-r)*(c-r))-Math.sqrt((d-e)*(d-e)+(c-b)*(c-b))-Math.sqrt((g-e)*(g-e)+(r-b)*(r-b)),1E-15>d*d):!1}function uc(a,h){a.isshowing=!0;if(a.args)for(var c=0;c<a.args.length;c++)if(!u.csnames[a.args[c]].isshowing){a.isshowing=!1;return}h.visiblecheck&&h.visiblecheck(a)}function Sd(a){a._bbox=null;if(a.isshowing&&!1!==a.visible){var h={size:a.size},c=a.homog,r=a.text,b=m[a.type].getText,r=b?b(a):r.replace(/@[$#]"([^"\\]|\\.)*"/g,function(a){var c,h;try{if(c=JSON.parse(a.substring(2)),h=u.csnames[c], -!h)return"?"}catch(r){return"?"}switch(a.charAt(1)){case "$":return h.printname||c;case "#":return"V"!==h.kind?"?":ba(h.value)}}),b=null;if(a.html)var d=a._textCache||{text:!1},g=a.html,e=g.parentNode,f=e.parentNode,b=function(c,h,r,b,na){d.invisible&&f.style.removeProperty("display");if(c!==d.text||h!==d.font||r!==d.x||b!==d.y||na!==d.align){h!==d.font&&(g.style.font=h,g.style.lineHeight=la.lineHeight);c!==d.text&&!1!==c&&!1===td(g,c,h)&&(c=!1);f.style.left=r+"px";f.style.top=b+"px";if(na||e.style.transform)e.style.transform= -"translateX("+-100*na+"%)";a._textCache={text:c,font:h,x:r,y:b,align:na}}};r=w.string(r);a.dock&&(a.dock.to?c=u.csnames[a.dock.to].homog:ud.hasOwnProperty(a.dock.corner)&&(c=t.screenbounds$0([],{}),c=c.value[ud[a.dock.corner]]),h.offset=a.dock.offset);a.align&&(h.align=w.string(a.align));c&&(a._bbox=D.drawtext([c,r],h,b))}else a.html&&(a.html.parentNode.parentNode.style.display="none",a._textCache={invisible:!0})}function Rd(){function a(){var a=e++/c._traces.length,h=c._traces[g];h&&(a*=r*a*a,t.draw$1([h], -{size:l.real(b),color:c.color,alpha:l.real(a)}));b*=d}for(var h=0;h<u.points.length;h++){var c=u.points[h];if(c.drawtrace){c._traces_tick===c.traceskip?(c._traces[c._traces_index]=c.homog,c._traces_index=(c._traces_index+1)%c._traces.length,c._traces_tick=0):c._traces_tick++;var r=c.alpha.value.real,b=c.size.value.real,d=1;1!==c.tracedim&&(b*=c.tracedim,d=Math.pow(c.tracedim,-1/c._traces.length));var g,e=0;for(g=c._traces_index;g<c._traces.length;++g)a();for(g=0;g<c._traces_index;++g)a()}}}function eb(a, -h){var c="Assertion failed: "+h;if(!a)throw console.log(c),Qa(),"undefined"!==typeof alert&&alert(c),Error(c);}function ee(a){if(a!==za.length){var h,c,r=vc.length;hb.length<a*r?(h=2*a,hb=new Float64Array(r*h)):h=hb.length/r|0;for(c=0;c<r;++c)db[vc[c]]=hb.subarray(c*h,c*h+a);a=za;ma=db["in"];Ma=db.out;za=db.good;za.set(a)}}function ub(){za.set(ma);Ja=!1;vd(!1);for(var a=za.length,h=Math.abs,c=0;c<a;c+=2)h(za[c])>1E12*h(za[c+1])&&(za[c+1]=0)}function Vb(){if(vb)Ja=!0;else throw wd;}function xd(a,h, -c,r,b){return w.add(r,w.mult(c,w.sub(b,r)))}function Qd(){L&&(L.currentMouseAndScripts=[]);wc=!0;if(fa){var a=fa.mover,h=g.realVector([X.x+fa.offset.x,X.y+fa.offset.y,1]);yd(a,h,"mouse");fa.prev.x=X.x;fa.prev.y=X.y}A(S.move);A(S.draw);Ja||ub();wc=!1;L&&(L.fullLog.push(g.turnIntoCSList([g.turnIntoCSList(L.currentMouseAndScripts)])),L.length>L.logLength&&L.splice(0,L.length-L.logLength),L.currentMouseAndScripts=null,L.postMouseHooks.forEach(function(a){a()}))}function Ia(a,h,c){yd(a,h,c);wc||Ja||ub()} -function yd(a,h,c){L&&L.currentMouseAndScripts&&(L.currentMover=[]);a===zd?(ma.set(za),Ja=!1):(zd=a,ub());Ma.set(ma);var r=1E4,b;b=Ub[a.name];if(!b){var d={},e=0;b=[];d[a.name]=a;for(var f=u.gslp,k=0;k<f.length;++k){var n=f[k],p=n.args;if(p)for(var q=0;q<p.length;++q)d.hasOwnProperty(p[q])&&(d[n.name]=n,b[e++]=n)}Ub[a.name]=b}var d=-1,e=.9,t,v,x,f=m[a.type],k=f.parameterPath||xd;va=a.stateIdx;n=f.getParamFromState(a);va=Aa=a.stateIdx;p=f.getParamForInput(a,h,c);for(q=d+e;d!==q;){var y=q*q,z=.5/(1+ -y),z=l.complex(2*q*z+.5,(1-y)*z);vb=d+.5*e<=d||0===r;0===r&&console.log("tracing limit Reached");y=!1;L&&L.currentMouseAndScripts&&(L.currentStep=[]);try{va=Aa=a.stateIdx;var A=k(a,q,z,n,p);L&&(L.currentParam=A);z=Ma;Ma=ma;f.putParamToState(a,A);Ma=z;Aa=a.stateIdx;L&&(L.currentElement=a);f.updatePosition(a,!0);eb(va===a.stateIdx+f.stateSize,"State fully consumed");eb(Aa===a.stateIdx+f.stateSize,"State fully updated");for(t=0;t<b.length;++t)v=b[t],x=m[v.type],va=Aa=v.stateIdx,L&&(L.currentElement= -v),x.updatePosition(v,!1),eb(va===v.stateIdx+x.stateSize,"State fully consumed"),eb(Aa===v.stateIdx+x.stateSize,"State fully updated");L&&(L.currentElement=null);d=q;e*=1.25;q+=e;1<=q&&(q=1);Ma=ma;ma=z}catch(B){if(B!==wd)throw B;e*=.5;q=d+e;--r;y=!0}L&&L.currentMouseAndScripts&&(L.currentMover.push(g.turnIntoCSList([g.turnIntoCSList(L.currentStep),w.wrap(y),w.wrap(d),w.wrap(q),w.wrap(L.currentParam)])),L.currentStep=null,L.currentParam=null)}vd(Ja);for(t=0;t<b.length;++t)v=b[t],x=m[v.type],uc(v,x); -L&&L.currentMouseAndScripts&&(L.currentMouseAndScripts.push(g.turnIntoCSList([g.turnIntoCSList(L.currentMover),w.wrap(Ja),w.wrap(a.name),h,w.wrap(c),n,p])),L.currentMover=null)}function Nd(){ub();vb=!0;for(var a=u.gslp,h=0;h<a.length;h++){var c=a[h],r=m[c.type];va=Aa=c.stateIdx;r.updatePosition(c,!1);uc(c,r)}a=Ma;Ma=ma;ma=a;ub()}function vd(a){var h=p.tracingStateReport;"string"===typeof h&&(document.getElementById(h).textContent=a?"BAD":"GOOD")}function fe(){return g.turnIntoCSList(L.fullLog.slice())} -function ge(a){var h=JSON.stringify(L.fullLog);a=new Blob([h],{type:a?"application/octet-stream":"application/json"});return window.URL.createObjectURL(a)}function wb(){var a=va;va+=2;return l.complex(ma[a],ma[a+1])}function Z(a){for(var h=Array(a),c=0;c<a;++c)h[c]=wb();return g.turnIntoCSList(h)}function Va(a){Ma[Aa]=a.value.real;Ma[Aa+1]=a.value.imag;Aa+=2}function T(a){for(var h=0,c=a.value.length;h<c;++h)Va(a.value[h])}function Na(a,h){var c=Z(3),r=Z(3),c=Ad(a,h,c,r);T(c[0]);T(c[1]);return g.turnIntoCSList(c)} -function Ad(a,h,c,r){if(fb)return[a,h];var b=g.projectiveDistMinScal(c,a),d=g.projectiveDistMinScal(c,h),e=g.projectiveDistMinScal(r,a),f=g.projectiveDistMinScal(r,h),l=g.projectiveDistMinScal(c,r),m=g.projectiveDistMinScal(a,h),n=b+f,p=d+e,q;n>p?(q=[h,a],n=p):q=[a,h];p=function(){};if(L&&L.currentStep){var t=[L.labelTracing2,w.wrap(L.currentElement.name),g.turnIntoCSList(q),g.turnIntoCSList([c,r]),g.realMatrix([[b,d],[e,f]]),w.wrap(n),w.wrap(l),w.wrap(m),k];L.currentStep.push(g.turnIntoCSList(t)); -p=function(a){L.hasOwnProperty(a)||(L[a]=w.wrap(a));t[t.length-1]=L[a]}}g._helper.isNaN(a)||g._helper.isNaN(h)?(p("Tracing failed due to NaNs."),Ja=!0):l>3*n&&m>3*n?p("Normal case, everything all right."):1E-5>m?1E-5>l?p("Staying inside singularity."):(p("Moved into singularity."),Ja=!0):1E-5>l?p("Moved out of singularity."):(vb?p("Reached refinement limit, giving up."):p("Need to refine."),Vb());return q}function xc(a,h,c,r){var b=Z(3),d=Z(3),e=Z(3),f=Z(3);a=he(a,h,c,r,b,d,e,f);T(a[0]);T(a[1]);T(a[2]); -T(a[3]);return g.turnIntoCSList(a)}function he(a,h,c,r,b,d,e,f){var l=function(){};b=[b,d,e,f];a=[a,h,c,r];if(fb)return a;d=0;r=Array(4);for(c=0;4>c;c++)for(r[c]=Array(4),f=0;4>f;f++)e=g.projectiveDistMinScal(b[c],a[f]),r[c][f]=e;e=nc(r);h=Array(4);for(c=0;4>c;++c)h[c]=a[e[c]],d+=r[c][e[c]];var m=1*d,n=Infinity,p=Infinity;for(c=0;4>c;c++){if(g._helper.isNaN(a[c]))return l("Tracing failed due to NaNs."),Ja=!0,h;for(f=c+1;4>f;f++)e=g.projectiveDistMinScal(b[c],b[f]),n>e&&(n=e),e=g.projectiveDistMinScal(h[c], -h[f]),p>e&&(p=e)}if(L&&L.currentStep){var q=[L.labelTracing4,w.wrap(L.currentElement.name),g.turnIntoCSList(h),g.turnIntoCSList(b),g.realMatrix(r),w.wrap(d),w.wrap(n),w.wrap(p),k];L.currentStep.push(g.turnIntoCSList(q));l=function(a){L.hasOwnProperty(a)||(L[a]=w.wrap(a));q[q.length-1]=L[a]}}n>m&&p>m||(1E-5>p?1E-5>n?l("Staying inside singularity."):(l("Moved into singularity."),Ja=!0):1E-5>n?l("Moved out of singularity."):(vb?l("Reached refinement limit, giving up."):l("Need to refine."),Vb()));return h} -function Bd(a){var h=a.length,c,r;if(fb){for(c=0;c<h;++c)va+=2*a[c].value.length,T(a[c]);return a}var b=Array(h),d=Array(h),e=Array(h),f=99,l=99,m=Array(h);for(c=0;c<h;++c)b[c]=Z(a[c].value.length),d[c]=g.normSquared(b[c]).value.real,e[c]=g.normSquared(a[c]).value.real,m[c]=Array(h);var n;for(c=0;c<h;++c){for(r=0;r<h;++r)n=g.sesquilinearproduct(b[c],a[r]).value,n=(n.real*n.real+n.imag*n.imag)/(d[c]*e[r]),m[c][r]=1-n;for(r=c+1;r<h;++r)n=g.sesquilinearproduct(b[c],b[r]).value,n=(n.real*n.real+n.imag* -n.imag)/(d[c]*d[r]),f>1-n&&(f=1-n),n=g.sesquilinearproduct(a[c],a[r]).value,n=(n.real*n.real+n.imag*n.imag)/(e[c]*e[r]),l>1-n&&(l=1-n)}n=nc(m);r=Array(h);d=0;e=!1;for(c=0;c<h;++c){var d=d+m[c][n[c]],p=r[c]=a[n[c]];T(p);e|=g._helper.isNaN(p)}e|=isNaN(d);a=function(){};if(L&&L.currentStep){var q=[L.labelTracingSesq,w.wrap(L.currentElement.name),g.turnIntoCSList(r),g.turnIntoCSList(b),g.realMatrix(m),w.wrap(d),w.wrap(f),w.wrap(l),k];L.currentStep.push(g.turnIntoCSList(q));a=function(a){L.hasOwnProperty(a)|| -(L[a]=w.wrap(a));q[q.length-1]=L[a]}}e?(a("Tracing failed due to NaNs."),Ja=!0):f>3*d&&l>3*d?a("Normal case, everything all right."):1E-5>l?1E-5>f?a("Staying inside singularity."):(a("Moved into singularity."),Ja=!0):1E-5>f?a("Moved out of singularity."):(vb?a("Reached refinement limit, giving up."):a("Need to refine."),Vb());return r}function gb(a){if(gb.hasOwnProperty(a.kind))gb[a.kind](a)}function Cd(a,h){return function(){a.incidences.push(h.name);h.incidences.push(a.name)}}function Dd(a,h){return{toString:function(){return"point "+ -a.name+" incident line "+h.name},apply:Cd(a,h),holds:function(){var c=g.scaldiv(g.abs(a.homog),a.homog),r=g.scaldiv(g.abs(h.homog),h.homog);return 1E-13>l.abs(g.scalproduct(c,r)).value.real}}}function Ed(a,h){return{toString:function(){return"point "+a.name+" incident conic "+h.name},apply:Cd(a,h),holds:function(){var c=w.mult(h.matrix,a.homog),c=w.mult(a.homog,c),c=l.abs(c);1E-13>c.value.real&&(a.incidences.push(h.name),h.incidences.push(a.name))}}}function pd(){if(0!==ib.length){for(var a=0;a<ib.length;++a)ib[a].apply(); -ib=[]}}function yc(a,h,c){var r=document.createElement("div"),b=document.createElement("img");b.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAPoCAQAAAC1v1zVAAAAGklEQVR42u3BMQEAAADCoPVPbQ0PoAAAgHcDC7gAAVI8ZnwAAAAASUVORK5CYII=";r.className="CindyJS-baseline";r.appendChild(b);b=document.createElement("div");b.className="CindyJS-button";r.appendChild(b);for(var d=2;d<arguments.length;++d)b.appendChild(arguments[d]);ka.parentNode.appendChild(r);a.html=arguments[arguments.length-1];Fa(a.fillalpha)|| -(a.fillalpha=1);a.fillcolor&&(a.html.style.backgroundColor=x.makeColor(a.fillcolor,a.fillalpha));r=e;if(a.script)var g=Ra(a.script),r=function(){A(g);e()};c.addEventListener(h,r);!p.keylistener&&(S.keydown||S.keyup||S.keytyped)&&(c.addEventListener("keydown",function(a){9!==a.keyCode&&N(a,S.keydown)}),c.addEventListener("keyup",function(a){N(a,S.keyup)}),c.addEventListener("keypress",function(a){9!==a.keyCode&&N(a,S.keytyped)}));m.Text.initialize(a)}function Pa(){}function ie(a){if(!/^Select/.test(a.type)&& -!m[a.type].isMovable)return null;var h=w.unwrap,c=l.add;switch(a.kind){case "P":case "L":case "Text":return h(a.homog);case "C":return a=a.matrix.value,{xx:h(a[0].value[0]),yy:h(a[1].value[1]),zz:h(a[2].value[2]),xy:h(c(a[0].value[1],a[1].value[0])),xz:h(c(a[0].value[2],a[2].value[0])),yz:h(c(a[1].value[2],a[2].value[1]))};default:return null}}function je(a){var h={};h.offset=w.unwrap(a.offset);a.to&&(h.to=a.to);a.corner&&(h.corner=a.corner);return h}function ke(a){var h={};le.forEach(function(c){if(a.hasOwnProperty(c)){var b= -w.unwrap(a[c]);null!==b&&void 0!==b&&(h[c]=b)}});if("P"===a.kind&&(!a.movable||a.pinned)&&h.color){var c=l.real(1/la.dimDependent);h.color=w.unwrap(g.scalmult(c,a.color))}if(c=ie(a))h.pos=c;a.dock&&(h.dock=je(a.dock));return h}function me(){var a=[];u.gslp.forEach(function(h){h.tmp||a.push(ke(h))});return a}function Od(){Ba.forEach(function(a){var h=(a.geo||[]).map(function(a){return u.csnames[a]});O[a.type].reset(a,h[0],h)})}function ec(a){ic=0!==a.length;Ba=[];ga=[];zc=[];O.Environment.init({}); -a.forEach(function(a){a.behavior?(a.name&&(a.behavior.geo=[a.name]),a=a.behavior,a.gravity&&(a.gravity=-a.gravity)):c=a.geo;var c=(a.geo||[]).map(function(a){return u.csnames[a]}),r=c[0],b=O[a.type];b?(b.init&&b.init(a,r,c),r&&(r.behavior=a,"Mass"===a.type?ga.push(r):"Spring"===a.type&&zc.push(r)),Ba.push(a)):(console.error(a),console.error("Behavior "+a.type+" not implemented yet"))})}var wa=this,ia,S={},Ya=!1,Ob=!0,Cb=0,Oc=.5,hc=0,Mb=10,Fd=5/360,Pd=.32/Fd/1E3*2,Kb=1,Wa=0,bc=0,cc=!1,zb=!1,ka,yb, -Fa=Number.isFinite||function(a){return"number"===typeof a&&isFinite(a)},ta,y,da,ca,u,Xa,kc=k,lc=k,Sa={play:Pa,pause:Pa,stop:Pa},gc=null,Ab=function(a,h){var c=[];Ab=function(a,h){c.push({img:a,id:h})};Ab(a,h);var r=wa.getBaseDir()+"images/Icons.svg",b=new XMLHttpRequest;b.onreadystatechange=function(){if(b.readyState===XMLHttpRequest.DONE)if(200!==b.status)console.error("Failed to load CindyJS Icons.svg from "+r+": "+b.statusText);else{var a=b.responseXML,h=a.documentElement,d={},g,e;for(g=h.firstChild;g;g= -e)e=g.nextSibling,g.nodeType===Node.ELEMENT_NODE&&"http://www.w3.org/2000/svg"===g.namespaceURI&&"g"===g.localName.toLowerCase()&&(h.removeChild(g),g.setAttribute("style","display:inline"),d[g.getAttribute("id")]=g);var f=new XMLSerializer;Ab=function(c,r){if(d.hasOwnProperty(r)){var b=d[r];h.appendChild(b);var g;try{g=f.serializeToString(a)}finally{h.removeChild(b)}c.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(g)}};c.forEach(function(a){Ab(a.img,a.id)});c=null}};b.responseType="document"; -b.open("GET",r);b.send()},Pc=1,Bb=null,jb=[],jc=!1,oa={config:p,startup:W,shutdown:Qa,evokeCS:function(a){a=Ra(a,!1);console.log(a);A(a);e()},play:I,pause:Ca,stop:Da,evalcs:function(a){return A(Ra(a,!1))},parse:function(a){return Ra(a)},niceprint:ba,canvas:null},ac=!1,Lb=0;p.use&&p.use.forEach(function(a){var h=null;p.plugins&&(h=p.plugins[a]);h||(h=wa._pluginRegistry[a]);h||(++Lb,console.log("Loading script for plugin "+a),wa.loadScript(a+"-plugin",a+"-plugin.js",function(){console.log("Successfully loaded plugin "+ -a);0===--Lb&&ac&&W()},function(){console.error("Failed to auto-load plugin "+a);0===--Lb&&ac&&W()}))});xb.prototype=new ab;cb.prototype=new ab;qa.prototype=new ab;var X={},fa,Qc="",Rc=0,Pb;Pb=p.isNode?process.nextTick:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,0)};var mc=null,ne=[0,8,4,0,"gbb244ca"],l={_helper:{}};l._helper.roundingfactor=1E4;l._helper.angleroundingfactor= -10;l._helper.niceround=function(a,h){return Math.round(a*h)/h};l.niceprint=function(a,h){h=h||l._helper.roundingfactor;if("Angle"===a.usage)return l._helper.niceangle(a);var c=l._helper.niceround(a.value.real,h),r=l._helper.niceround(a.value.imag,h);return 0===r?""+c:0<r?""+c+" + i*"+r:""+c+" - i*"+-r};var Ac=p.angleUnit||"\u00b0",oe=Ac.replace(/\s+/g,""),Gd=2*Math.PI,pe=1/Gd,qe={rad:Gd,"\u00b0":360,deg:360,degree:360,gra:400,grad:400,turn:1,cyc:1,rev:1,rot:1,"\u03c0":2,pi:2,quad:4};l._helper.niceangle= -function(a){var h=qe[oe];if(!h)return l.niceprint(w.withUsage(a,null));if("function"===typeof h)return h(a);a=l.niceprint(l.realmult(h*pe,a),200<h?l._helper.angleroundingfactor:null);return-1===a.indexOf("i*")?a+Ac:"("+a+")"+Ac};l.complex=function(a,h){return{ctype:"number",value:{real:a,imag:h}}};l.real=function(a){return{ctype:"number",value:{real:a,imag:0}}};l.zero=l.real(0);l.one=l.real(1);l.infinity=l.complex(Infinity,Infinity);l.nan=l.complex(NaN,NaN);l._helper.input=function(a){return"object"=== -typeof a?l.complex(+a.r,+a.i):l.real(+a)};l.argmax=function(a,h){return a.value.real*a.value.real+a.value.imag*a.value.imag<h.value.real*h.value.real+h.value.imag*h.value.imag?h:a};l.max=function(a,h){return{ctype:"number",value:{real:Math.max(a.value.real,h.value.real),imag:Math.max(a.value.imag,h.value.imag)}}};l.min=function(a,h){return{ctype:"number",value:{real:Math.min(a.value.real,h.value.real),imag:Math.min(a.value.imag,h.value.imag)}}};l.add=function(a,h){return{ctype:"number",value:{real:a.value.real+ -h.value.real,imag:a.value.imag+h.value.imag}}};l.sub=function(a,h){return{ctype:"number",value:{real:a.value.real-h.value.real,imag:a.value.imag-h.value.imag}}};l.neg=function(a){return{ctype:"number",value:{real:-a.value.real,imag:-a.value.imag}}};l.re=function(a){return{ctype:"number",value:{real:a.value.real,imag:0}}};l.im=function(a){return{ctype:"number",value:{real:a.value.imag,imag:0}}};l.conjugate=function(a){return{ctype:"number",value:{real:a.value.real,imag:-a.value.imag}}};l.round=function(a){return{ctype:"number", -value:{real:Math.round(a.value.real),imag:Math.round(a.value.imag)}}};l.ceil=function(a){return{ctype:"number",value:{real:Math.ceil(a.value.real),imag:Math.ceil(a.value.imag)}}};l.floor=function(a){return{ctype:"number",value:{real:Math.floor(a.value.real),imag:Math.floor(a.value.imag)}}};l.mult=function(a,h){return{ctype:"number",value:{real:a.value.real*h.value.real-a.value.imag*h.value.imag,imag:a.value.real*h.value.imag+a.value.imag*h.value.real}}};l.realmult=function(a,h){return{ctype:"number", -value:{real:a*h.value.real,imag:a*h.value.imag}}};l.multiMult=function(a){var h=a[0];if("number"!==h.ctype)return k;for(var c=1;c<a.length;c++){if("number"!==a[c].ctype)return k;h=l.mult(h,a[c])}return h};l.abs2=function(a,h){return{ctype:"number",value:{real:a.value.real*a.value.real+a.value.imag*a.value.imag,imag:0}}};l.abs=function(a){return l.sqrt(l.abs2(a))};l.inv=function(a){var h=a.value.real*a.value.real+a.value.imag*a.value.imag;return{ctype:"number",value:{real:a.value.real/h,imag:-a.value.imag/ -h}}};l.div=function(a,h){var c=a.value.real,r=a.value.imag,b=h.value.real,d=h.value.imag,g=b*b+d*d;return{ctype:"number",value:{real:(c*b+r*d)/g,imag:(r*b-c*d)/g}}};l.eps=1E-10;l.epsbig=1E-6;l.snap=function(a){var h=a.value.real;a=a.value.imag;Math.floor(h+l.eps)!==Math.floor(h-l.eps)&&(h=Math.round(h));Math.floor(a+l.eps)!==Math.floor(a-l.eps)&&(a=Math.round(a));return{ctype:"number",value:{real:h,imag:a}}};l.exp=function(a){var h=Math.exp(a.value.real);return{ctype:"number",value:{real:h*Math.cos(a.value.imag), -imag:h*Math.sin(a.value.imag)}}};l.cos=function(a){var h=a.value.real;a=a.value.imag;var c=Math.exp(a),r=c*Math.sin(-h),b=c*Math.cos(-h),c=Math.exp(-a);return{ctype:"number",value:{real:(b+c*Math.cos(h))/2,imag:(r+c*Math.sin(h))/2}}};l.sin=function(a){var h=a.value.real;a=a.value.imag;var c=Math.exp(a),r=c*Math.sin(-h),b=c*Math.cos(-h),c=Math.exp(-a);return{ctype:"number",value:{real:-(r-c*Math.sin(h))/2,imag:(b-c*Math.cos(h))/2}}};l.tan=function(a){var h=l.sin(a);a=l.cos(a);return l.div(h,a)};l.arccos= -function(a){var h=l.mult(a,l.neg(a)),h=l.sqrt(l.add(l.real(1),h));a=l.add(l.mult(a,l.complex(0,1)),h);a=l.add(l.mult(l.log(a),l.complex(0,1)),l.real(.5*Math.PI));return w.withUsage(a,"Angle")};l.arcsin=function(a){var h=l.mult(a,l.neg(a)),h=l.sqrt(l.add(l.real(1),h));a=l.add(l.mult(a,l.complex(0,1)),h);a=l.mult(l.log(a),l.complex(0,-1));return w.withUsage(a,"Angle")};l.arctan=function(a){var h=l.log(l.add(l.mult(a,l.complex(0,-1)),l.real(1)));a=l.log(l.add(l.mult(a,l.complex(0,1)),l.real(1)));h=l.mult(l.sub(h, -a),l.complex(0,.5));return w.withUsage(h,"Angle")};l.arctan2=function(a,h){var c;if(void 0===h)c=l.real(Math.atan2(a.value.imag,a.value.real));else if(l._helper.isReal(a)&&l._helper.isReal(h))c=l.real(Math.atan2(h.value.real,a.value.real));else{c=l.add(a,l.mult(l.complex(0,1),h));var r=l.sqrt(l.add(l.mult(a,a),l.mult(h,h)));c=l.mult(l.complex(0,-1),l.log(l.div(c,r)))}return w.withUsage(c,"Angle")};l.sqrt=function(a){var h=a.value.real,c=a.value.imag;a=Math.sqrt(Math.sqrt(h*h+c*c));h=Math.atan2(c, -h);return{ctype:"number",value:{real:a*Math.cos(h/2),imag:a*Math.sin(h/2)}}};l.powRealExponent=function(a,h){var c=a.value.real,r=a.value.imag,b=Math.pow(Math.sqrt(c*c+r*r),h),c=Math.atan2(r,c);return{ctype:"number",value:{real:b*Math.cos(c*h),imag:b*Math.sin(c*h)}}};l.log=function(a){var h=a.value.real;a=a.value.imag;var c=Math.sqrt(h*h+a*a),r=Math.atan2(a,h);0>a&&(r+=2*Math.PI);0===a&&0>h&&(r=Math.PI);r>Math.PI&&(r-=2*Math.PI);return l.snap({ctype:"number",value:{real:Math.log(c),imag:r}})};l.pow= -function(a,h){return l._helper.isZero(h)?l.one:l._helper.isZero(a)?l.zero:l._helper.isReal(h)?l.powRealExponent(a,h.value.real):l.exp(l.mult(l.log(a),h))};l.mod=function(a,h){var c=a.value.real,r=h.value.real,b=a.value.imag,d=h.value.imag,c=c-Math.floor(c/r)*r,b=b-Math.floor(b/d)*d;0===r&&(c=0);0===d&&(b=0);return l.snap({ctype:"number",value:{real:c,imag:b}})};l._helper.seed="NO";l._helper.seedrandom=function(a){a-=Math.floor(a);l._helper.seed=.8*a+.1};l._helper.rand=function(){if("NO"===l._helper.seed)return Math.random(); -var a=l._helper.seed,a=1E3*Math.sin(1E3*a),a=a-Math.floor(a);return l._helper.seed=a};l._helper.randnormal=function(){var a=l._helper.rand(),h=l._helper.rand();return Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*h)};l._helper.isEqual=function(a,h){return a.value.real===h.value.real&&a.value.imag===h.value.imag};l._helper.isLessThan=function(a,h){return a.value.real<h.value.real||a.value.real===h.value.real&&a.value.imag<h.value.imag};l._helper.compare=function(a,h){return l._helper.isLessThan(a,h)? --1:l._helper.isEqual(a,h)?0:1};l._helper.isAlmostEqual=function(a,h,c){var r=l.eps;"undefined"!==typeof c&&(r=c);c=a.value.real-h.value.real;a=a.value.imag-h.value.imag;return c<r&&c>-r&&a<r&&a>-r};l._helper.isZero=function(a){return 0===a.value.real&&0===a.value.imag};l._helper.isAlmostZero=function(a){var h=a.value.real;a=a.value.imag;return h<l.eps&&h>-l.eps&&a<l.eps&&a>-l.eps};l._helper.isReal=function(a){return 0===a.value.imag};l._helper.isAlmostReal=function(a){a=a.value.imag;return a<l.epsbig&& -a>-l.epsbig};l._helper.isNaN=function(a){return isNaN(a.value.real)||isNaN(a.value.imag)};l._helper.isFinite=function(a){return isFinite(a.value.real)&&isFinite(a.value.imag)};l._helper.isAlmostImag=function(a){a=a.value.real;return a<l.epsbig&&a>-l.epsbig};l._helper.z3a=l.complex(-.5,.5*Math.sqrt(3));l._helper.z3b=l.complex(-.5,-.5*Math.sqrt(3));l._helper.cub1={ctype:"list",value:[l.one,l.one,l.one]};l._helper.cub2={ctype:"list",value:[l._helper.z3a,l.one,l._helper.z3b]};l._helper.cub3={ctype:"list", -value:[l._helper.z3b,l.one,l._helper.z3a]};l.solveCubic=function(a,h,c,r){a=l._helper.solveCubicHelper(a,h,c,r);return[g.scalproduct(l._helper.cub1,a),g.scalproduct(l._helper.cub2,a),g.scalproduct(l._helper.cub3,a)]};l._helper.solveCubicHelper=function(a,h,c,r){var b=a.value.real;a=a.value.imag;var d=h.value.real;h=h.value.imag;var e=c.value.real,f=c.value.imag,k=r.value.real,m=r.value.imag,n=b*e-a*f;c=b*f+a*e;r=4*n-(d*d-h*h);var p=4*c-2*d*h,q=b*d-a*h,t=b*h+a*d,v=r*e-p*f-18*(q*k-t*m),p=r*f+p*e-18* -(q*m+t*k);r=27*(b*b-a*a);var u=54*a*b,w=r*k-u*m,x=r*m+u*k,z=d*d-h*h,y=2*d*h,A=z*d-y*h,B=z*h+y*d,C=w+4*A,u=x+4*B;r=27*(v*e-p*f+C*k-u*m);p=27*(v*f+p*e+C*m+u*k);C=Math.sqrt(Math.sqrt(r*r+p*p));u=Math.atan2(p,r);p=C*Math.sin(u/2);r=C*Math.cos(u/2);A=-2*A+9*(q*e-t*f)-w+(r*b-p*a);B=-2*B+9*(q*f+t*e)-x+(r*a+p*b);r=Math.exp(Math.log(Math.sqrt(A*A+B*B))/3);e=Math.atan2(B,A);u=r*Math.sin(e/3);p=r*Math.cos(e/3);r*=r;e*=2;n=2*z-6*n;c=2*y-6*c;y=-1.5874010519681996*(d*p-h*u);d=-1.5874010519681996*(d*u+h*p);h=1.2599210498948732* -r*Math.cos(e/3);e=1.2599210498948732*r*Math.sin(e/3);r=4.762203155904599*(p*b-u*a);p=4.762203155904599*(p*a+u*b);b=r*r+p*p;u=(-n*p+c*r)/b;n=(n*r+c*p)/b;c=u;u=(-y*p+d*r)/b;y=(y*r+d*p)/b;d=u;u=(-h*p+e*r)/b;h=(h*r+e*p)/b;e=u;return g.turnIntoCSList([l.complex(n,c),l.complex(y,d),l.complex(h,e)])};var g={_helper:{},turnIntoCSList:function(a){return{ctype:"list",value:a}}};g.EMPTY=g.turnIntoCSList([]);g.asList=function(a){return"list"===a.ctype?a:"number"===a.ctype||"boolean"===a.ctype||"geo"===a.ctype? -g.turnIntoCSList([a]):g.EMPTY};g.realVector=function(a){for(var h=[],c=0;c<a.length;c++)h[c]={ctype:"number",value:{real:a[c],imag:0}};return{ctype:"list",value:h}};g._helper.unitvector=function(a,h){var c=g.zerovector(a);c.value[Math.floor(h.value.real-1)]=l.real(1);return c};g.idMatrix=function(a){for(var h=g.zeromatrix(a,a),c=l.real(1),r=0;r<a.value.real;r++)h.value[r].value[r]=c;return h};g._helper.flippedidMatrix=function(a){for(var h=g.zeromatrix(a,a),c=l.real(1),r=0;r<a.value.real;r++)h.value[r].value[a.value.real- -r-1]=c;return h};g.println=function(a){for(var h=[],c=0;c<a.value.length;c++)if("number"===a.value[c].ctype)h[c]=l.niceprint(a.value[c]);else if("list"===a.value[c].ctype)g.println(a.value[c]);else return k;"number"===a.value[0].ctype&&console.log(h)};g.matrix=function(a){return g.turnIntoCSList(a.map(g.turnIntoCSList))};g.realMatrix=function(a){for(var h=a.length,c=Array(h),r=0;r<h;r++)c[r]=g.realVector(a[r]);return g.turnIntoCSList(c)};g.ex=g.realVector([1,0,0]);g.ey=g.realVector([0,1,0]);g.ez= -g.realVector([0,0,1]);g.linfty=g.realVector([0,0,1]);g.ii=g.turnIntoCSList([l.complex(1,0),l.complex(0,1),l.complex(0,0)]);g.jj=g.turnIntoCSList([l.complex(1,0),l.complex(0,-1),l.complex(0,0)]);g.fundDual=g.realMatrix([[1,0,0],[0,1,0],[0,0,0]]);g.fund=g.realMatrix([[0,0,0],[0,0,0],[0,0,1]]);g.sequence=function(a,h){for(var c=[],r=0,b=Math.round(a.value.real);b<Math.round(h.value.real)+1;b++)c[r]={ctype:"number",value:{real:b,imag:0}},r++;return{ctype:"list",value:c}};g.pairs=function(a){for(var h= -[],c=0;c<a.value.length-1;c++)for(var r=c+1;r<a.value.length;r++)h.push({ctype:"list",value:[a.value[c],a.value[r]]});return{ctype:"list",value:h}};g.triples=function(a){for(var h=[],c=0;c<a.value.length-2;c++)for(var r=c+1;r<a.value.length-1;r++)for(var b=r+1;b<a.value.length;b++)h.push({ctype:"list",value:[a.value[c],a.value[r],a.value[b]]});return{ctype:"list",value:h}};g.cycle=function(a){for(var h=[],c=0;c<a.value.length-1;c++)h[c]={ctype:"list",value:[a.value[c],a.value[c+1]]};h.push({ctype:"list", -value:[a.value[a.value.length-1],a.value[0]]});return{ctype:"list",value:h}};g.consecutive=function(a){for(var h=[],c=0;c<a.value.length-1;c++)h[c]={ctype:"list",value:[a.value[c],a.value[c+1]]};return{ctype:"list",value:h}};g.reverse=function(a){for(var h=Array(a.value.length),c=a.value.length-1,r=0;0<=c;c--,r++)h[r]=a.value[c];return{ctype:"list",value:h}};g.directproduct=function(a,h){for(var c=[],r=0;r<a.value.length;r++)for(var b=0;b<h.value.length;b++)c.push({ctype:"list",value:[a.value[r], -h.value[b]]});return{ctype:"list",value:c}};g.concat=function(a,h){for(var c=[],r=0;r<a.value.length;r++)c.push(a.value[r]);for(r=0;r<h.value.length;r++)c.push(h.value[r]);return{ctype:"list",value:c}};g.prepend=function(a,h){var c=[];c[0]=a;for(var r=0;r<h.value.length;r++)c[r+1]=h.value[r];return{ctype:"list",value:c}};g.append=function(a,h){for(var c=[],r=0;r<a.value.length;r++)c[r]=a.value[r];c.push(h);return{ctype:"list",value:c}};g.contains=function(a,h){for(var c=0;c<a.value.length;c++)if(D.equals(a.value[c], -h).value)return{ctype:"boolean",value:!0};return{ctype:"boolean",value:!1}};g.common=function(a,h){for(var c=[],r=0,b=0;b<a.value.length;b++){for(var d=!1,g=a.value[b],e=0;e<h.value.length;e++)d=d||D.equals(g,h.value[e]).value;d&&(c[r]=a.value[b],r++)}return{ctype:"list",value:c}};g.remove=function(a,h){for(var c=[],r=0,b=0;b<a.value.length;b++){for(var d=!1,g=a.value[b],e=0;e<h.value.length;e++)d=d||D.equals(g,h.value[e]).value;d||(c[r]=a.value[b],r++)}return{ctype:"list",value:c}};g.sort1=function(a){a= -a.value.slice();a.sort(w.compare);return g.turnIntoCSList(a)};g._helper.isEqual=function(a,h){return g.equals(a,h).value};g._helper.isLessThan=function(a,h){for(var c=a.value.length,r=h.value.length,b=0;!(b>=c||b>=r)&&w.isEqual(a.value[b],h.value[b]);)b++;return b===c&&b<r?!0:b===r&&b<c||b===c&&b===r?!1:w.isLessThan(a.value[b],h.value[b])};g._helper.compare=function(a,h){return g._helper.isLessThan(a,h)?-1:g._helper.isEqual(a,h)?0:1};g.equals=function(a,h){if(a.value.length!==h.value.length)return{ctype:"boolean", -value:!1};for(var c=!0,r=0;r<a.value.length;r++)var b=a.value[r],d=h.value[r],c="list"===b.ctype&&"list"===d.ctype?c&&g.equals(b,d).value:c&&pb([b,d],[]).value;return{ctype:"boolean",value:c}};g.almostequals=function(a,h){if(a.value.length!==h.value.length)return{ctype:"boolean",value:!1};for(var c=!0,r=0;r<a.value.length;r++)var b=a.value[r],d=h.value[r],c="list"===b.ctype&&"list"===d.ctype?c&&g.almostequals(b,d).value:c&&Yb([b,d],[]).value;return{ctype:"boolean",value:c}};g._helper.isAlmostReal= -function(a){for(var h=!0,c=0;c<a.value.length;c++)var r=a.value[c],h="list"===r.ctype?h&&g._helper.isAlmostReal(r):h&&l._helper.isAlmostReal(r);return h};g._helper.isAlmostZero=function(a){for(var h=0;h<a.value.length;h++){var c=a.value[h];if("list"===c.ctype){if(!g._helper.isAlmostZero(c))return!1}else if(!l._helper.isAlmostZero(c))return!1}return!0};g._helper.isNaN=function(a){for(var h=!1,c=0;c<a.value.length;c++)var r=a.value[c],h="list"===r.ctype?h||g._helper.isNaN(r):h||l._helper.isNaN(r);return h}; -g.set=function(a){var h=[],c=0;a=a.value.slice();a.sort(w.compare);for(var r=0;r<a.length;r++)0!==r&&pb([h[h.length-1],a[r]],[]).value||(h[c]=a[r],c++);return{ctype:"list",value:h}};g.maxval=function(a){for(var h=l.zero,c=0;c<a.value.length;c++){var r=a.value[c];"number"===r.ctype&&(h=l.argmax(h,r));"list"===r.ctype&&(h=l.argmax(h,g.maxval(r)))}return h};g.maxIndex=function(a,h,c){var r=0;void 0!==c&&(r=c);c=r;for(var b=h(a.value[r]).value.real;r<a.value.length;++r){var d=h(a.value[r]).value.real; -d>b&&(c=r,b=d)}return c};g.normalizeMax=function(a){var h=l.inv(g.maxval(a));return l._helper.isFinite(h)?g.scalmult(h,a):a};g.normalizeZ=function(a){var h=l.inv(a.value[2]);return g.scalmult(h,a)};g.dehom=function(a){a=a.value.slice();var h=a.length-1,c=l.inv(a[h]);a.length=h;for(var r=0;r<h;++r)a[r]=l.mult(c,a[r]);return g.turnIntoCSList(a)};g.normalizeAbs=function(a){var h=l.inv(g.abs(a));return g.scalmult(h,a)};g.max=function(a,h){if(a.value.length!==h.value.length)return k;for(var c=[],r=0;r< -a.value.length;r++)c[r]=w.max(a.value[r],h.value[r]);return{ctype:"list",value:c}};g.min=function(a,h){if(a.value.length!==h.value.length)return k;for(var c=[],r=0;r<a.value.length;r++)c[r]=w.min(a.value[r],h.value[r]);return{ctype:"list",value:c}};g.scaldiv=function(a,h){if("number"!==a.ctype)return k;for(var c=[],r=0;r<h.value.length;r++){var b=h.value[r];c[r]="number"===b.ctype?w.div(b,a):"list"===b.ctype?g.scaldiv(a,b):k}return{ctype:"list",value:c}};g.scalmult=function(a,h){if("number"!==a.ctype)return k; -for(var c=[],r=0;r<h.value.length;r++){var b=h.value[r];c[r]="number"===b.ctype?w.mult(b,a):"list"===b.ctype?g.scalmult(a,b):k}return{ctype:"list",value:c}};g.add=function(a,h){if(a.value.length!==h.value.length)return k;for(var c=[],r=0;r<a.value.length;r++){var b=a.value[r],d=h.value[r];c[r]="number"===b.ctype&&"number"===d.ctype?w.add(b,d):"list"===b.ctype&&"list"===d.ctype?g.add(b,d):k}return{ctype:"list",value:c}};g.sub=function(a,h){if(a.value.length!==h.value.length)return k;for(var c=[],r= -0;r<a.value.length;r++){var b=a.value[r],d=h.value[r];c[r]="number"===b.ctype&&"number"===d.ctype?l.sub(b,d):"list"===b.ctype&&"list"===d.ctype?g.sub(b,d):k}return{ctype:"list",value:c}};g.abs2=function(a){for(var h=0,c=0;c<a.value.length;c++){var r=a.value[c];if("number"===r.ctype)h+=l.abs2(r).value.real;else if("list"===r.ctype)h+=g.abs2(r).value.real;else return k}return{ctype:"number",value:{real:h,imag:0}}};g.abs=function(a){return l.sqrt(g.abs2(a))};g.normalizeMaxXX=function(a){for(var h=-1E4, -c=l.real(1),r=0;r<a.value.length;r++){var b=l.abs(a.value[r]);b.value.real>h&&(c=a.value[r],h=b.value.real)}return g.scaldiv(c,a)};g.recursive=function(a,h){for(var c=[],r=0;r<a.value.length;r++){var b=B(a.value[r]);c[r]="number"===b.ctype?l[h](b):"list"===b.ctype?g[h](b):k}return{ctype:"list",value:c}};g.re=function(a){return g.recursive(a,"re")};g.neg=function(a){return g.recursive(a,"neg")};g.im=function(a){return g.recursive(a,"im")};g.conjugate=function(a){return g.recursive(a,"conjugate")}; -g.transjugate=function(a){return g.transpose(g.conjugate(a))};g.round=function(a){return g.recursive(a,"round")};g.ceil=function(a){return g.recursive(a,"ceil")};g.floor=function(a){return g.recursive(a,"floor")};g._helper.colNumb=function(a){if("list"!==a.ctype)return-1;for(var h=-1,c=0;c<a.value.length;c++){if("list"!==a.value[c].ctype)return-1;if(0===c)h=a.value[c].value.length;else if(h!==a.value[c].value.length)return-1}return h};g._helper.isNumberVecN=function(a,h){if("list"!==a.ctype||a.value.length!== -h)return!1;for(var c=0;c<a.value.length;c++)if("number"!==a.value[c].ctype)return!1;return!0};g.isNumberVector=function(a){if("list"!==a.ctype)return{ctype:"boolean",value:!1};for(var h=0;h<a.value.length;h++)if("number"!==a.value[h].ctype)return{ctype:"boolean",value:!1};return{ctype:"boolean",value:!0}};g.isNumberVectorN=function(a,h){if("list"!==a.ctype)return{ctype:"boolean",value:!1};if(a.value)for(var c=0;c<a.value.length;c++)if("number"!==a.value[c].ctype)return{ctype:"boolean",value:!1};return{ctype:"boolean", -value:!0}};g.isNumberMatrix=function(a){if(-1===g._helper.colNumb(a))return{ctype:"boolean",value:!1};for(var h=0;h<a.value.length;h++)if(!g.isNumberVector(a.value[h]).value)return{ctype:"boolean",value:!1};return{ctype:"boolean",value:!0}};g._helper.isNumberMatrixMN=function(a,h,c){return g.isNumberMatrix(a).value&&a.value.length===h&&a.value[0].value.length===c};g.scalproduct=function(a,h){if(a.value.length!==h.value.length)return k;for(var c={ctype:"number",value:{real:0,imag:0}},r=0;r<h.value.length;r++){var b= -a.value[r],d=h.value[r];if("number"===b.ctype&&"number"===d.ctype)c=l.add(l.mult(b,d),c);else return k}return c};g.sesquilinearproduct=function(a,h){if(a.value.length!==h.value.length)return k;for(var c=0,r=0,b=0;b<h.value.length;b++)var d=a.value[b].value,g=h.value[b].value,c=c+(d.real*g.real+d.imag*g.imag),r=r+(d.real*g.imag-d.imag*g.real);return l.complex(c,r)};g.normSquared=function(a){for(var h=0,c=0;c<a.value.length;c++)var r=a.value[c].value,h=h+(r.real*r.real+r.imag*r.imag);return l.real(h)}; -g.productMV=function(a,h){if(a.value[0].value.length!==h.value.length)return k;for(var c=[],r=0;r<a.value.length;r++){for(var b={ctype:"number",value:{real:0,imag:0}},d=a.value[r],e=0;e<h.value.length;e++){var f=d.value[e],m=h.value[e];if("number"===f.ctype&&"number"===m.ctype)b=l.add(l.mult(f,m),b);else return k}c[r]=b}return g.turnIntoCSList(c)};g.productVM=function(a,h){if(a.value.length!==h.value.length)return k;for(var c=[],b=0;b<h.value[0].value.length;b++){for(var d={ctype:"number",value:{real:0, -imag:0}},e=0;e<a.value.length;e++){var f=a.value[e],m=h.value[e].value[b];if("number"===f.ctype&&"number"===m.ctype)d=l.add(l.mult(f,m),d);else return k}c[b]=d}return g.turnIntoCSList(c)};g.productMM=function(a,h){if(a.value[0].value.length!==h.value.length)return k;for(var c=[],b=0;b<a.value.length;b++){var d=g.productVM(a.value[b],h);c[b]=d}return g.turnIntoCSList(c)};g.mult=function(a,h){return a.value.length===h.value.length&&g.isNumberVector(a).value&&g.isNumberVector(h).value?g.scalproduct(a, -h):g.isNumberMatrix(a).value&&h.value.length===a.value[0].value.length&&g.isNumberVector(h).value?g.productMV(a,h):g.isNumberMatrix(h).value&&a.value.length===h.value.length&&g.isNumberVector(a).value?g.productVM(a,h):g.isNumberMatrix(a).value&&g.isNumberMatrix(h).value&&h.value.length===a.value[0].value.length?g.productMM(a,h):k};g.projectiveDistMinScal=function(a,h){var c=g.abs(a),b=g.abs(h);if(0===c.value.real||0===b.value.real)return 0;var d=g.conjugate(h),d=g.scalproduct(a,d),d=l._helper.isAlmostZero(d)? -l.real(1):l.div(d,l.abs(d)),c=g.scaldiv(c,a),b=g.scaldiv(b,h),b=g.scalmult(d,b),d=g.abs(g.add(c,b)),b=g.abs(g.sub(c,b));return Math.min(d.value.real,b.value.real)};g.conicDist=function(a,h){var c=v(a),b=v(h);console.log(ba(c),ba(b));return g.projectiveDistMinScal(c,b)};g.crossOperator=function(a){var h=a.value[0],c=a.value[1];a=a.value[2];return g.turnIntoCSList([g.turnIntoCSList([l.zero,l.neg(a),c]),g.turnIntoCSList([a,l.zero,l.neg(h)]),g.turnIntoCSList([l.neg(c),h,l.zero])])};g.cross=function(a, -h){var c=l.sub(l.mult(a.value[1],h.value[2]),l.mult(a.value[2],h.value[1])),b=l.sub(l.mult(a.value[2],h.value[0]),l.mult(a.value[0],h.value[2])),d=l.sub(l.mult(a.value[0],h.value[1]),l.mult(a.value[1],h.value[0]));return g.turnIntoCSList([c,b,d])};g.crossratio3harm=function(a,h,c,b,d){var e=g.det3(a,c,d),f=g.det3(h,b,d);a=g.det3(a,b,d);h=g.det3(h,c,d);e=l.mult(e,f);f=l.mult(a,h);return g.turnIntoCSList([e,f])};g.crossratio3=function(a,h,c,b,d){a=g.crossratio3harm(a,h,c,b,d);return l.div(a.value[0], -a.value[1])};g.veronese=function(a){var h=l.mult(a.value[0],a.value[0]),c=l.mult(a.value[1],a.value[1]),b=l.mult(a.value[2],a.value[2]),d=l.mult(a.value[0],a.value[1]),e=l.mult(a.value[0],a.value[2]);a=l.mult(a.value[1],a.value[2]);return g.turnIntoSCList([h,c,b,d,e,a])};g.matrixFromVeronese=function(a){var h=a.value[0],c=a.value[1],b=a.value[2],d=l.realmult(.5,a.value[3]),e=l.realmult(.5,a.value[4]);a=l.realmult(.5,a.value[5]);return g.turnIntoCSList([g.turnIntoCSList([h,d,e]),g.turnIntoCSList([d, -c,a]),g.turnIntoCSList([e,a,b])])};g.det2=function(a,h){var c=l.mult(a.value[0],h.value[1]);return c=l.sub(c,l.mult(a.value[1],h.value[0]))};g.det3=function(a,h,c){return l.complex(a.value[0].value.real*h.value[1].value.real*c.value[2].value.real-a.value[0].value.imag*h.value[1].value.imag*c.value[2].value.real-a.value[0].value.imag*h.value[1].value.real*c.value[2].value.imag-a.value[0].value.real*h.value[1].value.imag*c.value[2].value.imag+a.value[2].value.real*h.value[0].value.real*c.value[1].value.real- -a.value[2].value.imag*h.value[0].value.imag*c.value[1].value.real-a.value[2].value.imag*h.value[0].value.real*c.value[1].value.imag-a.value[2].value.real*h.value[0].value.imag*c.value[1].value.imag+a.value[1].value.real*h.value[2].value.real*c.value[0].value.real-a.value[1].value.imag*h.value[2].value.imag*c.value[0].value.real-a.value[1].value.imag*h.value[2].value.real*c.value[0].value.imag-a.value[1].value.real*h.value[2].value.imag*c.value[0].value.imag-a.value[0].value.real*h.value[2].value.real* -c.value[1].value.real+a.value[0].value.imag*h.value[2].value.imag*c.value[1].value.real+a.value[0].value.imag*h.value[2].value.real*c.value[1].value.imag+a.value[0].value.real*h.value[2].value.imag*c.value[1].value.imag-a.value[2].value.real*h.value[1].value.real*c.value[0].value.real+a.value[2].value.imag*h.value[1].value.imag*c.value[0].value.real+a.value[2].value.imag*h.value[1].value.real*c.value[0].value.imag+a.value[2].value.real*h.value[1].value.imag*c.value[0].value.imag-a.value[1].value.real* -h.value[0].value.real*c.value[2].value.real+a.value[1].value.imag*h.value[0].value.imag*c.value[2].value.real+a.value[1].value.imag*h.value[0].value.real*c.value[2].value.imag+a.value[1].value.real*h.value[0].value.imag*c.value[2].value.imag,-a.value[0].value.imag*h.value[1].value.imag*c.value[2].value.imag+a.value[0].value.imag*h.value[1].value.real*c.value[2].value.real+a.value[0].value.real*h.value[1].value.real*c.value[2].value.imag+a.value[0].value.real*h.value[1].value.imag*c.value[2].value.real- -a.value[2].value.imag*h.value[0].value.imag*c.value[1].value.imag+a.value[2].value.imag*h.value[0].value.real*c.value[1].value.real+a.value[2].value.real*h.value[0].value.real*c.value[1].value.imag+a.value[2].value.real*h.value[0].value.imag*c.value[1].value.real-a.value[1].value.imag*h.value[2].value.imag*c.value[0].value.imag+a.value[1].value.imag*h.value[2].value.real*c.value[0].value.real+a.value[1].value.real*h.value[2].value.real*c.value[0].value.imag+a.value[1].value.real*h.value[2].value.imag* -c.value[0].value.real+a.value[0].value.imag*h.value[2].value.imag*c.value[1].value.imag-a.value[0].value.imag*h.value[2].value.real*c.value[1].value.real-a.value[0].value.real*h.value[2].value.real*c.value[1].value.imag-a.value[0].value.real*h.value[2].value.imag*c.value[1].value.real+a.value[2].value.imag*h.value[1].value.imag*c.value[0].value.imag-a.value[2].value.imag*h.value[1].value.real*c.value[0].value.real-a.value[2].value.real*h.value[1].value.real*c.value[0].value.imag-a.value[2].value.real* -h.value[1].value.imag*c.value[0].value.real+a.value[1].value.imag*h.value[0].value.imag*c.value[2].value.imag-a.value[1].value.imag*h.value[0].value.real*c.value[2].value.real-a.value[1].value.real*h.value[0].value.real*c.value[2].value.imag-a.value[1].value.real*h.value[0].value.imag*c.value[2].value.real)};g.det4m=function(a){var h=a.value,c=h[0].value,b=c[0].value,d=+b.real,g=+b.imag,b=c[1].value,e=+b.real,f=+b.imag,b=c[2].value,k=+b.real,m=+b.imag,b=c[3].value,n=+b.real,p=+b.imag,c=h[1].value, -b=c[0].value,q=+b.real,t=+b.imag,b=c[1].value,u=+b.real,v=+b.imag,b=c[2].value,w=+b.real,x=+b.imag,b=c[3].value,c=+b.real,b=+b.imag;a=d*u-g*v-e*q+f*t;var y=d*v+g*u-e*t-f*q,z=d*w-g*x-k*q+m*t,A=d*x+g*w-k*t-m*q,B=d*c-g*b-n*q+p*t,C=d*b+g*c-n*t-p*q,D=e*w-f*x-k*u+m*v,E=e*x+f*w-k*v-m*u,F=e*c-f*b-n*u+p*v,G=e*b+f*c-n*v-p*u,H=k*c-m*b-n*w+p*x,L=k*b+m*c-n*x-p*w,c=h[2].value,b=c[0].value,d=+b.real,g=+b.imag,b=c[1].value,e=+b.real,f=+b.imag,b=c[2].value,k=+b.real,m=+b.imag,b=c[3].value,n=+b.real,p=+b.imag,c=h[3].value, -b=c[0].value,q=+b.real,t=+b.imag,b=c[1].value,u=+b.real,v=+b.imag,b=c[2].value,w=+b.real,x=+b.imag,b=c[3].value,c=+b.real,b=+b.imag,h=d*u-g*v-e*q+f*t,J=d*v+g*u-e*t-f*q,I=d*w-g*x-k*q+m*t,K=d*x+g*w-k*t-m*q,M=d*c-g*b-n*q+p*t,d=d*b+g*c-n*t-p*q,g=e*w-f*x-k*u+m*v,q=e*x+f*w-k*v-m*u,t=e*c-f*b-n*u+p*v,e=e*b+f*c-n*v-p*u,f=k*c-m*b-n*w+p*x,k=k*b+m*c-n*x-p*w;return l.complex(a*f-y*k-z*t+A*e+B*g-C*q+D*M-E*d-F*I+G*K+H*h-L*J,a*k+y*f-z*e-A*t+B*q+C*g+D*d+E*M-F*K-G*I+H*J+L*h)};g.eucangle=function(a,h){var c=g.cross(a, -g.linfty),b=g.cross(h,g.linfty),d=g.det3(g.ez,c,g.ii),c=g.det3(g.ez,c,g.jj),e=g.det3(g.ez,b,g.ii),b=g.det3(g.ez,b,g.jj),d=l.div(l.mult(d,b),l.mult(e,c)),d=l.log(d);return d=l.mult(d,l.complex(0,.5))};g.zerovector=function(a){a=Math.floor(a.value.real);for(var h=Array(a),c=0;c<a;c++)h[c]=0;return g.realVector(h)};g.zeromatrix=function(a,h){for(var c=Math.floor(a.value.real),b=Array(c),d=0;d<c;d++)b[d]=g.zerovector(h);return g.turnIntoCSList(b)};g.vandermonde=function(a){for(var h=a.value.length,c= -g.zeromatrix(h,h),b=0;b<h;b++)for(var d=0;d<h;d++)c.value[b].value[d]=l.pow(a.value[b],l.real(d-1));return c};g.transpose=function(a){for(var h=[],c=a.value[0].value.length,b=a.value.length,d=0;d<c;d++){for(var e=[],f=0;f<b;f++)e[f]=a.value[f].value[d];h[d]=g.turnIntoCSList(e)}return g.turnIntoCSList(h)};g.column=function(a,h){for(var c=[],b=a.value.length,d=Math.floor(h.value.real-1),e=0;e<b;e++)c[e]=a.value[e].value[d];return g.turnIntoCSList(c)};g.row=function(a,h){for(var c=[],b=a.value[0].value.length, -d=Math.floor(h.value.real-1),e=0;e<b;e++)c[e]=a.value[d].value[e];return g.turnIntoCSList(c)};g.adjoint2=function(a){var h=a.value[0].value[0],c=a.value[1].value[0],b=Array(2);b[0]=g.turnIntoCSList([a.value[1].value[1],l.neg(a.value[0].value[1])]);b[1]=g.turnIntoCSList([l.neg(c),h]);return b=g.turnIntoCSList(b)};g.adjoint3=function(a){var h,c,b,d,g,e,f,k,l,m,n,p,q,t,u,v,w;h=a.value[0].value;c=h[0].value;b=c.real;d=c.imag;c=h[1].value;g=c.real;e=c.imag;c=h[2].value;f=c.real;k=c.imag;h=a.value[1].value; -c=h[0].value;l=c.real;m=c.imag;c=h[1].value;n=c.real;p=c.imag;c=h[2].value;q=c.real;t=c.imag;h=a.value[2].value;c=h[0].value;a=c.real;u=c.imag;c=h[1].value;v=c.real;w=c.imag;c=h[2].value;h=c.real;c=c.imag;return{ctype:"list",value:[{ctype:"list",value:[{ctype:"number",value:{real:n*h-q*v-p*c+t*w,imag:n*c-q*w-v*t+h*p}},{ctype:"number",value:{real:-g*h+f*v+e*c-k*w,imag:-g*c+f*w+v*k-h*e}},{ctype:"number",value:{real:g*q-f*n-e*t+k*p,imag:g*t-f*p-n*k+q*e}}]},{ctype:"list",value:[{ctype:"number",value:{real:-l* -h+q*a+m*c-t*u,imag:-l*c+q*u+a*t-h*m}},{ctype:"number",value:{real:b*h-f*a-d*c+k*u,imag:b*c-f*u-a*k+h*d}},{ctype:"number",value:{real:-b*q+f*l+d*t-k*m,imag:-b*t+f*m+l*k-q*d}}]},{ctype:"list",value:[{ctype:"number",value:{real:l*v-n*a-m*w+p*u,imag:l*w-n*u-a*p+v*m}},{ctype:"number",value:{real:-b*v+g*a+d*w-e*u,imag:-b*w+g*u+a*e-v*d}},{ctype:"number",value:{real:b*n-g*l-d*p+e*m,imag:b*p-g*m-l*e+n*d}}]}]}};g.inverse=function(a){var h=a.value.length;if(h!==a.value[0].value.length)return console.log("Inverse works only for square matrices"), -k;if(2===h)return g.scaldiv(g.det(a),g.adjoint2(a));if(3===h)return g.scaldiv(g.det(a),g.adjoint3(a));h=g.LUdecomp(a);a=a.value.length;var c=l.real(0),b=l.real(1),d=g.zerovector(l.real(a));d.value[0]=b;for(var e=Array(a),f=0;f<a;f++)e[f]=g._helper.LUsolve(h,d),d.value[f]=c,d.value[f+1]=b;e=g.turnIntoCSList(e);return e=g.transpose(e)};g.linearsolve=function(a,h){return 2===a.value.length?g.linearsolveCramer2(a,h):3===a.value.length?g.linearsolveCramer3(a,h):g.LUsolve(a,h)};g.getDiag=function(a){if(a.value.length!== -a.value[0].value.length)return k;for(var h=Array(a.value.length),c=0;c<a.value.length;c++)h[c]=a.value[c].value[c];return g.turnIntoCSList(h)};g.getSubDiag=function(a){if(a.value.length!==a.value[0].value.length)return k;for(var h=Array(a.value.length-1),c=0;c<a.value.length-1;c++)h[c]=a.value[c+1].value[c];return g.turnIntoCSList(h)};g.eig2=function(a){var h=l.add(a.value[0].value[0],a.value[1].value[1]);a=g.det2(a.value[0],a.value[1]);var c=l.mult(h,h),b=h=l.mult(h,l.real(.5));a=l.sqrt(l.sub(l.div(c, -l.real(4)),a));h=l.add(h,a);b=l.sub(b,a);return g.turnIntoCSList([h,b])};g.eig=function(a,h){var c=h||!0,b=a,d=l.real(b.value.length),e=d.value.real;l.real(0);var b=g._helper.QRIteration(b)[0],b=g.getDiag(b),b=g.sort1(b),d=g.idMatrix(d,d),f=Array(e),f=g.turnIntoCSList(f);if(c){for(var k,m,n,p=0,q=!1,c=0;c<e;c++)q?m=k.value[p]:(k=b.value[c],k=g.sub(a,g.scalmult(k,d)),k=g.nullSpace(k),m=k.value[0],void 0!==m&&(n=m)),void 0===m&&(m=n),1E-8>g.abs(m).value.real&&0===p&&(m=g._helper.inverseIteration(a, -b.value[c])),f.value[c]=g._helper.isAlmostZeroVec(m)?m:g.scaldiv(g.abs(m),m),c<e-1&&((q=1E-6>l.abs(l.sub(b.value[c],b.value[c+1])).value.real)?p++:p=0);f=g.transpose(f)}return g.turnIntoCSList([b,f])};g._helper.isNormalMatrix=function(a){return 1E-10>g.abs(g.sub(a,g.transjugate(a))).value.real};g._helper.QRIteration=function(a,h){var c,b=a;c=l.real(b.value.length);var d=c.value.real,e=c.value.real;l.real(0);var f;g.idMatrix(c,c);var k=g.zeromatrix(c,c),m=g.idMatrix(c,c),n=h?h:2500,p,q,t,u=0,v=Array(e); -for(c=0;c<n;c++){f=g._helper.getBlock(b,[e-2,e-1],[e-2,e-1]);p=g.eig2(f);f=p.value[0];p=p.value[1];g.abs(f);g.abs(p);q=b.value[e-1].value[e-1];t=l.abs(l.sub(q,f)).value.real;q=l.abs(l.sub(q,p)).value.real;p=t<q?f:p;f=g.idMatrix(l.real(e),l.real(e));p=g.scalmult(p,f);f=g.QRdecomp(g.sub(b,p));b=w.mult(f.R,f.Q);b=g.add(b,p);f.Q=g._helper.buildBlockMatrix(f.Q,g.idMatrix(l.real(u),l.real(u)));m=w.mult(m,f.Q);if(1E-48>l.abs2(b.value[b.value.length-1].value[b.value[0].value.length-2]).value.real&&1<e){v[d- -u-1]=b.value[e-1].value[e-1];for(c=0;c<e;c++)k.value[e-1].value[c]=b.value[e-1].value[c],k.value[c].value[e-1]=b.value[c].value[e-1];b=g._helper.getBlock(b,[0,e-2],[0,e-2]);u++;e--}if(1===e){k.value[0].value[0]=b.value[0].value[0];break}if(g._helper.isUpperTriangular(b)){for(c=0;c<e;c++)k.value[c].value[c]=b.value[c].value[c];break}}return[k,m]};g.rank=function(a,h){return g.RRQRdecomp(a,h).rank};g._helper.isAlmostZeroVec=function(a){for(var h=a.value.length,c=0;c<h;c++)if(!l._helper.isAlmostZero(a.value[c]))return!1; -return!0};g._helper.isLowerTriangular=function(a){for(var h=a.value.length,c=a.value[0].value.length,b=0;b<h;b++)for(var d=b+1;d<c;d++)if(!l._helper.isAlmostZero(a.value[b].value[d]))return!1;return!0};g._helper.isUpperTriangular=function(a){return g._helper.isLowerTriangular(g.transpose(a))};g._helper.isAlmostId=function(a){var h=a.value.length,c=l.real(h);if(h!==a.value[0].value.length)return!1;a=g.sub(a,g.idMatrix(c),c);for(c=0;c<h;c++)for(var b=0;b<h;b++)if(1E-16<l.abs(a.value[c].value[b]).value.real)return!1; -return!0};g.nullSpace=function(a,h){var c=a.value.length,b=g.RRQRdecomp(g.transjugate(a),h),d=g.transpose(b.Q),b=c-b.rank.value.real,e=Array(b);d.value.reverse();for(var f,k=0;k<b;k++)f=d.value[k],e[k]=g.scaldiv(g.abs(f),f);e=g.turnIntoCSList(e);return 0<e.value.length?e:g.turnIntoCSList([g.zerovector(l.real(c))])};g._helper.isAlmostDiagonal=function(a){var h=a.value.length;l.real(h);l.real(0);if(h!==a.value[0].value.length)return!1;for(var c=0;c<h;c++)for(var b=0;b<h;b++)if(c!==b&&1E-16<l.abs(a.value[c].value[b]).value.real)return!1; -return!0};g._helper.inverseIteration=function(a,h){console.log("warning: code untested");for(var c=a.value.length,b=Array(c),d=0;d<c;d++)b[d]=2*Math.random()-.5;for(var b=g.realVector(b),c=g.idMatrix(l.real(c),l.real(c)),d=l.add(h,l.real(.1*Math.random()-.5)),e=0;100>e;e++)b=g.scaldiv(g.abs(b),b),b=g.LUsolve(g.sub(a,g.scalmult(d,c)),JSON.parse(JSON.stringify(b)));return g.scaldiv(g.abs(b),b)};g._helper.toHessenberg=function(a){var h=JSON.parse(JSON.stringify(a)),c=h.value.length,b=l.real(c-1),d=l.real(c); -l.real(1);if(g._helper.isUpperTriangular(h))return[g.idMatrix(b,b),a];var e;a=g.idMatrix(d,d);for(var f,d=1;d<c-1;d++)e=g.column(h,l.real(d)),e.value=e.value.splice(d),f=g.abs2(e).value.real,1E-16<f&&(e=g._helper.getHouseHolder(e),a=w.mult(a,e),h=w.mult(w.mult(e,h),e)),b.value.real--;return[a,h]};g._helper.swapEl=function(a,h,c){var b;"[object Array]"===Object.prototype.toString.call(a)?(b=a[h],a[h]=a[c],a[c]=b):"list"===a.ctype&&(b=a.value[h],a.value[h]=a.value[c],a.value[c]=b)};g.RRQRdecomp=function(a, -h){var c=Math.sqrt(l.eps);void 0!==h&&(c=.1*h.value.real);var c=c*c,b,d=a.value.length,e=l.real(d),f=l.real(1),k=g._helper.unitvector(l.real(a.value.length),f),m=g.idMatrix(e,e),n=JSON.parse(JSON.stringify(a)),p=g.transpose(a),q=Array(d);for(b=0;b<d;b++)q[b]=g.abs2(p.value[b]);q=g.turnIntoCSList(q);p=Array(d);for(b=0;b<d;b++)p[b]=b;b=g.maxIndex(q,l.abs);for(var t=q.value[b],u=0,v=0;1E-16<l.abs2(t).value.real;v++){u++;g._helper.swapColumn(n,v,b);g._helper.swapEl(q,v,b);g._helper.swapEl(p,v,b);b=g._helper.getBlock(n, -[v],[v]);b=g.column(b,f);t=g.abs2(b).value.real;1E-8<t&&(b=g._helper.getHouseHolder(b),b=g._helper.buildBlockMatrix(g.idMatrix(l.real(v),l.real(v)),b),m=w.mult(m,g.transjugate(b)),n=w.mult(b,n));for(b=v+1;b<d;b++)q.value[b]=l.sub(q.value[b],l.mult(n.value[v].value[b],l.conjugate(n.value[v].value[b])));b=g.maxIndex(q,l.abs2,v+1);t=q.value[b];if(v+2===d){l.abs(t).value.real>c&&u++;break}e=l.sub(e,f);k.value=k.value.splice(0,k.value.length-1)}return{Q:m,R:n,P:g.turnIntoCSList(p),rank:l.real(u)}};g._helper.getHouseHolder= -function(a){var h=l.real(a.value.length);if(1E-16>g.abs2(a))return g.idMatrix(h,h);var c,b=l.real(1),d=g._helper.unitvector(l.real(a.value.length),b);c=g._helper.QRgetAlpha(a,0);c=g.sub(a,g.scalmult(c,d));c=g.scaldiv(g.abs(c),c);a=l.div(g.sesquilinearproduct(a,c),g.sesquilinearproduct(c,a));h=g.idMatrix(h,h);return h=g.sub(h,g.scalmult(l.add(b,a),g._helper.transposeMult(c,g.conjugate(c))))};g._helper.reOrderbyPivots=function(a,h){for(var c=a.value.length.length,b=g.transpose(a),c=Array(c),d=0;d<h.length;d++)c[h[d]]= -b.value[d];c=g.turnIntoCSList(c);return g.transpose(c)};g.QRdecomp=function(a){var h,c=a.value.length,b=l.real(c);if(g._helper.isUpperTriangular(a))return{Q:g.idMatrix(b,b),R:a};var d=l.real(1),e=g._helper.unitvector(l.real(a.value.length),d),f,k=g.idMatrix(b,b);a=JSON.parse(JSON.stringify(a));for(var m=0;;m++){h=g._helper.getBlock(a,[m],[m]);h=g.column(h,d);f=g.abs2(h).value.real;1E-8<f&&(h=g._helper.getHouseHolder(h),h=g._helper.buildBlockMatrix(g.idMatrix(l.real(m),l.real(m)),h),k=w.mult(k,g.transjugate(h)), -a=w.mult(h,a));if(m+2===c)break;b=l.sub(b,d);e.value=e.value.splice(0,e.value.length-1)}return{Q:k,R:a}};g._helper.swapColumn=function(a,h,c){for(var b,d=0;d<a.value.length;d++)b=a.value[d].value[h],a.value[d].value[h]=a.value[d].value[c],a.value[d].value[c]=b};g._helper.buildBlockMatrix=function(a,h){if(0===a.value.length)return h;if(0===h.value.length)return a;for(var c=a.value.length,b=a.value[0].value.length,d=b+h.value[0].value.length,d=g.zeromatrix(l.real(c+h.value.length),l.real(d)),e=0;e< -a.value.length;e++)for(var f=0;f<a.value[0].value.length;f++)d.value[e].value[f]=a.value[e].value[f];for(e=0;e<h.value.length;e++)for(f=0;f<h.value[0].value.length;f++)d.value[c+e].value[b+f]=h.value[e].value[f];return d};g._helper.getBlock=function(a,h,c){a=JSON.parse(JSON.stringify(a));var b=h[0],d=c[0];h=void 0===h[1]?a.value.length:h[1];c=void 0===c[1]?a.value[0].value.length:c[1];h++;c++;a.value=a.value.slice(b,h);for(b=0;b<a.value.length;b++)a.value[b].value=a.value[b].value.slice(d,c);return a}; -g._helper.setBlock=function(a,h,c){a=JSON.parse(JSON.stringify(a));var b=c[0];c=c[1];for(var d=h.value.length,g=h.value[0].value.length,e=0;e<d;e++)for(var f=0;f<g;f++)a.value[b+e].value[c+f]=h.value[e].value[f];return a};g._helper.transposeMult=function(a,h){if(a.value.length!==h.value.length)return k;for(var c=a.value.length,b=Array(c),d=0;d<c;d++)b[d]=g.scalmult(a.value[d],h);return g.turnIntoCSList(b)};g._helper.QRgetAlpha=function(a,h){return 0>a.value[h].value.real?g.abs(a):l.neg(g.abs(a))}; -g.LUdecomp=function(a){a=JSON.parse(JSON.stringify(a));var h,c,b,d,g,e=0,f,k=a.value.length,m=k-1,n=Array(k);for(b=0;b<k;++b){g=b;d=a.value[b];f=l.abs(d.value[b]).value.real;for(c=b+1;c<k;++c)h=l.abs(a.value[c].value[b]),f<h.value.real&&(f=h.value.real,g=c);f<l.eps&&console.log("Warning: singular matrix!");n[b]=g;g!==b&&(a.value[b]=a.value[g],a.value[g]=d,d=a.value[b],e++);c=d.value[b];for(h=b+1;h<k;++h)a.value[h].value[b]=l.div(a.value[h].value[b],c);for(h=b+1;h<k;++h){g=a.value[h];for(c=b+1;c<m;++c)g.value[c]= -l.sub(g.value[c],l.mult(g.value[b],d.value[c])),++c,g.value[c]=l.sub(g.value[c],l.mult(g.value[b],d.value[c]));c===m&&(g.value[c]=l.sub(g.value[c],l.mult(g.value[b],d.value[c])))}}return{LU:a,P:n,TransPos:e}};g.LUsolve=function(a,h){var c=g.LUdecomp(a);return g._helper.LUsolve(c,h)};g._helper.LUsolve=function(a,h){var c=JSON.parse(JSON.stringify(h)),b,d=a.LU,g=d.value.length,e=JSON.parse(JSON.stringify(c)),f=a.P,k;for(b=g-1;-1!==b;--b)e.value[b]=c.value[b];for(b=0;b<g;++b)for(c=f[b],f[b]!==b&&(k= -e.value[b],e.value[b]=e.value[c],e.value[c]=k),k=d.value[b],c=0;c<b;++c)e.value[b]=l.sub(e.value[b],l.mult(e.value[c],k.value[c]));for(b=g-1;0<=b;--b){k=d.value[b];for(c=b+1;c<g;++c)e.value[b]=l.sub(e.value[b],l.mult(e.value[c],k.value[c]));e.value[b]=l.div(e.value[b],k.value[b])}return e};g.linearsolveCramer2=function(a,h){var c=g.column(a,l.real(1)),b=g.column(a,l.real(2)),d=g.det2(c,b);l._helper.isZero(d)&&console.log("A is not regular!");b=g.det2(h,b);b=l.div(b,d);c=g.det2(c,h);c=l.div(c,d);return g.turnIntoCSList([b, -c])};g.linearsolveCramer3=function(a,h){var c=g.column(a,l.real(1)),b=g.column(a,l.real(2)),d=g.column(a,l.real(3)),e=g.det3(c,b,d);l._helper.isZero(e)&&console.log("A is not regular!");var f=g.det3(h,b,d),d=g.det3(c,h,d),c=g.det3(c,b,h),f=g.turnIntoCSList([f,d,c]);return f=g.scaldiv(e,f)};g.linearsolveCGNR=function(a,h){var c=g.transpose(a),b=w.mult(c,a),c=w.mult(c,h);return g.linearsolveCG(b,c)};g.linearsolveCG=function(a,h){var c,b,d,e,f,k;e=h;b=c=g.sub(h,w.mult(a,h));for(var m=Math.ceil(1.2*a.value.length), -n=0;n<m;){n++;f=w.mult(a,b);k=d=g.scalproduct(c,c);d=l.div(d,g.scalproduct(b,f));e=g.add(e,w.mult(d,b));c=g.sub(c,w.mult(d,f));if(g.abs(c).value.real<l.eps)break;d=g.scalproduct(c,c);d=l.div(d,k);b=g.add(c,w.mult(d,b))}n>=m&&console.log("CG did not converge");return e};g.det=function(a){if(1===a.value.length)return a.value[0].value[0];if(2===a.value.length)return g.det2(a.value[0],a.value[1]);if(3===a.value.length)return g.det3(a.value[0],a.value[1],a.value[2]);if(4===a.value.length)return g.det4m(a); -var h=a.value.length,c=l.real(1),b,d,e=JSON.parse(JSON.stringify(a)),f,k,m,n;for(a=0;a<h-1;a++){d=a;for(b=a+1;b<h;b++)l.abs(e.value[b].value[a]).value.real>l.abs(e.value[d].value[a]).value.real&&(d=b);d!==a&&(b=e.value[d],e.value[d]=e.value[a],e.value[a]=b,c=l.neg(c));f=e.value[a];for(b=a+1;b<h;b++){k=e.value[b];m=l.div(k.value[a],f.value[a]);for(d=a+1;d<h-1;d+=2)n=d+1,k.value[d]=l.sub(k.value[d],l.mult(f.value[d],m)),k.value[n]=l.sub(k.value[n],l.mult(f.value[n],m));d!==h&&(k.value[d]=l.sub(k.value[d], -l.mult(f.value[d],m)))}if(l._helper.isZero(f.value[a]))return l.real(0);c=l.mult(c,f.value[a])}return l.mult(c,e.value[a].value[a])};g.LUdet=function(a){a=g.LUdecomp(a);for(var h=a.LU,c=h.value.length,b=h.value[0].value[0],d=1;d<c;d++)b=l.mult(b,h.value[d].value[d]);1===a.TransPos%2&&(b=l.neg(b));return b};g.getField=function(a,h){var c;if("homog"===h){if(g._helper.isNumberVecN(a,3))return a;if(g._helper.isNumberVecN(a,2))return g.turnIntoCSList([a.value[0],a.value[1],l.real(1)])}if("xy"===h){if(g._helper.isNumberVecN(a, -2))return a;if(g._helper.isNumberVecN(a,3))return g.turnIntoCSList([l.div(a.value[0],a.value[2]),l.div(a.value[1],a.value[2])])}if("x"===h&&g.isNumberVector(a)){c=a.value.length;if(0<c&&3!==c)return a.value[0];if(3===c)return"Point"===a.usage?l.div(a.value[0],a.value[2]):a.value[0]}if("y"===h&&g.isNumberVector(a)){c=a.value.length;if(1<c&&3!==c)return a.value[1];if(3===c)return"Point"===a.usage?l.div(a.value[1],a.value[2]):a.value[1]}return"z"===h&&g.isNumberVector(a)&&(c=a.value.length,2<c)?a.value[2]: -k};g.nil=g.turnIntoCSList([]);g.ofGeos=function(a){return g.turnIntoCSList(a.map(function(a){return{ctype:"geo",value:a}}))};var Ka={key:function(a){if("string"===a.ctype)return"s"+a.value.length+":"+a.value+";";if("number"===a.ctype)return"n"+a.value.real+","+a.value.imag+";";if("list"===a.ctype)return"l"+a.value.length+":"+a.value.map(Ka.key).join(",")+";";if("boolean"===a.ctype)return"b"+a.value+";";if("dict"===a.ctype)return a=Object.keys(a.value).sort(),"d"+a.length+":"+a.join(",")+";";"undefined"!== -a.ctype&&ia.err("Bad dictionary key: "+ba(a));return"undef"},create:function(){return{ctype:"dict",value:{}}},clone:function(a){var h=Ka.create(),c;for(c in a.value)a.value.hasOwnProperty(c)&&(h.value[c]=a.value[c]);return h},put:function(a,h,c){a.value[Ka.key(h)]={key:h,value:c}},get:function(a,h,c){return(a=a.value[Ka.key(h)])?a.value:c},niceprint:function(a){return"{"+Object.keys(a.value).sort().map(function(h){h=a.value[h];return ba(h.key)+":"+ba(h.value)}).join(", ")+"}"}},w={_helper:{},order:{undefined:0, -"boolean":1,number:2,term:3,atomic:4,variable:5,geo:6,string:7,list:8},string:function(a){return{ctype:"string",value:a}},bool:function(a){return{ctype:"boolean",value:a}},not:function(a){return w.bool(!a.value)},isLessThan:function(a,h){return-1===w.compare(a,h)},isEqual:function(a,h){return 0===w.compare(a,h)},compareResults:function(a,h){return w.compare(a.result,h.result)},compare:function(a,h){if(a.ctype!==h.ctype)return w.order[a.ctype]-w.order[h.ctype];if("number"===a.ctype)return l._helper.compare(a, -h);if("list"===a.ctype)return g._helper.compare(a,h);if("geo"===a.ctype)return a.value.name===h.value.name?0:a.value.name<h.value.name?-1:1;if("string"===a.ctype)return a.value===h.value?0:a.value<h.value?-1:1;if("boolean"===a.ctype)return a.value===h.value?0:!1===a.value?-1:1},add:function(a,h){return"void"===a.ctype&&"number"===h.ctype||"void"===a.ctype&&"list"===h.ctype?h:"number"===a.ctype&&"number"===h.ctype?l.add(a,h):"string"===a.ctype||"string"===h.ctype?{ctype:"string",value:ba(a)+ba(h)}: -"list"===a.ctype&&"list"===h.ctype?g.add(a,h):k},sub:function(a,h){return"void"===a.ctype&&"number"===h.ctype?l.neg(h):"void"===a.ctype&&"list"===h.ctype?g.neg(h):"number"===a.ctype&&"number"===h.ctype?l.sub(a,h):"list"===a.ctype&&"list"===h.ctype?g.sub(a,h):k},mult:function(a,h){return"number"===a.ctype&&"number"===h.ctype?l.mult(a,h):"number"===a.ctype&&"list"===h.ctype?g.scalmult(a,h):"list"===a.ctype&&"number"===h.ctype?g.scalmult(h,a):"list"===a.ctype&&"list"===h.ctype?g.mult(a,h):k},div:function(a, -h){return"number"===a.ctype&&"number"===h.ctype?l.div(a,h):"list"===a.ctype&&"number"===h.ctype?g.scaldiv(h,a):k},max:function(a,h){return"number"===a.ctype&&"number"===h.ctype?l.max(a,h):"list"===a.ctype&&"list"===h.ctype?g.max(a,h):k},min:function(a,h){return"number"===a.ctype&&"number"===h.ctype?l.min(a,h):"list"===a.ctype&&"list"===h.ctype?g.min(a,h):k},wrap:function(a){if("number"===typeof a)return l.real(a);if("object"===typeof a&&void 0!==a.length){for(var h=[],c=0;c<a.length;c++)h[c]=w.wrap(a[c]); -return g.turnIntoCSList(h)}return"string"===typeof a?{ctype:"string",value:a}:"boolean"===typeof a?{ctype:"boolean",value:a}:k},unwrap:function(a){if("object"!==typeof a||null===a)return a;if(Array.isArray(a))return a.map(w.unwrap);switch(a.ctype){case "string":case "boolean":return a.value;case "number":return 0===a.value.imag?a.value.real:{r:a.value.real,i:a.value.imag};case "list":return a.value.map(w.unwrap);default:return null}},withUsage:function(a,h){return{ctype:a.ctype,value:a.value,usage:h}}, -wrapJSON:function(a){switch(typeof a){case "number":return l.real(a);case "string":return w.string(a);case "boolean":return w.bool(a);case "object":if(null===a)return k;if(Array.isArray(a))return g.turnIntoCSList(a.map(w.wrapJSON));var h=Ka.create(),c;for(c in a)Ka.put(h,w.string(c),w.wrapJSON(a[c]));return h;default:return console.log("Failed to convert "+typeof a+" to CindyJS data type"),k}},identity:function(a){return a}},Za={},R={};R[":"]=C(":");R["\u00b0"]=function(a,h){var c=B(a[0]);return"number"=== -c.ctype&&"void"===a[1].ctype?w.withUsage(l.realmult(Math.PI/180,c),"Angle"):k};R._=oc;R["^"]=Mc;R["\u221a"]=function(a,h){return"void"===a[0].ctype?t.sqrt$1([a[1]],h):k};R["*"]=Kc;R["\u00d7"]=Sc;R["/"]=Lc;R["+"]=Jc;R["-"]=$b;R["!"]=function(a,h){var c=B(a[1]);return"void"===a[0].ctype&&"boolean"===c.ctype?{ctype:"boolean",value:!c.value}:k};R["=="]=pb;R["~="]=Yb;R["~<"]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)? -{ctype:"boolean",value:c.value.real-b.value.real<=-l.eps}:k};R["~>"]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real-b.value.real>=l.eps}:k};R["=:="]=C("=:=");R[">="]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real>=b.value.real}:"string"===c.ctype&&"string"=== -b.ctype?{ctype:"boolean",value:c.value>=b.value}:k};R["<="]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real<=b.value.real}:"string"===c.ctype&&"string"===b.ctype?{ctype:"boolean",value:c.value<=b.value}:k};R["~>="]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real- -b.value.real>-l.eps}:k};R["~<="]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real-b.value.real<l.eps}:k};R[">"]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real>b.value.real}:"string"===c.ctype&&"string"===b.ctype?{ctype:"boolean",value:c.value>b.value}: -k};R["<"]=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&l._helper.isAlmostReal(c)&&l._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real<b.value.real}:"string"===c.ctype&&"string"===b.ctype?{ctype:"boolean",value:c.value<b.value}:k};R["<>"]=Gc;R["\u2208"]=function(a,h){var c=A(a[0]),b=A(a[1]);return"list"===b.ctype?g.contains(b,c):k};R["\u2209"]=function(a,h){var c=A(a[0]),b=A(a[1]);return"list"===b.ctype?w.not(g.contains(b,c)):k};R["&"]=Hc;R["%"]=Ic; -R["!="]=Gc;R["~!="]=function(a,h){return w.not(Yb(a,h))};R[".."]=function(a,h){var c=A(a[0]),b=A(a[1]);return"number"===c.ctype&&"number"===b.ctype?g.sequence(c,b):k};R["++"]=Tc;R["--"]=Vc;R["~~"]=Uc;R[":>"]=Wc;R["<:"]=Xc;R["="]=bb;R[":="]=function(a,h,c){h="undefined"===a[1].ctype;if("undefined"===a[0].ctype||h)return k;if("function"===a[0].ctype){h=a[0].oper;var b=a[0].args,d=a[1],g=1;if(Za.hasOwnProperty(h)){g=Za[h];if(g.definer===c)return k;g=g.generation+1}Za[h]={oper:h,body:d,arglist:b,definer:c, -generation:g}}"variable"===a[0].ctype&&J.setvar(a[0].name,a[1]);return k};R[":=_"]=function(a,h){if("void"!==a[1].ctype)return k;"function"===a[0].ctype&&delete Za[a[0].oper];return k};R["::="]=C("::=");R[";"]=function(a,h){var c="void"===a[0].ctype,b="void"===a[1].ctype;if(c&&b)return k;if(!c&&b)return A(a[0]);c||b||A(a[0]);return b?k:A(a[1])};var t={},D={evaluate:function(a,h,c){if(Za.hasOwnProperty(a)){a=Za[a];if(void 0===a)h=k;else{var b=[];for(c=0;c<a.arglist.length;c++)b[c]=A(h[c]);for(c=0;c< -a.arglist.length;c++)J.newvar(a.arglist[c].name),J.setvar(a.arglist[c].name,b[c]);J.pushVstack("*");h=A(a.body);J.cleanVstack();for(c=0;c<a.arglist.length;c++)J.removevar(a.arglist[c].name)}return h}if(b=t[a])return b(h,c);var d=a.lastIndexOf("$");if(-1!==d&&(d=a.substr(0,d),b=t[d]))return b(h,c);ia.err("Called undefined function "+d+" (as "+a+")");return k},equals:function(a,h){return"number"===a.ctype&&"number"===h.ctype?{ctype:"boolean",value:a.value.real===h.value.real&&a.value.imag===h.value.imag}: -"string"===a.ctype&&"string"===h.ctype||"boolean"===a.ctype&&"boolean"===h.ctype?{ctype:"boolean",value:a.value===h.value}:"list"===a.ctype&&"list"===h.ctype?g.equals(a,h):"geo"===a.ctype&&"geo"===h.ctype?{ctype:"boolean",value:a.value===h.value}:{ctype:"boolean",value:!1}}},J={};J.vars=function(){var a={pi:l.real(Math.PI),"\u03c0":l.real(Math.PI),i:l.complex(0,1),"true":w.bool(!0),"false":w.bool(!1),"#":k,nil:g.turnIntoCSList([]),newline:w.string("\n"),tab:w.string("\t")},h=[],c;for(c in a)h[c]= -[a[c]];return h}();J.isVariable=function(a){return this.vars.hasOwnProperty(a)};J.create=function(a){if(this.vars.hasOwnProperty(a))return this.vars[a];var h=[null];return this.vars[a]=h};J.newvar=function(a){a=this.vars[a];a.push(k);return a};J.removevar=function(a){var h=this.vars[a];0===h.length&&console.error("Removing non-existing "+a);h.pop();0===h.length&&console.warn("Removing last "+a)};J.setvar=function(a,h){var c=this.vars[a];0===c.length&&console.error("Setting non-existing variable "+ -a);void 0===h&&(console.error("Setting variable "+a+" to undefined value"),h=k);if("undefined"===h.ctype)c[c.length-1]=h;else{var b=h;null===b&&(b=k);c[c.length-1]=b}};J.undefinedWarning={};J.getvar=function(a){var h=this.vars[a];0===h.length&&console.error("Getting non-existing variable "+a);h=h[h.length-1];if(null===h){if(u.csnames.hasOwnProperty(a))return{ctype:"geo",value:u.csnames[a]};console&&console.log&&void 0===this.undefinedWarning[a]&&(this.undefinedWarning[a]=!0,console.log("Warning: Accessing undefined variable: "+ -a));return k}return h};J.dump=function(a){var h=this.vars[a];console.log("*** Dump "+a);for(a=0;a<h.length;a++)console.log(a+":> "+ba(h[a]))};J.vstack=[];J.pushVstack=function(a){this.vstack.push(a)};J.popVstack=function(){this.vstack.pop()};J.cleanVstack=function(){for(var a=this.vstack;0<a.length&&"*"!==a[a.length-1];)this.removevar(a[a.length-1]),a.pop();0<a.length&&a.pop()};var ya={generalFields:{color:"color",colorhsb:"",size:"size",alpha:"alpha",fillcolor:"fillcolor",fillalpha:"fillalpha",isshowing:"isshowing", -visible:"visible",name:"name",caption:"caption",trace:"",tracelength:"",selected:"",labeled:"labeled",labelled:"labeled"},getGeoField:function(a,h){return"undefined"!==typeof u.csnames[a]?ya.getField(u.csnames[a],h):k},setGeoField:function(a,h,c){return"undefined"!==typeof u.csnames[a]?ya.setField(u.csnames[a],h,c):k},getField:function(a,h){var c;if("P"===a.kind){if("xy"===h)return c=g.dehom(a.homog),w.withUsage(c,"Point");if("homog"===h)return w.withUsage(a.homog,"Point");if("x"===h)return l.div(a.homog.value[0], -a.homog.value[2]);if("y"===h)return l.div(a.homog.value[1],a.homog.value[2])}if("L"===a.kind||"S"===a.kind){if("homog"===h)return w.withUsage(a.homog,"Line");if("angle"===h)return c=g.eucangle(g.ey,a.homog),w.withUsage(c,"Angle");if("slope"===h)return l.neg(l.div(a.homog.value[0],a.homog.value[1]))}if("Tr"===a.kind&&"matrix"===h)return a.matrix;if("C"===a.kind){if("radius"===h){var b=a.matrix;c=b.value[0].value[0];var d=b.value[0].value[2],e=b.value[1].value[2],b=b.value[2].value[2];l.mult(c,c);d= -l.div(d,c);e=l.div(e,c);c=l.div(b,c);return c=l.sqrt(l.sub(l.add(l.mult(d,d),l.mult(e,e)),c))}if("size"===h)return a.size;if("matrix"===h)return a.matrix;if("center"===h)return c=m._helper.CenterOfConic(a.matrix),c=g.dehom(c),w.withUsage(c,"Point");if("dualMatrix"===h)return g.normalizeMax(g.adjoint3(a.matrix))}if("Text"===a.kind){if("pressed"===h)return a.checkbox?w.bool(a.checkbox.checked):w.bool(!1);if("xy"===h)return c=g.dehom(a.homog),w.withUsage(c,"Point");if("homog"===h)return w.withUsage(a.homog, -"Point");if("x"===h)return l.div(a.homog.value[0],a.homog.value[2]);if("y"===h)return l.div(a.homog.value[1],a.homog.value[2])}if("trace"===h)return w.bool(!!a.drawtrace);if(ya.generalFields[h])return(c=a[ya.generalFields[h]])&&c.ctype?c:"object"!==typeof c?w.wrap(c):k;if(a.behavior){if("mass"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.mass);if("radius"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.radius);if("charge"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.charge); -if("friction"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.friction);if("vx"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.vx);if("vy"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.vy);if("v"===h&&"Mass"===a.behavior.type)return g.realVector([a.behavior.vx,a.behavior.vy]);if("fx"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.fx);if("fy"===h&&"Mass"===a.behavior.type)return l.real(a.behavior.fy);if("f"===h&&"Mass"===a.behavior.type)return g.realVector([a.behavior.fx, -a.behavior.fy])}c=m[a.type]["get_"+h];return"function"===typeof c?c(a):k},setField:function(a,h,c){"color"===h&&g._helper.isNumberVecN(c,3)&&(a.color=c);"size"===h&&"number"===c.ctype&&(a.size=c);"alpha"===h&&"number"===c.ctype&&(a.alpha=c);"fillcolor"===h&&g._helper.isNumberVecN(c,3)&&(a.fillcolor=c);"fillalpha"===h&&"number"===c.ctype&&(a.fillalpha=c);"visible"===h&&"boolean"===c.ctype&&(a.visible=c.value);"pinned"===h&&"boolean"===c.ctype&&(a.pinned=c.value);"labeled"!==h&&"labelled"!==h||"boolean"!== -c.ctype||(a.labeled=c.value);"printlabel"===h&&(a.printname=ba(c));"trace"===h&&"boolean"===c.ctype&&(c.value&&!a.drawtrace?(a.drawtrace=!0,qd(a)):a.drawtrace=c.value);"P"===a.kind&&a.movable&&("xy"===h&&g._helper.isNumberVecN(c,2)&&Ia(a,g.turnIntoCSList([c.value[0],c.value[1],l.real(1)]),"homog"),"xy"===h&&g._helper.isNumberVecN(c,3)&&Ia(a,c,"homog"),"x"===h&&"number"===c.ctype&&Ia(a,g.turnIntoCSList([l.mult(c,a.homog.value[2]),a.homog.value[1],a.homog.value[2]]),"homog"),"y"===h&&"number"===c.ctype&& -Ia(a,g.turnIntoCSList([a.homog.value[0],l.mult(c,a.homog.value[2]),a.homog.value[2]]),"homog"),"homog"===h&&g._helper.isNumberVecN(c,3)&&Ia(a,c,"homog"));"homog"===h&&"L"===a.kind&&a.movable&&g._helper.isNumberVecN(c,3)&&Ia(a,c,"homog");"Text"===a.kind&&("pressed"===h&&"boolean"===c.ctype&&a.checkbox&&(a.checkbox.checked=c.value),a.movable&&("xy"===h?g._helper.isNumberVecN(c,2)?a.homog=g.turnIntoCSList([c.value[0],c.value[1],l.real(1)]):g._helper.isNumberVecN(c,3)&&(a.homog=c):"homog"===h&&g._helper.isNumberVecN(c, -3)?a.homog=c:"x"===h&&"number"===c.ctype?a.homog=g.turnIntoCSList([l.mult(c,a.homog.value[2]),a.homog.value[1],a.homog.value[2]]):"y"===h&&"number"===c.ctype&&(a.homog=g.turnIntoCSList([a.homog.value[0],l.mult(c,a.homog.value[2]),a.homog.value[2]]))));a.behavior&&("mass"===h&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.mass=c.value.real),"mass"===h&&"Sun"===a.behavior.type&&"number"===c.ctype&&(a.behavior.mass=c.value.real),"friction"===h&&"Mass"===a.behavior.type&&"number"===c.ctype&& -(a.behavior.friction=c.value.real),"charge"===h&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.charge=c.value.real),"radius"===h&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.radius=c.value.real),"vx"===h&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.vx=c.value.real),"vy"===h&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.vy=c.value.real),"v"===h&&"Mass"===a.behavior.type&&g._helper.isNumberVecN(c,2)&&(a.behavior.vx=c.value[0].value.real,a.behavior.vy= -c.value[1].value.real));h=m[a.type]["set_"+h];if("function"===typeof h)return h(a,c)}};t.version$0=function(a,h){var c=["CindyJS"].concat(ne);return g.turnIntoCSList(c.map(w.wrap))};t.clearconsole$0=function(a,h){ia.clear()};t.err$1=function(a,h){var c="",b;"variable"===a[0].ctype?(c=a[0].name,b=J.getvar(a[0].name)):b=a[0];b=c+" ===> "+ba(A(b));ia.err(b);return k};t.errc$1=function(a,h){var c;"variable"===a[0].ctype?(c=A(J.getvar(a[0].name)),console.log(a[0].name+" ===> "+ba(c))):(c=A(a[0]),console.log(" ===> "+ -ba(c)));return k};t.print$1=function(a,h){ia.out(ba(A(a[0])),!0);return k};t.println$1=function(a,h){ia.out(ba(A(a[0])));return k};t.assert$2=function(a,h){var c=A(a[0]);if("boolean"===c.ctype){if(!1===c.value)return t.println$1([a[1]],h)}else ia.err("Condition for assert is not boolean");return k};t.dump$1=function(a,h){console.log(JSON.stringify(a[0]));return k};t.repeat$2=function(a,h){return t.repeat$3([a[0],null,a[1]],h)};t.repeat$3=function(a,h){var c=B(a[0]),b="#";null!==a[1]&&"variable"=== -a[1].ctype&&(b=a[1].name);if("number"!==c.ctype)return k;var c=Math.round(c.value.real),d=1,g=1,e=c+1,f=!1,l=!1,m=!1,n;void 0!==h.start&&(n=A(h.start),"number"===n.ctype&&(f=!0,g=n.value.real));void 0!==h.step&&(n=A(h.step),"number"===n.ctype&&(m=!0,d=n.value.real));void 0!==h.stop&&(n=A(h.stop),"number"===n.ctype&&(l=!0,e=n.value.real));!f||l||m||(e=d*c+g);f||!l||m||(g=-d*(c-1)+e,e+=d);f||l||!m||(e=d*c+g);f&&l&&!m&&(d=(e-g)/(c-1),e+=d);f&&!l&&m&&(e=d*c+g);!f&&l&&m&&(g=-d*(c-1)+e,e+=d);f&&l&&m&&(e+= -d);(g<=e&&0<d||g>=e&&0>d)&&f&&l&&m&&(c=Math.floor((e-g)/d));J.newvar(b);e=k;for(f=0;f<c;f++)J.setvar(b,{ctype:"number",value:{real:f*d+g,imag:0}}),e=A(a[2]);J.removevar(b);return e};t.while$2=function(a,h){for(var c=a[1],b=a[0],d=A(b),e=k;"list"!==d.ctype&&d.value;)e=A(c),d=A(b);return e};t.apply$2=function(a,h){return t.apply$3([a[0],null,a[1]],h)};t.apply$3=function(a,h){var c=B(a[0]);if("list"!==c.ctype)return k;var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);var c=c.value,d=[];J.newvar(b); -for(var e=0;e<c.length;e++)J.setvar(b,c[e]),d[e]=A(a[2]);J.removevar(b);return{ctype:"list",value:d}};t.forall$2=function(a,h){return t.forall$3([a[0],null,a[1]],h)};t.forall$3=function(a,h){var c=B(a[0]);if("list"!==c.ctype)return k;var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);c=c.value;J.newvar(b);for(var d,e=0;e<c.length;e++)J.setvar(b,c[e]),d=A(a[2]);J.removevar(b);return d};t.select$2=function(a,h){return t.select$3([a[0],null,a[1]],h)};t.select$3=function(a,h){var c=B(a[0]); -if("list"!==c.ctype)return k;var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);var c=c.value,d=[];J.newvar(b);for(var e=0,g=0;g<c.length;g++){J.setvar(b,c[g]);var f=A(a[2]);"boolean"===f.ctype&&!0===f.value&&(d[e]=c[g],e++)}J.removevar(b);return{ctype:"list",value:d}};t.flatten$1=function(a,h){function c(a,h){return-1===h||"list"!==a.ctype?a:[].concat.apply([],a.value.map(function(a){return c(a,h-1)}))}var b=B(a[0]);if("list"!==b.ctype)return b;var d=h.levels;void 0===d?d=1:(d=A(d),d= -"number"===d.ctype?d.value.real:"string"===d.ctype&&"all"===d.value?-2:1);return{ctype:"list",value:c(b,d)}};t.createvar$1=function(a,h){"variable"===a[0].ctype&&J.newvar(a[0].name);return k};t.local=function(a,h){for(var c=0;c<a.length;c++)"variable"===a[c].ctype&&J.newvar(a[c].name);return k};t.removevar$1=function(a,h){var c=A(a[0]);"variable"===a[0].ctype&&J.removevar(a[0].name);return c};t.release=function(a,h){if(0===a.length)return k;for(var c=A(a[a.length-1]),b=0;b<a.length;b++)"variable"=== -a[b].ctype&&J.removevar(a[b].name);return c};t.regional=function(a,h){for(var c=0;c<a.length;c++)if("variable"===a[c].ctype){var b=a[c].name;J.newvar(b);J.pushVstack(b)}return k};t.genList=function(a,h){return g.turnIntoCSList(a.map(A))};D.assigntake=function(a,h){var c=a.args[0],b=A(c),d=B(a.args[1]),e=k;if("list"===b.ctype||"string"===b.ctype)d=Math.floor(d.value.real),0>d&&(d=b.value.length+d+1),0<d&&d<=b.value.length&&("list"===b.ctype?(b=b.value.slice(),b[d-1]=A(h),e=g.turnIntoCSList(b)):(b= -b.value,b=b.substring(0,d-1)+ba(A(h))+b.substring(d,b.length),e=w.string(b)));bb([c,e])};D.assigndot=function(a,h){var c=A(a.obj),b=a.key;"geo"===c.ctype&&b&&ya.setField(c.value,b,B(h));return k};D.assignlist=function(a,h){var c=a.length,b=h.length;b<c&&(c=b);for(b=0;b<c;b++)bb([a[b],h[b]],[])};t.if$2=function(a,h){return t.if$3(a,h)};t.if$3=function(a,h){var c=B(a[0]);if("boolean"===c.ctype){if(!0===c.value)return A(a[1]);if(3===a.length)return A(a[2])}else ia.err("Condition for if is not boolean"); -return k};t.and$2=Hc;t.or$2=Ic;t.xor$2=function(a,h){var c=B(a[0]),b=B(a[1]);return"boolean"===c.ctype&&"boolean"===b.ctype?{ctype:"boolean",value:c.value!==b.value}:k};t.not$1=function(a,h){var c=B(a[0]);return"boolean"===c.ctype?{ctype:"boolean",value:!c.value}:k};D.genericListMathGen=function(a,h,c){t[a+"$1"]=function(a,b){var d=A(a[0]);if("list"!==d.ctype)return k;d=d.value;if(0===d.length)return c;for(var r=d[0],e=1;e<d.length;e++)r=h(r,d[e]);return r};var b=a+"$3";t[a+"$2"]=function(a,c){return t[b]([a[0], -null,a[1]])};t[b]=function(a,b){var d=B(a[0]);if("list"!==d.ctype)return k;d=d.value;if(0===d.length)return c;var r="#";null!==a[1]&&"variable"===a[1].ctype&&(r=a[1].name);J.newvar(r);J.setvar(r,d[0]);for(var e=A(a[2]),g=1;g<d.length;g++){J.setvar(r,d[g]);var f=A(a[2]),e=h(e,f)}J.removevar(r);return e}};D.genericListMathGen("product",w.mult,l.real(1));D.genericListMathGen("sum",w.add,l.real(0));D.genericListMathGen("max",w.max,k);D.genericListMathGen("min",w.min,k);t.max$2=function(a,h){var c=B(a[0]); -if("list"===c.ctype)return t.max$3([c,null,a[1]]);var b=B(a[1]);return t.max$1([g.turnIntoCSList([c,b])])};t.min$2=function(a,h){var c=B(a[0]);if("list"===c.ctype)return t.min$3([c,null,a[1]]);var b=B(a[1]);return t.min$1([g.turnIntoCSList([c,b])])};t.add$2=Jc;t.sub$2=$b;t.mult$2=Kc;t.div$2=Lc;t.mod$2=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype?l.mod(c,b):k};t.pow$2=Mc;t.exp$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.exp(c):k};t.sin$1=function(a, -h){var c=B(a[0]);return"number"===c.ctype?l.sin(c):k};t.sqrt$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.sqrt(c):k};D.laguerre=function(a,h,c){if("list"!==a.ctype)return k;var b=a.value.length-1,d;for(d=0;d<=b;d++)if("number"!==a.value[d].ctype)return k;if("number"!==h.ctype)return k;for(var e=[1,.3141,.5926,.5358,.9793,.2385,.6264,.3383,.2795,.0288],g,f,m,n=1;n<=c;n++){f=m=l.zero;g=a.value[b];for(d=b-1;0<=d;d--)m=l.add(f,l.mult(m,h)),f=l.add(g,l.mult(f,h)),g=l.add(a.value[d],l.mult(g, -h));if(l._helper.isLessThan(l.abs(g),l.real(1E-14)))break;d=l.div(f,g);f=l.mult(d,d);g=l.sub(f,l.div(l.mult(l.real(2),m),g));m=l.sqrt(l.mult(l.real(b-1),l.sub(l.mult(l.real(b),g),f)));g=l.add(d,m);d=l.sub(d,m);l._helper.isLessThan(l.abs(g),l.abs(d))&&(g=d);d=l._helper.isLessThan(l.real(1E-14),l.abs(g))?l.div(l.real(b),g):l.mult(l.add(l.abs(h),l.one),l.complex(Math.cos(n),Math.sin(n)));if(l._helper.isLessThan(l.abs(d),l.real(1E-14)))break;0===n%20&&n<c-19&&(d=l.mult(d,l.real(e[Math.floor(n/20)]))); -h=l.sub(h,d)}return h};D.quadratic_roots=function(a){if("list"!==a.ctype)return k;var h=a.value[2],c=a.value[1];a=a.value[0];if(l._helper.isZero(a))return[l.zero,l.neg(l.div(c,h))];var b=l.sqrt(l.sub(l.mult(c,c),l.mult(l.real(4),l.mult(h,a))));0<=l.re(c)&&(b=l.neg(b));return[l.div(l.sub(b,c),l.mult(l.real(2),h)),l.div(l.mult(l.real(2),a),l.sub(b,c))]};D.roots=function(a){var h=[],c=a,b=a.value.length-1;if(0>=b)return g.turnIntoCSList([]);if(l._helper.isZero(a.value[b]))return h=D.roots(g.turnIntoCSList(a.value.slice(0, -b))),g.append(h,l.infinity);if(1===b)h[0]=l.neg(l.div(a.value[0],a.value[1]));else if(2===b)h=D.quadratic_roots(a);else{for(var d=0;d<b-2;d++){h[d]=D.laguerre(a,l.zero,200);h[d]=D.laguerre(c,h[d],1);var e=[];e[b-d]=a.value[b-d];for(var f=b-d;0<f;f--)e[f-1]=l.add(a.value[f-1],l.mult(e[f],h[d]));e.shift();a=g.turnIntoCSList(e)}a=D.quadratic_roots(a);h[b-2]=a[0];h[b-1]=a[1]}return g.turnIntoCSList(h)};t.roots$1=function(a,h){var c=B(a[0]);if("list"===c.ctype){for(var b=0;b<c.value.length;b++)if("number"!== -c.value[b].ctype)return k;c=D.roots(c);return g.sort1(c)}return k};t.autodiff$3=function(a,h){var c="x",b;if("function"===a[0].ctype)b=Za[a[0].oper].body,c=a[0].args[0].name;else if("function"===typeof a[0].impl)b=a[0];else return console.log("could not parse function"),k;var d=B(a[1]),e=B(a[2]);if(1>e.value.real)return console.log("grade cant be < 1"),k;e=l.add(e,l.real(1));return P.autodiff(b,c,d,e)};t.cos$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.cos(c):k};t.tan$1=function(a,h){var c= -B(a[0]);return"number"===c.ctype?l.tan(c):k};t.arccos$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.arccos(c):k};t.arcsin$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.arcsin(c):k};t.arctan$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.arctan(c):k};t.arctan2$2=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype?l.arctan2(c,b):k};t.arctan2$1=function(a,h){var c=B(a[0]);if("list"===c.ctype&&2===c.value.length){if(c=c.value,"number"===c[0].ctype&& -"number"===c[1].ctype)return t.arctan2$2(c,h)}else if("number"===c.ctype)return l.arctan2(c);return k};t.log$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.log(c):k};D.recursiveGen=function(a){var h=l[a],c=g[a];t[a+"$1"]=function(a,b){var d=B(a[0]);return"number"===d.ctype?h(d):"list"===d.ctype?c(d):k}};D.recursiveGen("im");D.recursiveGen("re");D.recursiveGen("conjugate");D.recursiveGen("round");D.recursiveGen("ceil");D.recursiveGen("floor");D.recursiveGen("abs");t.abs_infix=t.abs$1;t.random$0= -function(a,h){return l.real(l._helper.rand())};t.random$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?l.complex(c.value.real*l._helper.rand(),c.value.imag*l._helper.rand()):k};t.seedrandom$1=function(a,h){var c=B(a[0]);"number"===c.ctype&&l._helper.seedrandom(c.value.real);return k};t.randomnormal$0=function(a,h){return l.real(l._helper.randnormal())};t.randominteger$1=function(a,h){var c=B(a[0]);if("number"===c.ctype){var b=c.value.real|0,c=c.value.imag|0,b=b*l._helper.rand()|0,c=c*l._helper.rand()| -0;return l.complex(b,c)}return k};t.randomint$1=t.randominteger$1;t.randombool$0=function(a,h){return.5<l._helper.rand()?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isreal$1=function(a,h){var c=A(a[0]);return"number"===c.ctype&&l._helper.isAlmostReal(c)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isinteger$1=function(a,h){var c=A(a[0]);return"number"===c.ctype&&l._helper.isAlmostReal(c)&&c.value.real===Math.floor(c.value.real)?{ctype:"boolean",value:!0}:{ctype:"boolean", -value:!1}};t.iseven$1=function(a,h){var c=A(a[0]);return"number"===c.ctype&&l._helper.isAlmostReal(c)&&c.value.real/2===Math.floor(c.value.real/2)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isodd$1=function(a,h){var c=A(a[0]);return"number"===c.ctype&&l._helper.isAlmostReal(c)&&(c.value.real-1)/2===Math.floor((c.value.real-1)/2)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.iscomplex$1=function(a,h){return"number"===A(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean", -value:!1}};t.isstring$1=function(a,h){return"string"===A(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.islist$1=function(a,h){return"list"===A(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.ismatrix$1=function(a,h){var c=A(a[0]);return-1!==g._helper.colNumb(c)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.iscircle$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&"C"===c.value.kind&&"Circle"===c.value.matrix.usage?{ctype:"boolean",value:!0}: -{ctype:"boolean",value:!1}};t.isconic$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&"C"===c.value.kind?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isline$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&"L"===c.value.kind?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.ispoint$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&"P"===c.value.kind?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isgeometric$1=function(a,h){return"geo"===A(a[0]).ctype?{ctype:"boolean", -value:!0}:{ctype:"boolean",value:!1}};t.isnumbermatrix$1=function(a,h){var c=A(a[0]);return g.isNumberMatrix(c)};t.isnumbervector$1=function(a,h){var c=A(a[0]);return g.isNumberVector(c)};t.issun$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Sun"===c.value.behavior.type?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.ismass$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Mass"===c.value.behavior.type?{ctype:"boolean",value:!0}: -{ctype:"boolean",value:!1}};t.isspring$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Spring"===c.value.behavior.type?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isbouncer$1=function(a,h){var c=A(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Bouncer"===c.value.behavior.type?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isundefined$1=function(a,h){return"undefined"===A(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}}; -var Hd={ArcBy3:"Arc",CenterOfConic:"Center",ConicBy1p4l:"Conic1P4L",ConicBy4p1l:"Conic4P1L",ConicBy5lines:"Conic5L",ConicBy2Foci1P:"ConicFoci",ConicFromPrincipalDirections:"ConicPrincipleDirs",Free:"FreePoint",PolarOfLine:"PolarLine",PolarOfPoint:"PolarPoint",PointOnSegment:"PointOnLine",Button:"Text",ToggleButton:"Text",TrReflectionL:"TrReflection",TrReflectionP:"TrReflection",TrReflectionC:"TrReflection",TrTranslation:"TrProjection",TrSimilarity:"TrProjection",TrAffine:"TrProjection",TransformP:"Transform", -TransformL:"Transform",TransformSegment:"Transform",TransformS:"Transform",TransformPolygon:"Transform",TransformArc:"Transform",TransformConic:"Transform",TransformC:"Transform",TrMoebiusP:"Transform",TrMoebiusL:"Transform",TrMoebiusSegment:"Transform",TrMoebiusS:"Transform",TrMoebiusPolygon:"Transform",TrMoebiusArc:"Transform",TrMoebiusCircle:"Transform",TrMoebiusC:"Transform",TrInverseMoebius:"TrInverse",Perp:"Orthogonal",Para:"Parallel",AngleBisector:"AngularBisector",IntersectLC:"IntersectionConicLine", -IntersectCirCir:"IntersectionCircleCircle",OtherPointOnCircle:"PointOnCircle"};t.algorithm$1=function(a,h){var c=A(a[0]);if("geo"===c.ctype){var c=c.value,b=c.type,d=B(h.compatibility);"string"===d.ctype&&/^cinderella$/i.test(d.value)&&(/^Select/.test(b)&&(c=u.csnames[c.args[0]],b=c.type),Hd.hasOwnProperty(b)?b=Hd[b]:"CircleMr"===b&&(b=c.pinned?"CircleByFixedRadius":"CircleByRadius"));return w.string(b)}return k};t.inputs$1=function(a,h){var c=A(a[0]);if("geo"===c.ctype){var c=c.value,b=c.type,d= -[];c.args&&(d=c.args.map(function(a){return{ctype:"geo",value:u.csnames[a]}}));if(/^Select/.test(b)||m[b].isMovable)switch(c.kind){case "P":case "L":d.push(c.homog);break;case "C":d.push(c.matrix)}return g.turnIntoCSList(d)}return k};t.moveto$2=function(a,h){var c=A(a[0]),b=B(a[1]);"geo"===c.ctype&&(c=c.value,g._helper.isNumberVecN(b,2)?ya.setField(c,"xy",b):g._helper.isNumberVecN(b,3)&&ya.setField(c,"homog",b));return k};t.continuefromhere$0=function(a,h){ub();return k};t.matrixrowcolumn$1=function(a, -h){var c=A(a[0]);return-1!==g._helper.colNumb(c)?g.realVector([c.value.length,c.value[0].value.length]):k};t.rowmatrix$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.turnIntoCSList([c]):k};t.columnmatrix$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.turnIntoCSList(c.value.map(function(a){return g.turnIntoCSList([a])})):k};t.submatrix$3=function(a,h){var c=A(a[0]),b=A(a[1]),d=A(a[2]);if("list"===c.ctype&&"number"===b.ctype&&"number"===d.ctype){var e=Math.round(b.value.real),b=Math.round(d.value.real), -c=c.value.slice();0<b&&b<=c.length&&c.splice(b-1,1);var f=!0,c=c.map(function(a){if("list"!==a.ctype)f=!1;else return a=a.value.slice(),0<e&&e<=a.length&&a.splice(e-1,1),g.turnIntoCSList(a)});return f?g.turnIntoCSList(c):k}return k};t.complex$1=function(a,h){var c,b,d;d=B(a[0]);if("list"===d.ctype&&g.isNumberVector(d)){if(2===d.value.length)return c=d.value[0],b=d.value[1],l.complex(c.value.real-b.value.imag,b.value.real+c.value.imag);if(3===d.value.length)return c=d.value[0],b=d.value[1],d=d.value[2], -c=l.div(c,d),b=l.div(b,d),l.complex(c.value.real-b.value.imag,b.value.real+c.value.imag)}return k};t.gauss$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?g.realVector([c.value.real,c.value.imag]):k};t.cross$2=Sc;t.crossratio$4=function(a,h){var c=A(a[0]),b=A(a[1]),d=A(a[2]),e=A(a[3]),f=M(c),m=M(b),n=M(d),p=M(e);return f!==k&&m!==k&&n!==k&&p!==k?g.crossratio3(f,m,n,p,g.ii):"number"===c.ctype&&"number"===b.ctype&&"number"===d.ctype&&"number"===e.ctype?l.div(l.mult(l.sub(c,d),l.sub(b,e)),l.mult(l.sub(c, -e),l.sub(b,d))):k};t.para$2=function(a,h){var c=B(a[0]),b=B(a[1]),d=M(c),e=M(b);if(c!==k&&b!==k){var b=b.usage,f=d,l=e;if("Line"===c.usage||"Point"===b)f=e,l=d;c=g.cross(g.cross(g.linfty,l),f);return w.withUsage(c,"Line")}return k};t.perp$2=function(a,h){var c=B(a[0]),b=B(a[1]),d=M(c),e=M(b);if(c!==k&&b!==k){var f=b.usage||e.usage,b=d,m=e;if("Line"===(c.usage||d.usage)||"Point"===f)b=e,m=d;c=g.turnIntoCSList([m.value[0],m.value[1],l.zero]);c=g.cross(c,b);return w.withUsage(c,"Line")}return k};t.perp$1= -function(a,h){var c=B(a[0]);return g._helper.isNumberVecN(c,2)?g.turnIntoCSList([l.neg(c.value[1]),c.value[0]]):k};t.parallel$2=t.para$2;t.perpendicular$2=t.perp$2;t.perpendicular$1=t.perp$1;t.meet$2=function(a,h){var c=M(a[0]),b=M(a[1]);return c!==k&&b!==k?(c=g.cross(c,b),w.withUsage(c,"Point")):k};t.join$2=function(a,h){var c=M(a[0]),b=M(a[1]);return c!==k&&b!==k?(c=g.cross(c,b),w.withUsage(c,"Line")):k};t.dist$2=function(a,h){var c=B(a[0]),b=B(a[1]),c=$b([c,b],[]);return t.abs$1([c],[])};t.dist_infix= -t.dist$2;t.point$1=function(a,h){var c=A(a[0]);return g._helper.isNumberVecN(c,3)||g._helper.isNumberVecN(c,2)?w.withUsage(c,"Point"):c};t.line$1=function(a,h){var c=A(a[0]);return g._helper.isNumberVecN(c,3)?w.withUsage(c,"Line"):c};t.det$3=function(a,h){var c=M(a[0]),b=M(a[1]),d=M(a[2]);if(c!==k&&b!==k&&d!==k)return g.det3(c,b,d)};t.det$1=function(a,h){var c=B(a[0]);if("list"===c.ctype){var b=g._helper.colNumb(c);if(-1!==b&&b===c.value.length)return g.det(c)}return k};t.eig$1=function(a,h){var c= -B(a[0]);if("list"===c.ctype){var b=g._helper.colNumb(c);if(-1!==b&&b===c.value.length)return g.eig(c)}return k};t.eigenvalues$1=function(a,h){var c=B(a[0]);if("list"===c.ctype){var b=g._helper.colNumb(c);if(-1!==b&&b===c.value.length)return g.eig(c,!1).value[0]}return k};t.rank$1=function(a,h){var c=B(a[0]);if("list"===c.ctype){var b=g._helper.colNumb(c);if(-1!==b&&b===c.value.length)return g.rank(c,h.precision)}return k};t.kernel$1=function(a,h){var c=B(a[0]);if("list"===c.ctype){var b=g._helper.colNumb(c); -if(-1!==b&&b===c.value.length)return c=g.nullSpace(c,h.precision),g.transpose(c)}return k};t.eigenvectors$1=function(a,h){var c=B(a[0]);if("list"===c.ctype){var b=g._helper.colNumb(c);if(-1!==b&&b===c.value.length)return g.eig(c).value[1]}return k};t.area$3=function(a,h){var c=M(a[0]),b=M(a[1]),d=M(a[2]);if(c!==k&&b!==k&&d!==k){var e=c.value[2],f=b.value[2],m=d.value[2];if(!l._helper.isAlmostZero(e)&&!l._helper.isAlmostZero(f)&&!l._helper.isAlmostZero(m))return c=g.scaldiv(e,c),b=g.scaldiv(f,b),d= -g.scaldiv(m,d),c=g.det3(c,b,d),l.realmult(.5,c)}return k};t.inverse$1=function(a,h){var c=B(a[0]);if("list"===c.ctype){var b=g._helper.colNumb(c);if(-1!==b&&b===c.value.length)return g.inverse(c)}return k};t.linearsolve$2=function(a,h){var c=B(a[0]),b=B(a[1]);if("list"===c.ctype){var d=g._helper.colNumb(c);if(-1!==d&&d===c.value.length&&g._helper.isNumberVecN(b,d))return g.linearsolve(c,b)}return k};var Ud=[[[]],[[0]],[[0,1],[1,0]],[[0,1,2],[0,2,1],[1,0,2],[1,2,0],[2,0,1],[2,1,0]],[[0,1,2,3],[0,1, -3,2],[0,2,1,3],[0,2,3,1],[0,3,1,2],[0,3,2,1],[1,0,2,3],[1,0,3,2],[1,2,0,3],[1,2,3,0],[1,3,0,2],[1,3,2,0],[2,0,1,3],[2,0,3,1],[2,1,0,3],[2,1,3,0],[2,3,0,1],[2,3,1,0],[3,0,1,2],[3,0,2,1],[3,1,0,2],[3,1,2,0],[3,2,0,1],[3,2,1,0]]];t.mincostmatching$1=function(a,h){var c=A(a[0]);if(g.isNumberMatrix(c).value){var b=c.value.length,d=g._helper.colNumb(c),e=b<d?d:b,f,m,n=Array(e);for(f=0;f<e;++f)for(n[f]=Array(e),m=0;m<e;++m)n[f][m]=f<b&&m<d?c.value[f].value[m].value.real:0;c=nc(n);e=Array(b);for(f=0;f<b;++f)m= -c[f],e[f]=m<d?l.real(m+1):l.real(0);return g.turnIntoCSList(e)}return k};t.take$2=oc;t.length$1=function(a,h){var c=A(a[0]);return"list"===c.ctype||"string"===c.ctype?l.real(c.value.length):k};t.pairs$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.pairs(c):k};t.triples$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.triples(c):k};t.cycle$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.cycle(c):k};t.consecutive$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.consecutive(c): -k};t.reverse$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.reverse(c):k};t.directproduct$2=function(a,h){var c=A(a[0]),b=A(a[1]);return"list"===c.ctype&&"list"===b.ctype?g.directproduct(c,b):k};t.concat$2=Tc;t.common$2=Uc;t.remove$2=Vc;t.append$2=Wc;t.prepend$2=Xc;t.contains$2=function(a,h){var c=A(a[0]),b=A(a[1]);return"list"===c.ctype?g.contains(c,b):k};t.sort$2=function(a,h){return t.sort$3([a[0],null,a[1]],h)};t.sort$3=function(a,h){var c=B(a[0]);if("list"!==c.ctype)return k;var b="#"; -null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);var c=c.value,d=[];J.newvar(b);var e;for(e=0;e<c.length;e++)J.setvar(b,c[e]),d[e]={val:c[e],result:A(a[2])};J.removevar(b);d.sort(w.compareResults);b=[];for(e=0;e<c.length;e++)b[e]=d[e].val;return{ctype:"list",value:b}};t.sort$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.sort1(c):k};t.set$1=function(a,h){var c=A(a[0]);return"list"===c.ctype?g.set(c):k};t.combinations$2=function(a,h){function c(a,h){a===f?n.push(g.turnIntoCSList(m.slice())): -h<e&&(m[a]=b.value[h],c(a+1,h+1),c(a,h+1))}var b=A(a[0]),d=A(a[1]),e,f,m,n;if("number"===d.ctype){f=d.value.real|0;if("number"===b.ctype){e=b.value.real|0;e-f<f&&(f=e-f);if(0>f)return l.real(0);if(0===f)return l.real(1);if(1===f)return b;for(var p=d=1,q=1;q<=f;++q)var t=e-f+q|0,v=q|0,u=pc(t,v)|0,t=t/u|0,v=v/u|0,u=pc(d,v)|0,d=d/u|0,v=v/u|0,u=pc(t,p)|0,t=t/u|0,p=p/u|0,d=d*t|0,p=p*v|0;return l.real(d/p)}if("list"===b.ctype){e=b.value.length;if(0>f||f>e)return g.turnIntoCSList([]);if(0===f)return g.turnIntoCSList([g.turnIntoCSList([])]); -if(f===e)return g.turnIntoCSList([b]);n=[];m=Array(f);c(0,0);return g.turnIntoCSList(n)}}return k};t.zeromatrix$2=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype?g.zeromatrix(c,b):k};t.zerovector$1=function(a,h){var c=B(a[0]);return"number"===c.ctype?g.zerovector(c):k};t.transpose$1=function(a,h){var c=B(a[0]);return"list"===c.ctype&&-1!==g._helper.colNumb(c)?g.transpose(c):k};t.row$2=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===b.ctype&&"list"===c.ctype&& --1!==g._helper.colNumb(c)?g.row(c,b):k};t.column$2=function(a,h){var c=B(a[0]),b=B(a[1]);return"number"===b.ctype&&"list"===c.ctype&&-1!==g._helper.colNumb(c)?g.column(c,b):k};t.dict$0=function(a,h){var c=Ka.create(),b;for(b in h)h.hasOwnProperty(b)&&Ka.put(c,w.string(b),A(h[b]));return c};t.put$3=function(a,h){var c=A(a[0]),b=A(a[1]),d=A(a[2]);return"dict"===c.ctype?(c=Ka.clone(c),Ka.put(c,b,d),c):k};t.get$2=function(a,h){var c=A(a[0]),b=A(a[1]);return"dict"===c.ctype?Ka.get(c,b,k):k};t.red$1=function(a, -h){var c=A(a[0]);return"number"===c.ctype?g.realVector([Math.min(1,Math.max(0,c.value.real)),0,0]):k};t.green$1=function(a,h){var c=A(a[0]);return"number"===c.ctype?g.realVector([0,Math.min(1,Math.max(0,c.value.real)),0]):k};t.blue$1=function(a,h){var c=A(a[0]);return"number"===c.ctype?g.realVector([0,0,Math.min(1,Math.max(0,c.value.real))]):k};t.gray$1=function(a,h){var c=A(a[0]);return"number"===c.ctype?(c=Math.min(1,Math.max(0,c.value.real)),g.realVector([c,c,c])):k};t.grey$1=t.gray$1;D.HSVtoRGB= -function(a,h,c){var b,d,e,f,k,l;a&&void 0===h&&void 0===c&&(h=a.s,c=a.v,a=a.h);f=Math.floor(6*a);k=6*a-f;a=c*(1-h);l=c*(1-k*h);h=c*(1-(1-k)*h);switch(f%6){case 0:b=c;d=h;e=a;break;case 1:b=l;d=c;e=a;break;case 2:b=a;d=c;e=h;break;case 3:b=a;d=l;e=c;break;case 4:b=h;d=a;e=c;break;case 5:b=c,d=a,e=l}return g.realVector([b,d,e])};t.hue$1=function(a,h){var c=A(a[0]);return"number"===c.ctype?(c=c.value.real,c-=Math.floor(c),D.HSVtoRGB(c,1,1)):k};D.shapeconvert=function(a){var h,c;if("circle"===a.type){h= -a.value.value[0];h=w.div(h,h.value[2]);var b=h.value[0].value.real,d=h.value[1].value.real;a=a.value.value[1].value.real;c=Array(125);var e=2*Math.PI/125;for(h=0;125>h;h++)c[h]={X:b+Math.cos(h*e)*a,Y:d+Math.sin(h*e)*a};return[c]}if("polygon"===a.type){b=[];for(h=0;h<a.value.length;h++){d=a.value[h];c=[];for(e=0;e<d.length;e++)c[e]={X:d[e].X,Y:d[e].Y};b[h]=c}return b}};D.shapeop=function(a,h,c){a=D.shapeconvert(a);var b=D.shapeconvert(h);ClipperLib.JS.ScaleUpPaths(a,1E3);ClipperLib.JS.ScaleUpPaths(b, -1E3);h=new ClipperLib.Clipper;h.AddPaths(a,ClipperLib.PolyType.ptSubject,!0);h.AddPaths(b,ClipperLib.PolyType.ptClip,!0);var b=a=ClipperLib.PolyFillType.pftNonZero,d=new ClipperLib.Paths;h.Execute(c,d,a,b);ClipperLib.JS.ScaleDownPaths(d,1E3);return{ctype:"shape",type:"polygon",value:d}};D.shapecommon=function(a,h){return D.shapeop(a,h,ClipperLib.ClipType.ctIntersection)};D.shaperemove=function(a,h){return D.shapeop(a,h,ClipperLib.ClipType.ctDifference)};D.shapeconcat=function(a,h){return D.shapeop(a, -h,ClipperLib.ClipType.ctUnion)};t.key$0=function(a,h){return{ctype:"string",value:Qc}};t.keycode$0=function(a,h){return l.real(Rc)};t.mouse$0=function(a,h){return g.realVector([ta[0],ta[1]])};t.mover$0=function(a,h){if(fa&&fa.mover)return{ctype:"geo",value:fa.mover};console.log("Not moving anything at the moment");return k};t.translate$1=function(a,h){var c=B(a[0]);"list"===c.ctype&&g.isNumberVector(c)&&2===c.value.length&&z.translate(c.value[0].value.real,c.value[1].value.real);return k};t.rotate$1= -function(a,h){var c=B(a[0]);"number"===c.ctype&&z.rotate(c.value.real);return k};t.scale$1=function(a,h){var c=B(a[0]);"number"===c.ctype&&z.scale(c.value.real);return k};t.greset$0=function(a,h){var c=$a.stack.length;z.greset();for(var b=0;b<c;b++)y.restore();return k};t.gsave$0=function(a,h){z.gsave();y.save();return k};t.grestore$0=function(a,h){z.grestore();y.restore();return k};t.color$1=function(a,h){var c=B(a[0]);"list"===c.ctype&&g.isNumberVector(c).value&&z.setcolor(c);return k};t.linecolor$1= -function(a,h){var c=B(a[0]);"list"===c.ctype&&g.isNumberVector(c).value&&z.setlinecolor(c);return k};t.pointcolor$1=function(a,h){var c=B(a[0]);"list"===c.ctype&&g.isNumberVector(c).value&&z.setpointcolor(c);return k};t.alpha$1=function(a,h){var c=B(a[0]);"number"===c.ctype&&z.setalpha(c);return k};t.pointsize$1=function(a,h){var c=B(a[0]);"number"===c.ctype&&z.setpointsize(c);return k};t.linesize$1=function(a,h){var c=B(a[0]);"number"===c.ctype&&z.setlinesize(c);return k};t.textsize$1=function(a, -h){var c=B(a[0]);"number"===c.ctype&&z.settextsize(c);return k};t.playanimation$0=function(a,h){I();return k};t.pauseanimation$0=function(a,h){Ca();return k};t.stopanimation$0=function(a,h){Da();return k};t.text$1=function(a,h){var c=B(a[0]);return w.string(ba(c))};t.replace$3=function(a,h){var c=A(a[0]),b=A(a[1]),d=A(a[2]);if("string"===c.ctype&&"string"===b.ctype&&"string"===d.ctype)return c=c.value,b=b.value.replace(/[^A-Za-z0-9]/g,"\\$&"),d=d.value.replace(/\$/g,"$$$$"),c=c.replace(new RegExp(b, -"g"),d),{ctype:"string",value:c}};t.replace$2=function(a,h){function c(a,c,h){var e="";d=b=-1;for(var g=0;g<c.length;g++){var f=c[g][0],k=a.indexOf(f,h);-1!==k&&(-1===b?(e=f,b=k,d=g):k<b&&(e=f,b=k,d=g))}return e}var b,d,e,g=A(a[0]);e=A(a[1]);if("string"===g.ctype&&"list"===e.ctype){for(var g=g.value,f=[],l=0;l<e.value.length;l++){var m=e.value[l];"list"===m.ctype&&2===m.value.length&&"string"===m.value[0].ctype&&"string"===m.value[1].ctype&&(f[f.length]=[m.value[0].value,m.value[1].value])}b=-1;for(e= -c(g,f,0);-1!==b;)g=g.substring(0,b)+f[d][1]+g.substring(b+e.length,g.length),e=b+f[d][1].length,e=c(g,f,e);return{ctype:"string",value:g}}return k};t.substring$3=function(a,h){var c=A(a[0]),b=B(a[1]),d=B(a[2]);return"string"===c.ctype&&"number"===b.ctype&&"number"===d.ctype?{ctype:"string",value:c.value.substring(Math.floor(b.value.real),Math.floor(d.value.real))}:k};t.tokenize$2=function(a,h){var c=A(a[0]),b=A(a[1]);if("string"===c.ctype&&"string"===b.ctype)return t.tokenize$2([c,g.turnIntoCSList([b])], -h);if("string"===c.ctype&&"list"===b.ctype){c=c.value;if(0===b.value.length){b=!0;if(void 0!==h.autoconvert){var d=A(h.autoconvert);"boolean"===d.ctype&&(b=d.value)}return b&&""!==c&&(b=Number(c),!isNaN(b))?l.real(b):w.string(c)}var d=b.value[0],e=g.turnIntoCSList(b.value.slice(1)),c=c.split(d.value);return g.turnIntoCSList(c.map(function(a){return t.tokenize$2([w.string(a),e],h)}))}return k};t.indexof$2=function(a,h){var c=A(a[0]),b=A(a[1]);return"string"===c.ctype&&"string"===b.ctype?(c=c.value.indexOf(b.value), -l.real(c+1)):k};t.indexof$3=function(a,h){var c=A(a[0]),b=A(a[1]),d=A(a[2]);return"string"===c.ctype&&"string"===b.ctype&&"number"===d.ctype?(c=c.value.indexOf(b.value,Math.round(d.value.real)-1),l.real(c+1)):k};t.parse$1=function(a,h){var c=A(a[0]);return"string"===c.ctype?(c=Ra(c.value),A(c)):k};t.unicode$1=function(a,h){var c;c=A(a[0]);var b=16;if(h.base){var d=A(h.base);"number"===d.ctype&&(b=d.value.real)}if("string"===c.ctype)c=parseInt(c.value,b);else if("number"===c.ctype)c=c.value.real;else return k; -"undefined"!==typeof String.fromCodePoint?c=String.fromCodePoint(c):65535>=c?c=String.fromCharCode(c):(c-=65536,c=String.fromCharCode((c>>10)+55296,(c&1023)+56320));return w.string(c)};t.international$1=function(a,h){return t.international$2([a[0],null],h)};t.international$2=function(a,h){var c=A(a[0]);if("string"!==c.ctype)return k;var b=(p.translations||{})[p.language||"en"]||{};if(!b.hasOwnProperty(c.value))return c;var d=b[c.value];if("string"===typeof d)return w.string(d);if(null===a[1])return c; -var e=A(a[1]),e="number"===e.ctype?e.value.real:0,b=(b._pluralFormFunction||Vd)(e);return b<d.length?w.string(d[b]):c};t.currentlanguage$0=function(a,h){return w.string(p.language||"en")};D.basismap=function(a,h,c,b){var d=g.turnIntoCSList([a,h,c]),d=g.adjoint3(g.transpose(d));b=w.mult(d,b);d=g.turnIntoCSList([w.mult(b.value[0],a),w.mult(b.value[1],h),w.mult(b.value[2],c)]);return g.transpose(d)};t.map$8=function(a,h){var c=M(a[0]),b=M(a[1]),d=M(a[2]),e=M(a[3]),f=M(a[4]),l=M(a[5]),m=M(a[6]),n=M(a[7]); -return f!==k&&l!==k&&m!==k&&n!==k&&c!==k&&b!==k&&d!==k&&e!==k?(f=D.basismap(f,l,m,n),c=D.basismap(c,b,d,e),c=w.mult(f,g.adjoint3(c)),g.normalizeMax(c)):k};t.map$6=function(a,h){var c=M(a[0]),b=M(a[1]),d=M(a[2]),e=g.realVector([0,0,1]),f=g.cross,l=f(f(d,f(e,f(c,b))),f(b,f(e,f(c,d)))),m=M(a[3]),n=M(a[4]),p=M(a[5]),e=f(f(p,f(e,f(m,n))),f(n,f(e,f(m,p))));return m!==k&&n!==k&&p!==k&&e!==k&&c!==k&&b!==k&&d!==k&&l!==k?(m=D.basismap(m,n,p,e),c=D.basismap(c,b,d,l),c=w.mult(m,g.adjoint3(c)),g.normalizeMax(c)): -k};t.map$4=function(a,h){var c=g.ii,b=g.jj,d=M(a[0]),e=M(a[1]),f=M(a[2]),l=M(a[3]);return f!==k&&l!==k&&d!==k&&e!==k?(f=D.basismap(f,l,c,b),c=D.basismap(d,e,c,b),c=w.mult(f,g.adjoint3(c)),g.normalizeMax(c)):k};t.map$2=function(a,h){var c=g.ii,b=g.jj,d=M(a[0]),e=w.add(g.realVector([1,0,0]),d),f=M(a[1]),l=w.add(g.realVector([1,0,0]),f);return f!==k&&l!==k&&d!==k&&e!==k?(f=D.basismap(f,l,c,b),c=D.basismap(d,e,c,b),c=w.mult(f,g.adjoint3(c)),g.normalizeMax(c)):k};t.pointreflect$1=function(a,h){var c=g.ii, -b=g.jj,d=M(a[0]),e=w.add(g.realVector([1,0,0]),d),f=w.add(g.realVector([-1,0,0]),d);return f!==k&&d!==k&&e!==k?(f=D.basismap(d,f,c,b),c=D.basismap(d,e,c,b),c=w.mult(f,g.adjoint3(c)),g.normalizeMax(c)):k};t.linereflect$1=function(a,h){var c=g.ii,b=g.jj,d=M(a[0]),e=g.realVector([Math.random(),Math.random(),Math.random()]),f=g.realVector([Math.random(),Math.random(),Math.random()]),e=g.cross(e,d),f=g.cross(f,d);return d!==k&&e!==k?(d=D.basismap(e,f,c,b),c=D.basismap(e,f,b,c),c=w.mult(d,g.adjoint3(c)), -g.normalizeMax(c)):k};D.extractPointVec=function(a){var h={ok:!1};if("geo"===a.ctype){var c=a.value;if("P"===c.kind)return h.x=ya.getField(c,"x"),h.y=ya.getField(c,"y"),h.z=l.real(1),h.ok=!0,h}if("list"!==a.ctype)return h;var b=a.value;if(2===b.length&&(a=b[0],c=b[1],"number"===a.ctype&&"number"===c.ctype))return h.x=a,h.y=c,h.z=l.real(1),h.ok=!0,h;3===b.length&&(a=b[0],c=b[1],b=b[2],"number"===a.ctype&&"number"===c.ctype&&"number"===b.ctype&&(h.x=l.div(a,b),h.y=l.div(c,b),h.z=l.real(1),h.ok=!0)); -return h};t.polygon$1=function(a,h){var c=A(a[0]);if("list"===c.ctype){for(var b=[],d=0;d<c.value.length;d++){var e=D.extractPoint(c.value[d]);if(!e.ok)return k;b[d]={X:e.x,Y:e.y}}return{ctype:"shape",type:"polygon",value:[b]}}return k};t.circle$2=function(a,h){var c=B(a[0]),b=B(a[1]),c=D.extractPointVec(c);if(!c.ok||"number"!==b.ctype)return k;c=g.turnIntoCSList([c.x,c.y,c.z]);return{ctype:"shape",type:"circle",value:g.turnIntoCSList([c,b])}};t.screen$0=function(a,h){var c=z.drawingstate.initialmatrix, -b=function(a,b){var h=a-c.tx,d=b+c.ty;return{X:(h*c.d-d*c.b)/c.det,Y:-(-h*c.c+d*c.a)/c.det}};return{ctype:"shape",type:"polygon",value:[[b(0,0),b(da,0),b(da,ca),b(0,ca)]]}};t.halfplane$2=function(a,b){var c=B(a[0]),d=B(a[1]),e=M(c),f=M(d);if(c!==k&&d!==k){var m=d.usage,d=e,n=f;if("Line"===c.usage||"Point"===m)d=f,n=e;c=g.turnIntoCSList([n.value[0],n.value[1],l.zero]);c=g.cross(c,d);c=g.cross(n,c);c=w.div(c,c.value[2]);d=w.div(d,d.value[2]);d=g.sub(d,c);n=g.abs(d);d=w.div(d,n);n=c.value[0].value.real; -c=c.value[1].value.real;e=1E3*d.value[0].value.real;d=1E3*d.value[1].value.real;return{ctype:"shape",type:"polygon",value:[[{X:n+d/2,Y:c-e/2},{X:n+d/2+e,Y:c-e/2+d},{X:n-d/2+e,Y:c+e/2+d},{X:n-d/2,Y:c+e/2}]]}}return k};t.element$1=function(a,b){var c=A(a[0]);return"string"===c.ctype&&u.csnames.hasOwnProperty(c.value)?{ctype:"geo",value:u.csnames[c.value]}:k};D.all$1=function(a,b){var c=A(a[0]);return"geo"===c.ctype&&c.value.incidences?g.ofGeos(c.value.incidences.map(function(a){return u.csnames[a]}).filter(b)): -g.nil};t.allpoints$0=function(a,b){return g.ofGeos(u.points)};t.allpoints$1=function(a,b){return D.all$1(a,function(a){return"P"===a.kind})};t.allmasses$0=function(a,b){return g.ofGeos(ga)};t.allmasses$1=function(a,b){return D.all$1(a,function(a){return"P"===a.kind&&a.behavior&&"Mass"===a.behavior.type})};t.allsprings$0=function(a,b){return g.ofGeos(zc)};t.allsprings$1=function(a,b){return D.all$1(a,function(a){return"S"===a.kind&&a.behavior&&"Spring"===a.behavior.type})};t.alllines$0=function(a, -b){return g.ofGeos(u.lines)};t.alllines$1=function(a,b){return D.all$1(a,function(a){return"L"===a.kind||"S"===a.kind})};t.allsegments$0=function(a,b){return g.ofGeos(u.lines.filter(function(a){return"S"===a.kind}))};t.allsegments$1=function(a,b){return D.all$1(a,function(a){return"S"===a.kind})};t.allconics$0=function(a,b){return g.ofGeos(u.conics)};t.allconics$1=function(a,b){return D.all$1(a,function(a){return"C"===a.kind})};t.allcircles$0=function(a,b){return g.ofGeos(u.conics.filter(function(a){return"Circle"=== -a.matrix.usage}))};t.allcircles$1=function(a,b){return D.all$1(a,function(a){return"C"===a.kind&&"Circle"===a.matrix.usage})};t.allelements$0=function(a,b){return g.ofGeos(u.gslp)};t.allelements$1=function(a,b){return D.all$1(a,function(a){return!0})};t.incidences$1=t.allelements$1;t.createpoint$2=function(a,b){var c=A(a[0]),d=M(a[1]);return"string"!==c.ctype?(console.log("Name must be a string"),k):"list"!==d.ctype&&g.isNumberVector(d)?(console.log("Position must be a number vector"),k):Ha({name:c.value, -type:"Free",labeled:!0,pos:d})};t.create$3=function(a,b){var c=A(a[0]),d=A(a[1]),e=A(a[2]),f,n;if("string"===c.ctype)f=c.value;else{if("list"!==c.ctype)return console.log("Names must be a string or a list of strings"),k;if(1!==c.value.length){f=w.string(c.value.map(function(a){return a.value}).join("__"));f=t.create$3([f,d,e],b);if(f!==k)for(d=w.string(f.kind.replace(/^(.*)s$/,"Select$1")),e=g.turnIntoCSList([w.string(f.name)]),n=0;n<c.value.length;++n)t.create$3([c.value[n],d,e],{index:l.real(n+ -1)});return f}if("string"!==c.value[0].ctype)return console.log("Element of names list must be a string"),k;f=c.value[0].value}if("string"!==d.ctype)return console.log("Type must be a string"),k;if("list"!==e.ctype)return console.log("Arguments must be a list"),k;if(!m.hasOwnProperty(d.value)&&!tc.hasOwnProperty(d.value)&&!rd.hasOwnProperty(d.value))return console.log("Invalid geometric operation: '"+d.value+"'"),k;var c=[],p=null;for(n=0;n<e.value.length;n++){var q=e.value[n];if("string"===q.ctype)c.push(q.value); -else if("geo"===q.ctype)c.push(q.value.name);else if(p=M(q),p===k)return console.log("Unknown argument type"),k}f={name:f,type:d.value,labeled:!0};p&&(f.pos=p);0<c.length&&(f.args=c);d=B(b.index);"number"===d.ctype&&(f.index=d.value.real|0);return Ha(f)};t.javascript$1=function(a,b){var c=A(a[0]);"string"===c.ctype&&(new Function(c.value)).call(oa);return k};t.use$1=function(a,b){function c(a,c,b){t[a.toLowerCase()+"$"+c]=b}var d=A(a[0]);if("string"===d.ctype){var d=d.value,e;p.plugins&&(e=p.plugins[d]); -e||(e=wa._pluginRegistry[d]);if(e)return e({instance:oa,config:p,nada:k,evaluate:A,extractPoint:D.extractPoint,evaluateAndVal:B,defineFunction:c,addShutdownHook:jb.push.bind(jb),addAutoCleaningEventListener:H,getVariable:J.getvar.bind(J),getInitialMatrix:function(){return z.drawingstate.initialmatrix},setTextRenderer:function(a,c){Bc=a;c&&(td=c)},getImage:function(a,c){"string"===typeof a&&(a=w.string(a));var b=La(a);if(!b)return null;!c&&b.cdyUpdate&&b.cdyUpdate();return b},getMyfunction:function(a){return Za.hasOwnProperty(a)? -Za[a]:null}}),{ctype:"boolean",value:!0};console.log("Plugin "+d+" not found");return{ctype:"boolean",value:!1}}return k};t.format$2=function(a,b){function c(a){a=a.toFixed(f);var c;do c=a,a=a.substring(0,a.length-1);while(""!==a&&"-"!==a&&+a===+c);return""+c}function d(a){var b;return"number"===a.ctype?(b=c(a.value.real),a=c(a.value.imag),b="0"===a?b:"-"===a.substring(0,1)?b+" - i*"+a.substring(1):b+" + i*"+a,{ctype:"string",value:b}):"list"===a.ctype?{ctype:"list",value:a.value.map(d)}:{ctype:"string", -value:ba(a).toString()}}var e=B(a[0]),g=B(a[1]),f;return"number"!==e.ctype&&"list"!==e.ctype||"number"!==g.ctype?k:(f=Math.max(0,Math.min(20,Math.round(g.value.real))),d(e))};Date.now||(Date.now=function(){return(new Date).getTime()});var Id=0;t.timestamp$0=function(a,b){return l.real(Date.now())};t.seconds$0=function(a,b){return l.real((Date.now()-Id)/1E3)};t.resetclock$0=function(a,b){Id=Date.now();return k};t.time$0=function(a,b){var c=new Date;return g.realVector([c.getHours(),c.getMinutes(), -c.getSeconds(),c.getMilliseconds()])};t.date$0=function(a,b){var c=new Date;return g.realVector([c.getFullYear(),c.getMonth()+1,c.getDate()])};t.simulationtime$0=function(a,b){return l.real(Cb*Fd)};t.settimeout$2=function(a,b){function c(){A(g);e()}var d=A(a[0]),g=a[1];"number"===d.ctype&&"undefined"!==typeof window&&window.setTimeout(c,1E3*d.value.real);return k};D.formatForWebGL=function(a){return a.toFixed(10)};t.generateWebGL$2=function(a,b){var c=D.formatForWebGL,d=a[0],e=A(a[1]);console.log(e); -if("list"!==e.ctype)return k;for(var g=[],f=0;f<e.value.length;f++)"string"===e.value[f].ctype&&g.push(e.value[f].value);console.log("***********");console.log(g);e=D.plotvars(d);console.log(e);-1===e.indexOf("a")&&-1===e.indexOf("b")&&-1===e.indexOf("c")&&-1===e.indexOf("d")&&-1===e.indexOf("e")&&-1===e.indexOf("f")&&(d=B(d));if("number"===d.ctype)return{ctype:"string",value:"vec2("+c(d.value.real)+","+c(d.value.imag)+")"};if("variable"===d.ctype)return{ctype:"string",value:d.name};if("string"=== -d.ctype||"void"===d.ctype)return d;if(2===d.args.length&&("infix"===d.ctype||"function"===d.ctype)){c=t.compileToWebGL$1([d.args[0]],{});e=t.compileToWebGL$1([d.args[1]],{});if("+"===d.oper||"add"===d.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:e.value}:{ctype:"string",value:"addc("+c.value+","+e.value+")"};if("*"===d.oper||"mult"===d.oper)return{ctype:"string",value:"multc("+c.value+","+e.value+")"};if("/"===d.oper||"div"===d.oper)return{ctype:"string",value:"divc("+c.value+ -","+e.value+")"};if("-"===d.oper||"sub"===d.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:"negc("+e.value+")"}:{ctype:"string",value:"subc("+c.value+","+e.value+")"};if("^"===d.oper||"pow"===d.oper)return{ctype:"string",value:"powc("+c.value+","+e.value+")"}}if("function"===d.ctype&&1===d.args.length){c=t.compileToWebGL$1([d.args[0]],{});if("sin$1"===d.oper)return{ctype:"string",value:"sinc("+c.value+")"};if("cos$1"===d.oper)return{ctype:"string",value:"cosc("+c.value+")"}; -if("tan$1"===d.oper)return{ctype:"string",value:"tanc("+c.value+")"};if("exp$1"===d.oper)return{ctype:"string",value:"expc("+c.value+")"};if("log$1"===d.oper)return{ctype:"string",value:"logc("+c.value+")"};if("arctan$1"===d.oper)return{ctype:"string",value:"arctanc("+c.value+")"};if("arcsin$1"===d.oper)return{ctype:"string",value:"arcsinc("+c.value+")"};if("arccos$1"===d.oper)return{ctype:"string",value:"arccosc("+c.value+")"};if("sqrt$1"===d.oper)return{ctype:"string",value:"sqrtc("+c.value+")"}}return k}; -t.compileToWebGL$1=function(a,b){var c,d;c=D.formatForWebGL;var e=a[0];d=D.plotvars(e);-1===d.indexOf("a")&&-1===d.indexOf("b")&&-1===d.indexOf("c")&&-1===d.indexOf("d")&&-1===d.indexOf("e")&&-1===d.indexOf("f")&&(e=B(e));if("number"===e.ctype)return{ctype:"string",value:"vec2("+c(e.value.real)+","+c(e.value.imag)+")"};if("variable"===e.ctype)return{ctype:"string",value:e.name};if("string"===e.ctype||"void"===e.ctype)return e;if(2===e.args.length&&("infix"===e.ctype||"function"===e.ctype)){c=t.compileToWebGL$1([e.args[0]], -{});d=t.compileToWebGL$1([e.args[1]],{});if("+"===e.oper||"add"===e.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:d.value}:{ctype:"string",value:"addc("+c.value+","+d.value+")"};if("*"===e.oper||"mult"===e.oper)return{ctype:"string",value:"multc("+c.value+","+d.value+")"};if("/"===e.oper||"div"===e.oper)return{ctype:"string",value:"divc("+c.value+","+d.value+")"};if("-"===e.oper||"sub"===e.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:"negc("+d.value+ -")"}:{ctype:"string",value:"subc("+c.value+","+d.value+")"};if("^"===e.oper||"pow"===e.oper)return{ctype:"string",value:"powc("+c.value+","+d.value+")"}}if("function"===e.ctype&&1===e.args.length){c=t.compileToWebGL$1([e.args[0]],{});if("sin$1"===e.oper)return{ctype:"string",value:"sinc("+c.value+")"};if("cos$1"===e.oper)return{ctype:"string",value:"cosc("+c.value+")"};if("tan$1"===e.oper)return{ctype:"string",value:"tanc("+c.value+")"};if("exp$1"===e.oper)return{ctype:"string",value:"expc("+c.value+ -")"};if("log$1"===e.oper)return{ctype:"string",value:"logc("+c.value+")"};if("arctan$1"===e.oper)return{ctype:"string",value:"arctanc("+c.value+")"};if("arcsin$1"===e.oper)return{ctype:"string",value:"arcsinc("+c.value+")"};if("arccos$1"===e.oper)return{ctype:"string$1",value:"arccosc("+c.value+")"};if("sqrt$1"===e.oper)return{ctype:"string",value:"sqrtc("+c.value+")"}}return k};t.setsimulationspeed$1=function(a,b){var c=B(a[0]);"number"===c.ctype&&sa(c.value.real);return k};t.setsimulationaccuracy$1= -function(a,b){var c=B(a[0]);"number"===c.ctype&&"undefined"!==typeof O&&"undefined"!==typeof O.env&&(O.env.accuracy=Math.max(1,c.value.real|0));return k};t.setsimulationquality$1=function(a,b){var c=B(a[0]);"number"===c.ctype&&"undefined"!==typeof O&&"undefined"!==typeof O.env&&(c=c.value.real,0===c&&(O.env.errorbound=.01,O.env.lowestdeltat=1E-5,O.env.slowdownfactor=2),1===c&&(O.env.errorbound=.001,O.env.lowestdeltat=1E-7,O.env.slowdownfactor=2),2===c&&(O.env.errorbound=1E-5,O.env.lowestdeltat=1E-10, -O.env.slowdownfactor=4),3===c&&(O.env.errorbound=1E-6,O.env.lowestdeltat=1E-12,O.env.slowdownfactor=4));return k};var Wb=null,dc=null;t.createtool$3=function(a,b){var c,d="left",e="top",g=null;b.space&&(c=A(b.space),"number"===c.ctype&&(g=c.value.real/2));var f=null;b.toolbar&&(c=A(b.toolbar),"string"===c.ctype&&((f=document.getElementById(c.value))||console.warn("Element #"+c.value+" not found")));if(!f){if(b.reference){var l=A(b.reference);if("string"===l.ctype)switch(l.value){case "UR":d="right"; -break;case "LL":e="bottom";break;case "LR":d="right",e="bottom"}}f=document.createElement("div");f.className="CindyJS-toolbar";ka.parentNode.appendChild(f);l=A(a[1]);c=A(a[2]);"number"===l.ctype&&(f.style[d]=l.value.real+"px");"number"===c.ctype&&(f.style[e]=c.value.real+"px");null!==g&&(f.style.margin=-g+"px")}l=A(a[0]);if("string"===l.ctype)l=[[l.value]];else if("list"===l.ctype)l=l.value.map(function(a){return"string"===a.ctype?[a.value]:"list"===a.ctype?a.value.map(function(a){return"string"=== -a.ctype?a.value:null}):[null]});else return console.log("Name must be a string or a list of strings"),k;if(b.flipped&&(c=A(b.flipped),"boolean"===c.ctype&&c.value)){console.log("Flipping");var m=0;c=l.length;l.forEach(function(a){a.length>m&&(m=a.length)});for(var n=[],p=0;p<m;++p){n[p]=[];for(var q=0;q<c;++q)n[p][q]=l[q][p]||null}l=n}"bottom"===e&&l.reverse();l.forEach(function(a){"right"===d&&a.reverse();var c=document.createElement("div");f.appendChild(c);a.forEach(function(a){function b(){Wb&& -Wb.classList.remove("CindyJS-active");Wb=d;d.classList.add("CindyJS-active");qc=a;var c=G[qc].actions;dc&&(dc.textContent=c[0].tooltip||"");ua=[];sb=Ua=0}G.hasOwnProperty(a)||(console.log("Tool '"+a+"' not implemented yet."),a=null);if(null===a){var h=document.createElement("span");h.className="CindyJS-spacer";c.appendChild(h)}else{var d=document.createElement("button"),h=document.createElement("img");h.src=wa.getBaseDir()+"images/"+a+".png";d.appendChild(h);d.addEventListener("click",b);Wb||b(); -null!==g&&(d.style.margin=g+"px");c.appendChild(d)}})});return k};t.dropped$0=function(){return kc};t.droppoint$0=function(){return lc};t.parsecsv$1=function(a,b){var c=!0,d=B(b.autoconvert);"boolean"===d.ctype&&(c=d.value);var e=null,d=B(b.delimiter);"string"===d.ctype&&/^[^\"\r\n]$/.test(d.value)&&(e=d.value);d=B(a[0]);if("string"!==d.ctype)return console.log("CSV data is not a string"),k;var d=d.value,f='(?:"((?:[^"]+|"")*)"|([^]*?))(\r\n|(,)|[\r\n]|$)';e&&(e=e.replace(/[^A-Za-z0-9]/g,"\\$&").replace(/\$/g, -"$$$$"),f=f.replace(/,/g,e));for(var f=new RegExp(f,"g"),e=[],m=[],n=null;f.lastIndex<d.length;){var p=f.exec(d),q=p[2];"string"===typeof p[1]&&(q=p[1].replace(/""/g,'"'));q=c?/^[Tt]rue$/.test(q)?w.bool(!0):/^[Ff]alse$/.test(q)?w.bool(!1):/^[\-+]?([0-9]+(\.[0-9]*)?|\.[0-9]+|Infinity)$/.test(q)?l.real(Number(q)):w.string(q):w.string(q);e.push(q);p[4]&&f.lastIndex===d.length&&(e.push(w.string("")),p={});if(!p[4]){null===n&&(n=e.length);if(n<e.length)for(n=e.length,p=0;p<m.length;++p)for(q=m[p].length;q< -n;++q)m[p][q]=k;else if(n>e.length)for(p=e.length;p<n;++p)e[p]=k;m.push(e);e=[]}}return g.turnIntoCSList(m.map(g.turnIntoCSList))};t.load$2=function(a,b){return t.load$3([a[0],null,a[1]],b)};t.load$3=function(a,b){function c(){if(l.readyState===XMLHttpRequest.DONE){var c;200===l.status?c=w.string(String(l.responseText)):(ia.err("Failed to load "+f+": "+l.statusText),c=k);J.newvar(d);J.setvar(d,c);A(a[2]);J.removevar(d);e()}}var d="#";null!==a[1]&&"variable"===a[1].ctype&&(d=a[1].name);var g=B(a[0]), -f=null,l=null;"string"===g.ctype&&/^https?:\/\//.test(g.value)&&(f=g.value);return null!==f?(l=new XMLHttpRequest,l.onreadystatechange=c,l.open("GET",f),l.send(),w.bool(!0)):k};D.extractPoint=function(a){var b={ok:!1};if("geo"===a.ctype){var c=a.value;if("P"===c.kind)return b.x=ya.getField(c,"x").value.real,b.y=ya.getField(c,"y").value.real,b.ok=!0,b}if("list"!==a.ctype)return b;var d=a.value;if(2===d.length&&(a=d[0],c=d[1],"number"===a.ctype&&"number"===c.ctype))return b.x=a.value.real,b.y=c.value.real, -b.ok=!0,b;3===d.length&&(a=d[0],c=d[1],d=d[2],"number"===a.ctype&&"number"===c.ctype&&"number"===d.ctype&&(a=l.div(a,d),c=l.div(c,d),b.x=a.value.real,b.y=c.value.real,b.ok=!0));return b};t.draw$1=function(a,b){var c=B(a[0]);if("shape"===c.ctype)D.drawshape(c,b);else if("Line"===c.usage)x.handleModifs(b,x.lineModifs),x.drawline(c);else{var d=D.extractPoint(c);if(!d.ok){if("undefined"!==typeof c.value&&2===c.value.length)return t.draw$2(c.value,b);return}null!==b&&x.handleModifs(b,x.pointModifs);x.drawpoint(d)}return k}; -t.draw$2=function(a,b){var c=B(a[0]),d=B(a[1]),c=D.extractPoint(c),d=D.extractPoint(d);if(!c.ok||!d.ok)return k;null!==b&&x.handleModifs(b,x.lineModifs);x.drawsegcore(c,d);return k};t.drawcircle$2=function(a,b){return D.drawcircle(a,b,"D")};D.arcHelper=function(a){var b={};b.startPoint=M(a[0]);b.viaPoint=M(a[1]);b.endPoint=M(a[2]);return b};t.fillcircle$2=function(a,b){return D.drawcircle(a,b,"F")};t.drawarc$3=function(a,b){var c=D.arcHelper(a);return D.drawarc(c,b,"D")};t.fillarc$3=function(a,b){var c= -D.arcHelper(a);return D.drawarc(c,b,"F")};D.drawarc=function(a,b,c){var d=a.startPoint,e=a.viaPoint;a=a.endPoint;if(!g._helper.isAlmostReal(g.turnIntoCSList([d,e,a])))return k;x.handleModifs(b,x.conicModifs);x.preDrawCurve();b=g.det3(d,e,a);if(1E-12<Math.abs(b.value.real)){b=m._helper.ConicBy5(null,d,e,a,g.ii,g.jj);var f=m._helper.CenterOfConic(b),f=g.normalizeMax(f);b=l.real(0);var n=g.turnIntoCSList([g.turnIntoCSList([f.value[2],b,l.neg(f.value[0])]),g.turnIntoCSList([b,f.value[2],l.neg(f.value[1])]), -g.turnIntoCSList([b,b,f.value[2]])]);b=g.normalizeZ(w.mult(n,d));g.normalizeZ(w.mult(n,e));n=g.normalizeZ(w.mult(n,a));b=-Math.atan2(b.value[1].value.real,b.value[0].value.real);n=-Math.atan2(n.value[1].value.real,n.value[0].value.real);f=g.normalizeZ(f);d=g.normalizeZ(d);e=g.normalizeZ(e);a=g.normalizeZ(a);var p=g.abs(g.sub(d,f)),q=[f.value[0].value.real,f.value[1].value.real],f=z.drawingstate.matrix,t=q[0]*f.a-q[1]*f.b+f.tx,q=q[0]*f.c-q[1]*f.d-f.ty,d=0<g.det3(d,e,a).value.real;y.save();y.beginPath(); -y.translate(t,q);y.arc(0,0,p.value.real*f.sdet,b,n,d);"F"===c&&(y.fillStyle=x.lineColor,y.closePath(),y.fill());"D"===c&&y.stroke();y.restore()}else{if("D"!==c)return k;c=D.extractPoint(d);b=D.extractPoint(e);n=D.extractPoint(a);if(!c.ok||!b.ok||!n.ok)return k;p=(c.x-n.x)*(c.x-n.x)+(c.y-n.y)*(c.y-n.y);f=(n.x-b.x)*(n.x-b.x)+(n.y-b.y)*(n.y-b.y);if(1E-12>(c.x-b.x)*(c.x-b.x)+(c.y-b.y)*(c.y-b.y)||1E-12>p||1E-12>f)return k;0>g.crossratio3(d,a,e,g.cross(g.cross(d,e),g.linfty),g.ii).value.real?x.drawsegcore(c, -n):x.drawRaySegment(d,a)}return k};D.drawcircle=function(a,b,c){var d=B(a[0]);a=B(a[1]);var e=D.extractPoint(d);if(!e.ok||"number"!==a.ctype||!l._helper.isAlmostReal(a))return k;var d=z.drawingstate.matrix,g=e.x*d.a-e.y*d.b+d.tx,e=e.x*d.c-e.y*d.d-d.ty;x.handleModifs(b,x.conicModifs);x.preDrawCurve();y.lineJoin="miter";y.beginPath();y.arc(g,e,Math.abs(a.value.real)*d.sdet,0,2*Math.PI);y.closePath();"D"===c&&y.stroke();"F"===c&&(y.fillStyle=x.lineColor,y.fill());"C"===c&&y.clip();return k};t.drawconic$1= -function(a,b){var c;c=B(a[0]);if("list"!==c.ctype||3!==c.value.length&&6!==c.value.length)return console.error("could not parse conic"),k;if(6===c.value.length){for(var d=0;6>d;d++)if("number"!==c.value[d].ctype)return console.error("could not parse conic"),k;var e=l.real(.5),d=c.value[0],f=c.value[2],f=l.mult(f,e),m=c.value[1],n=c.value[3],n=l.mult(n,e),p=c.value[4],p=l.mult(p,e);c=c.value[5];c=g.turnIntoCSList([g.turnIntoCSList([d,f,n]),g.turnIntoCSList([f,m,p]),g.turnIntoCSList([n,p,c])])}else{for(d= -0;3>d;d++)for(f=0;3>f;f++)if("number"!==c.value[d].value[f].ctype)return console.error("could not parse conic"),k;g.equals(c,g.transpose(c)).value||(d=w.mult(c,l.real(.5)),c=w.mult(g.transpose(c),l.real(.5)),c=g.add(d,c))}c=g.normalizeMax(c);return D.drawconic(c,b)};D.drawconic=function(a,b){x.handleModifs(b,x.conicModifs);if(0!==x.lsize){x.preDrawCurve();for(var c=g.normalizeMax(a),d=c,e=0;2>e;e++)for(var f=0;2>f;f++)if(Math.abs(c.value[e].value[f].value.imag)>l.eps)return;e=g.turnIntoCSList([g.realVector([-1, --1,1]),g.realVector([1,0,0]),g.realVector([0,1,0])]);f=z.from(0,0,1);f[2]=1;var n=z.from(1,0,1);n[2]=1;var p=z.from(0,1,1);p[2]=1;var f=g.turnIntoCSList([g.realVector(f),g.realVector(n),g.realVector(p)]),f=g.transpose(f),e=w.mult(f,e),e=g.inverse(e),c=w.mult(g.transpose(e),c),c=w.mult(c,e),e=c.value[0].value[0].value.real,f=c.value[1].value[0].value.real,n=c.value[1].value[1].value.real,p=c.value[2].value[0].value.real,q=c.value[2].value[1].value.real,v=c.value[2].value[2].value.real,c=[[e,f,p],[f, -n,q],[p,q,v]],u=1E-14>Math.abs(e*n*v-e*q*q-f*f*v+2*f*p*q-n*p*p);if(u&&"Circle"===a.usage){var A=w.mult(g.adjoint3(d),g.linfty);l.abs(A.value[2]).value.real>l.eps&&(u=!1)}var A=da>ca?da:ca,B=-1.5*A,C=1.5*A,D=-1.5*A,E=1.5*A,F=1;u&&(F=0);if(F)var p=0,p=1E-14<Math.abs(e-f)?Math.atan(f/e-n)/2:Math.PI/4,G=function(a){var c=Math.cos(a);a=Math.sin(a);return[[c,-a,0],[a,c,0],[0,0,1]]}(p),G=g.realMatrix(G),e=g.transpose(G),c=w.mult(g.realMatrix(c),G),c=w.mult(e,c),e=c.value[0].value[0].value.real,f=c.value[1].value[0].value.real, -n=c.value[1].value[1].value.real,p=c.value[2].value[0].value.real,q=c.value[2].value[1].value.real,v=c.value[2].value[2].value.real;var c=[e,f,n,p,q,v],e=function(){var a=m._helper.splitDegenConic(d);if(a!==k){var c=a[1],a=[a[0]];t.draw$1(a,b);a[0]=c;t.draw$1(a,b)}},H=function(a){"undefined"!==a&&6===a.length||console.error("this does not define a Conic");if(u)return"degenerate";a=a[0]*a[2]-a[1]*a[1];return 1E-14>Math.abs(a)?"parabola":1E-14<a?"ellipsoid":"hyperbola"};H(c);var L=function(a,c){return 0< -a&&a<da&&0<c&&c<ca},J=[],I=[],K=[],M=[],N=[],O=[],P=function(){J=[];I=[];K=[];M=[];N=[];O=[]},R=function(a,c){y.beginPath();y.moveTo(a[0],c[0]);for(var b=1;b<a.length;b++)y.lineTo(a[b],c[b]);y.stroke()},S=function(a,c,b){var h,d,e=H(a);if(6!==a.length)console.error("Conic needs 6 Parameters");else{var f=a[0],r=a[1],k=a[2],l=a[3],m=a[4];a=a[5];var n;h=b-c;for(var p=.1*h+c,na=b-.1*h,Q=c;Q<=b;Q+=n){n=Q<p||Q>na||100>Math.abs(b-c)?.5:0>Q||Q>ca?10:3;d=-f*k*Q*Q-2*f*m*Q-f*a+r*r*Q*Q+2*r*l*Q+l*l;d=Math.sqrt(d); -h=1/f*(-r*Q-l+d);d=-1/f*(r*Q+l+d);var q,Ga;F?(q=[h,Q,1],Ga=[d,Q,1],q=w.mult(G,g.realVector(q)),Ga=w.mult(G,g.realVector(Ga)),h=q.value[0].value.real,d=Ga.value[0].value.real,q=q.value[1].value.real,Ga=Ga.value[1].value.real):Ga=q=Q;isNaN(h)||"ellipsoid"!==e?!isNaN(h)&&h>=B&&h<=C&&(J.push(h),K.push(q)):(J.push(h),K.push(q));isNaN(d)||"ellipsoid"!==e?!isNaN(d)&&d>=B&&d<=C&&(I.push(d),M.push(Ga)):(I.push(d),M.push(Ga))}}},f=function(a){var c,b,h;H(a);if(6!==a.length)console.error("Conic needs 6 Parameters"); -else{h=a[0];var d=a[1],e=a[2],f=a[3],g=a[4],r=a[5];c=-h*g+d*f;b=Math.sqrt(h*(-h*e*r+h*Math.pow(g,2)+Math.pow(d,2)*r-2*d*f*g+e*Math.pow(f,2)));e=h*e-Math.pow(d,2);1E-14<Math.abs(e)?(h=(c-b)/e,b=(c+b)/e):b=h=(-h*r+f*f)/(2*h*g-2*d*f);!isNaN(h)&&h>D&&h<E||(h=D);!isNaN(b)&&b>D&&b<E||(b=D);c=h<b?h:b;b=h>b?h:b;S(a,D,c);N=J.concat(I.reverse());O=K.concat(M.reverse());R(N,O);P();S(a,b,E);R(J,K);if(L(J[0],K[1])||L(I[0],M[0]))y.beginPath(),y.moveTo(J[0],K[0]),y.lineTo(I[0],M[0]),y.stroke();R(I,M);P();S(a,c, -b);R(J,K);y.beginPath();y.moveTo(J[0],K[0]);y.lineTo(I[0],M[0]);y.stroke();y.beginPath();y.moveTo(J[J.length-1],K[K.length-1]);y.lineTo(I[I.length-1],M[M.length-1]);y.stroke();R(I,M);P()}};u?e():f(c)}};t.drawall$1=function(a,b){var c=A(a[0]);if("list"===c.ctype){x.handleModifs(b,x.pointAndLineModifs);for(var d=0;d<c.value.length;d++)t.draw$1([c.value[d]],null)}return k};t.connect$1=function(a,b){return D.drawpolygon(a,b,"D",!1)};t.drawpoly$1=function(a,b){return D.drawpolygon(a,b,"D",!0)};t.fillpoly$1= -function(a,b){return D.drawpolygon(a,b,"F",!0)};t.drawpolygon$1=function(a,b){return D.drawpolygon(a,b,"D",!0)};t.fillpolygon$1=function(a,b){return D.drawpolygon(a,b,"F",!0)};D.drawpolygon=function(a,b,c,d){function e(){for(var a=l.value,c=0;c<a.length;c++){var b=a[c],h;for(h=0;h<b.length;h++){var d=b[h],f=d.X*g.a-d.Y*g.b+g.tx,d=d.X*g.c-d.Y*g.d-g.ty;0===h?y.moveTo(f,d):y.lineTo(f,d)}y.closePath()}}function f(){var a;for(a=0;a<l.value.length;a++){var c=D.extractPoint(l.value[a]);if(!c.ok)return;var b= -c.x*g.a-c.y*g.b+g.tx,c=c.x*g.c-c.y*g.d-g.ty;0===a?y.moveTo(b,c):y.lineTo(b,c)}d&&y.closePath()}x.handleModifs(b,x.conicModifs);x.preDrawCurve();var g=z.drawingstate.matrix,l=A(a[0]);y.beginPath();"list"===l.ctype&&f();"shape"===l.ctype&&e();"D"===c&&(x.fillColor&&(y.fillStyle=x.fillColor,y.fill(x.fillrule)),y.stroke());"F"===c&&(y.fillStyle=x.lineColor,y.fill(x.fillrule));"C"===c&&y.clip();return k};var Bc=Yc,td=function(a,b,c){if(-1!==b.indexOf("\n"))for(b=b.split("\n"),a.textContent=b[0],c=1;c< -b.length;++c)a.appendChild(document.createElement("br")),a.appendChild(document.createTextNode(b[c]));else a.textContent=b};D.drawtext=function(a,b,c){var d=B(a[0]);a=A(a[1]);var e=D.extractPoint(d);if(!e.ok)return null;x.handleModifs(b,x.textModifs);b=z.drawingstate.textsize;null===b&&(b=la.textsize);null!==x.size&&(b=x.size);y.fillStyle=x.textColor;var f=z.drawingstate.matrix,d=e.x*f.a-e.y*f.b+f.tx+x.xOffset,e=e.x*f.c-e.y*f.d-f.ty-x.yOffset;a=ba(a);f=x.bold+x.italics+Math.round(10*b)/10+"px "+x.family; -y.font=f;return c?c(a,f,d,e,x.align,b):Bc(y,a,d,e,x.align,b,b*la.lineHeight)};t.drawtext$2=function(a,b){D.drawtext(a,b,null);return k};t.drawtable$2=function(a,b){var c=B(a[0]),d=B(a[1]),e=D.extractPoint(c);if(!e.ok||"list"!==d.ctype)return k;var d=d.value,c=d.length,f=-1,l;for(l=0;l<c;++l)"list"===d[l].ctype&&d[l].value.length>f&&(f=d[l].value.length);-1===f?(d=d.map(function(a){return[a]}),f=1):d=d.map(function(a){return g.asList(a).value});var m=100,n=null,p=!0,q=z.drawingstate.textcolor;x.handleModifs(b, -{size:!0,color:function(a){g._helper.isNumberVecN(a,3)&&(q=x.makeColor([a.value[0].value.real,a.value[1].value.real,a.value[2].value.real]))},alpha:!0,bold:!0,italics:!0,family:!0,align:!0,x_offset:!0,y_offset:!0,offset:!0,width:function(a){"number"===a.ctype&&(m=a.value.real)},height:function(a){"number"===a.ctype&&(n=a.value.real)},border:function(a){"boolean"===a.ctype&&(p=a.value)}});var t=z.drawingstate.textsize;null===t&&(t=la.textsize);null!==x.size&&(t=x.size);null===n&&(n=1.6*t);y.font=x.bold+ -x.italics+Math.round(10*t)/10+"px "+x.family;l=z.drawingstate.matrix;var v=f*m,u=c*n,t=e.x*l.a-e.y*l.b+l.tx+x.xOffset,w=e.x*l.c-e.y*l.d-l.ty-x.yOffset-u;if(p){x.preDrawCurve();y.strokeStyle=x.lineColor;y.beginPath();for(l=1;l<c;++l)y.moveTo(t,w+l*n),y.lineTo(t+v,w+l*n);for(e=1;e<f;++e)y.moveTo(t+e*m,w),y.lineTo(t+e*m,w+u);y.stroke();y.lineWidth=x.lsize+1;y.beginPath();y.rect(t,w,v,u);y.stroke()}t+=x.align*m+(1-2*x.align)*n*.3;w+=.7*n;y.fillStyle=q;for(l=0;l<c;++l)for(e=0;e<f;++e)v=ba(d[l][e]),Bc(y, -v,t+e*m,w+l*n,x.align);return k};D.drawshape=function(a,b){return"polygon"===a.type?D.drawpolygon([a],b,"D",1):"circle"===a.type?D.drawcircle([a.value.value[0],a.value.value[1]],b,"D"):k};D.fillshape=function(a,b){return"polygon"===a.type?D.drawpolygon([a],b,"F",1):"circle"===a.type?D.drawcircle([a.value.value[0],a.value.value[1]],b,"F"):k};D.clipshape=function(a,b){return"polygon"===a.type?D.drawpolygon([a],b,"C",1):"circle"===a.type?D.drawcircle([a.value.value[0],a.value.value[1]],b,"C"):k};t.fill$1= -function(a,b){var c=A(a[0]);return"shape"===c.ctype?D.fillshape(c,b):k};t.clip$1=function(a,b){var c=A(a[0]);return"shape"===c.ctype?D.clipshape(c,b):"list"===c.ctype?(c=t.polygon$1(a,[]),t.clip$1([c],[])):k};t.plot$1=function(a,b){return t.plot$2([a[0],null],b)};t.plot$2=function(a,b){function c(a){return"number"===a.ctype&&l._helper.isAlmostReal(a)}function d(a,c,b,h,e){n++;c=+c.value.real;e=+h.value.real;h=c*E.a-e*E.b+E.tx;c=c*E.c-e*E.d-E.ty;a=+a.value.real;e=+b.value.real;b=a*E.a-e*E.b+E.tx;a= -a*E.c-e*E.d-E.ty;p?(y.lineTo(b,a),y.lineTo(h,c)):(y.beginPath(),y.moveTo(b,a),y.lineTo(h,c),p=!0)}function e(a,b,h,g,k){var n=c(h),q=c(g);if(.001>k)!f&&p&&(y.stroke(),p=!1);else if(n||q){var t=l.real((a.value.real+b.value.real)/2);J.setvar(B,t);var v=A(w),u=c(v);if(n&&q&&u){var Nb=h.value.real,q=v.value.real,u=g.value.real;if(n=1>Math.abs(Nb+u-2*q)/m){var x=l.real((a.value.real+t.value.real)/2);J.setvar(B,x);var x=A(w),fc=l.real((t.value.real+b.value.real)/2);J.setvar(B,fc);fc=A(w);Nb=Math.abs(Nb+ -q-2*x.value.real)/m;q=Math.abs(q+u-2*fc.value.real)/m;n=n&&1>Nb&&1>q}n?(d(a,t,h,v,k/2),d(t,b,v,g,k/2)):(e(a,t,h,v,k/2),e(t,b,v,g,k/2))}else e(a,t,h,v,k/2),e(t,b,v,g,k/2)}}var f=!1,m=.2/Kb,n=0,p=!1,q=-10,t=10,v=.1,u=1E3,w=a[0],B;if(null!==a[1]&&"variable"===a[1].ctype)B=a[1].name;else{var C=D.plotvars(w);B="#";-1!==C.indexOf("t")&&(B="t");-1!==C.indexOf("z")&&(B="z");-1!==C.indexOf("y")&&(B="y");-1!==C.indexOf("x")&&(B="x")}J.newvar(B);var E=z.drawingstate.matrix;x.handleModifs(b,{color:!0,alpha:!0, -size:!0,dashpattern:!0,dashtype:!0,dashing:!0,lineCap:!0,lineJoin:!0,miterLimit:!0,connect:function(a){"boolean"===a.ctype&&(f=a.value)},start:function(a){"number"===a.ctype&&(q=a.value.real)},stop:function(a){"number"===a.ctype&&(t=a.value.real)},steps:function(a){"number"===a.ctype&&(u=a.value.real)}});y.strokeStyle=x.lineColor;y.lineWidth=x.lsize;var F,G,H,I,p=!1,C=l.real(14.32);J.setvar(B,C);H=A(w);if("number"!==H.ctype){if(g.isNumberVector(H).value&&2===H.value.length){p=!1;v=(t-q)/u;for(C=q;C< -t;C+=v)J.setvar(B,l.real(C)),I=A(w),g.isNumberVector(I).value&&2===I.value.length&&(F=+I.value[0].value.real,G=+I.value[1].value.real,I=F*E.a-G*E.b+E.tx,F=F*E.c-G*E.d-E.ty,p?y.lineTo(I,F):(y.beginPath(),y.moveTo(I,F),p=!0));y.stroke();J.removevar(B)}return k}for(I=q;I<t+v;I+=v)C=l.real(I),J.setvar(B,C),H=A(w),C.value.real>q&&e(F,C,G,H,v),F=C,G=H;J.removevar(B);p&&y.stroke();return k};t.plotX$1=function(a,b){var c=a[0],d=D.plotvars(c),e="#";-1!==d.indexOf("t")&&(e="t");-1!==d.indexOf("z")&&(e="z"); --1!==d.indexOf("y")&&(e="y");-1!==d.indexOf("x")&&(e="x");J.newvar(e);d=z.drawingstate.matrix;y.fillStyle=z.drawingstate.linecolor;y.lineWidth=1;y.lineCap=x.lineCap;y.lineJoin=x.lineJoin;y.miterLimit=x.miterLimit;for(var f=!1,g=-10;10>g;g+=.01){J.setvar(e,l.real(g));var m=A(c);if("number"===m.ctype){var n=+m.value.real,m=g*d.a-n*d.b+d.tx,n=g*d.c-n*d.d-d.ty;f?y.lineTo(m,n):(y.beginPath(),y.moveTo(m,n),f=!0)}}y.stroke();J.removevar(e);return k};D.plotvars=function(a){function b(a,c){var h={},d;for(d= -a.length-1;0<=d;--d)h[a[d]]=a[d];for(d=c.length-1;0<=d;--d)h[c[d]]=c[d];d=[];for(var e in h)h.hasOwnProperty(e)&&d.push(h[e]);return d}function c(a,c){for(var b=0;b<a.length;b++)a[b]===c&&(a.splice(b,1),b--);return a}var d,e,f,g;if("variable"===a.ctype)return[a.name];if("infix"===a.ctype)return d=D.plotvars(a.args[0]),a=D.plotvars(a.args[1]),b(d,a);if("list"===a.ctype){f=a.value;e=[];for(g=0;g<f.length;g++)d=D.plotvars(f[g]),e=b(e,d);return e}if("function"===a.ctype){f=a.args;e=[];for(g=0;g<f.length;g++)d= -D.plotvars(f[g]),e=b(e,d);"apply"!==a.oper&&"select"!==a.oper&&"forall"!==a.oper&&"sum"!==a.oper&&"product"!==a.oper&&"repeat"!==a.oper&&"min"!==a.oper&&"max"!==a.oper&&"sort"!==a.oper||"variable"!==a.args[1].ctype||(e=c(e,a.args[1].name));return e}return[]};t.clrscr$0=function(a,b){"undefined"!==typeof da&&"undefined"!==typeof ca&&y.clearRect(0,0,da,ca);return k};t.repaint$0=function(a,b){e();return k};t.screenbounds$0=function(a,b){var c=w.withUsage(g.realVector(z.to(0,0)),"Point"),d=w.withUsage(g.realVector(z.to(da, -0)),"Point"),e=w.withUsage(g.realVector(z.to(da,ca)),"Point"),f=w.withUsage(g.realVector(z.to(0,ca)),"Point");return g.turnIntoCSList([c,d,e,f])};t.createimage$3=function(a,b){var c=A(a[0]),d=B(a[1]),e=B(a[2]);if("number"!==d.ctype||"number"!==e.ctype||"string"!==c.ctype)return k;var f=document.createElement("canvas");f.id=c.value;f.width=d.value.real;f.height=e.value.real;f.style.display="none";document.body.appendChild(f);Xa[c.value]=aa(f,!1);return k};t.clearimage$1=function(a,b){var c=A(a[0]); -if("string"!==c.ctype&&"image"!==c.ctype)return k;var c=La(c),d=c.img;if("undefined"===typeof d||null===d)return k;var e=c.width,f=c.height;d.getContext("2d").clearRect(0,0,e,f);c.generation++;return k};t.canvas$4=function(a,b){var c=B(a[0]),d=B(a[1]),e=A(a[2]),f=a[3],g=D.extractPoint(c),l=D.extractPoint(d);if(!g.ok||!l.ok||"string"!==e.ctype&&"image"!==e.ctype)return k;e=La(e);if(!e||!e.img.getContext)return k;var d=e.img,m=e.width,c=e.height,n=l.x-g.x,p=l.y-g.y,q=g.x-p*c/m,t=g.y+n*c/m,p=l.x-p*c/ -m,n=l.y+n*c/m,l=z.from(g.x,g.y,1),q=z.from(q,t,1),p=z.from(p,n,1),g=l[0],t=l[1],n=q[0],v=q[1],u=p[0],w=p[1],q=m*(t-v)/((g-n)*(t-w)-(g-u)*(t-v)),m=m*(g-n)/((t-v)*(g-u)-(t-w)*(g-n)),p=-q*g-m*t,l=(c*(t-w)-c*(t-v))/((g-n)*(t-w)-(g-u)*(t-v)),n=(c*(g-u)-c*(g-n))/((t-v)*(g-u)-(t-w)*(g-n)),c=c-l*g-n*t,d=d.getContext("2d"),g=y;y=d;y.save();y.transform(q,l,m,n,p,c);e.generation++;A(f);y.restore();y=g};t.canvas$5=function(a,b){var c=B(a[0]),d=B(a[1]),e=B(a[2]),f=A(a[3]),g=a[4],c=D.extractPoint(c),l=D.extractPoint(d), -m=D.extractPoint(e);if(!c.ok||!l.ok||!m.ok||"string"!==f.ctype&&"image"!==f.ctype)return k;f=La(f);if(!f||!f.img.getContext)return k;var e=f.img,n=f.width,d=f.height,p=z.from(c.x,c.y,1),q=z.from(l.x,l.y,1),l=z.from(m.x,m.y,1),c=p[0],m=p[1],t=q[0],v=q[1],u=l[0],w=l[1],l=((0-n)*(m-w)-0*(m-v))/((c-t)*(m-w)-(c-u)*(m-v)),n=((0-n)*(c-u)-0*(c-t))/((m-v)*(c-u)-(m-w)*(c-t)),q=0-l*c-n*m,p=((d-d)*(m-w)-(d-0)*(m-v))/((c-t)*(m-w)-(c-u)*(m-v)),t=((d-d)*(c-u)-(d-0)*(c-t))/((m-v)*(c-u)-(m-w)*(c-t)),d=d-p*c-t*m,e= -e.getContext("2d"),c=y;y=e;y.save();y.transform(l,p,n,t,q,d);f.generation++;A(g);y.restore();y=c};t.screenresolution$0=function(a,b){return l.real(z.drawingstate.matrix.a)};t.layer$1=function(a,b){};t.imagesize$1=function(a,b){var c=La(B(a[0]));return c?g.realVector([+c.width,+c.height]):k};t.imageready$1=function(a,b){var c=La(B(a[0]));return w.bool(!(!c||!c.ready))};t.drawimage$2=function(a,b){function c(){var a=1,c=1,d=1,f=1,r=0,l=1,n=D.extractPoint(e);if(!n.ok)return k;m=La(m);if(!m)return k; -y.save();var p;void 0!==b.angle&&(p=A(b.angle),"number"===p.ctype&&(r=p.value.real));void 0!==b.rotation&&(p=A(b.rotation),"number"===p.ctype&&(r=p.value.real));void 0!==b.scale&&(p=B(b.scale),"number"===p.ctype&&(c=a=p.value.real),g.isNumberVector(p).value&&2===p.value.length&&(a=p.value[0].value.real,c=p.value[1].value.real));void 0!==b.scalex&&(p=A(b.scalex),"number"===p.ctype&&(a=p.value.real));void 0!==b.scaley&&(p=A(b.scaley),"number"===p.ctype&&(c=p.value.real));void 0!==b.flipx&&(p=A(b.flipx), -"boolean"===p.ctype&&p.value&&(d=-1));void 0!==b.flipy&&(p=A(b.flipy),"boolean"===p.ctype&&p.value&&(f=-1));void 0!==b.alpha&&(p=A(b.alpha),"number"===p.ctype&&(l=p.value.real));var q=z.drawingstate.matrix,Q=z.drawingstate.initialmatrix,t=m.width,v=m.height;p=n.x*q.a-n.y*q.b+q.tx;var u=n.x*q.c-n.y*q.d-q.ty,w=(n.x+1)*q.a-n.y*q.b+q.tx-p,q=(n.x+1)*q.c-n.y*q.d-q.ty-u,Ga=(n.x+1)*Q.a-n.y*Q.b+Q.tx-(n.x*Q.a-n.y*Q.b+Q.tx),Q=(n.x+1)*Q.c-n.y*Q.d-Q.ty-(n.x*Q.c-n.y*Q.d-Q.ty),n=Math.sqrt(w*w+q*q)/Math.sqrt(Ga* -Ga+Q*Q),w=-Math.atan2(w,q)+Math.atan2(Ga,Q),q=z.drawingstate.matrix.sdet/72,a=a*q,c=c*q;1!==l&&(y.globalAlpha=l);y.translate(p,u);y.scale(a*d*n,c*f*n);y.rotate(r+w);y.translate(-p,-u);y.translate(-t/2,-v/2);a=m;a.drawTo?a.drawTo(y,p,u):y.drawImage(a.img,p,u);y.globalAlpha=1;y.restore()}function d(){var a=1,c=1,g=1,r=1,n=D.extractPoint(e),p=D.extractPoint(f),q;if(!n.ok||!p.ok)return k;m=La(m);if(!m)return k;var t=m.width,v=m.height;if(0===l)q={},q.x=n.x-(p.y-n.y),q.y=n.y+(p.x-n.x),r=v/t;else if(q= -D.extractPoint(l),!n.ok)return k;y.save();var u;void 0!==b.alpha&&(u=A(b.alpha),"number"===u.ctype&&(a=u.value.real));void 0!==b.aspect&&(u=A(b.aspect),"number"===u.ctype&&(r=u.value.real));void 0!==b.flipx&&(u=A(b.flipx),"boolean"===u.ctype&&u.value&&(c=-1));void 0!==b.flipy&&(u=A(b.flipy),"boolean"===u.ctype&&u.value&&(g=-1));u=z.drawingstate.matrix;1!==a&&(y.globalAlpha=a);a=n.x*u.a-n.y*u.b+u.tx;n=n.x*u.c-n.y*u.d-u.ty;y.transform(p.x*u.a-p.y*u.b+u.tx-a,p.x*u.c-p.y*u.d-u.ty-n,q.x*u.a-q.y*u.b+u.tx- -a,q.x*u.c-q.y*u.d-u.ty-n,a,n);y.scale(1/t,-1/v*r);y.translate(t/2,-v/2);y.scale(c,g);y.translate(-t/2,v/2);y.translate(0,-v);c=m;c.drawTo?c.drawTo(y,0,0):y.drawImage(c.img,0,0);y.globalAlpha=1;y.restore()}var e,f,l,m;return 2===a.length?(e=B(a[0]),m=B(a[1]),c()):3===a.length?(e=B(a[0]),f=B(a[1]),l=0,m=B(a[2]),d()):4===a.length?(e=B(a[0]),f=B(a[1]),l=B(a[2]),m=B(a[3]),d()):k};t.drawimage$3=t.drawimage$2;t.drawimage$4=t.drawimage$2;t.allimages$0=function(){var a=[];Object.keys(Xa).forEach(function(b){a.push({ctype:"string", -value:b})});return g.turnIntoCSList(a)};t.cameravideo$0=function(a,b){function c(a){return{video:{width:a,advanced:[{width:{max:a,min:a}},{width:{ideal:a}}]},audio:!1}}var d=!0,e={};if(void 0!==b.resolution){var f=A(b.resolution);"string"===f.ctype&&"maximal"===f.value?d=!0:"number"===f.ctype?(d=!1,e=c(f.value.real)):g._helper.isNumberVecN(f,2)&&(d=!1,e=c(f.value[0].value.real),f=f.value[1].value.real,10>f||!Number.isInteger(f)?(e.video.aspectRatio=f,e.video.advanced[0].aspectRatio={min:f,max:f}, -e.video.advanced[1].aspectRatio={ideal:f}):(e.video.height=f,e.video.advanced[0].height={min:f,max:f},e.video.advanced[1].height={ideal:f}))}d&&(e=[320,640,1024,1280,1920,2560],e=e.map(function(a){return{width:{min:a}}}),e={video:{width:16E3,height:9E3,advanced:e},audio:!1});var d=null,l=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia;l?d=function(a,c){navigator.mediaDevices.getUserMedia(e).then(a,c)}:(l=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia|| -navigator.msGetUserMedia)&&(d=function(a,c){l.call(navigator,e,a,c)});if(!d)return console.warn("getUserMedia call not supported"),k;var m=document.createElement("video");m.autoplay=!0;f=aa(m,!0);console.log("Opening stream.");d(function(a){a=window.URL.createObjectURL(a);m.src=a;m.addEventListener("loadeddata",I)},function(a){console.error("Could not get user video:",String(a),a)});return f};t.playvideo$1=function(a,b){var c=La(B(a[0]));c.live&&c.img.play&&c.img.play();return k};t.pausevideo$1=function(a, -b){var c=La(B(a[0]));c.live&&c.img.pause&&c.img.pause();return k};var Db;t.imagergba$3=function(a,b){var c=La(B(a[0])),d=B(a[1]),e=B(a[2]);if(!c||"number"!==d.ctype||"number"!==e.ctype||!c.ready)return k;d=Math.round(d.value.real);e=Math.round(e.value.real);if(!Fa(d)||!Fa(e))return k;c=rb(c,d,e,1,1);return g.realVector([255*c[0],255*c[1],255*c[2],c[3]])};t.imagergb$3=t.imagergba$3;t.imagergba$4=function(a,b){var c=La(B(a[2]));if(!c||!c.ready)return k;var d=c.width,e=c.height,f=M(a[0]),l=M(a[1]),m= -M(g.realVector([0,e,1])),d=M(g.realVector([d,e,1]));if(f===k||l===k||n===k)return k;var n=g.ii,e=g.jj,m=D.basismap(m,d,n,e),f=D.basismap(f,l,e,n),n=M(a[3]);var p=D.extractPoint(w.mult(m,w.mult(g.adjoint3(f),n)));if(p.ok){var l=c.width,m=c.height,n=!0,q=!1;void 0!==b.interpolate&&(f=A(b.interpolate),"boolean"===f.ctype&&(n=f.value));void 0!==b.repeat&&(f=A(b.repeat),"boolean"===f.ctype&&(q=f.value));n&&(p.x-=.5,p.y-=.5);q&&(p.x=(p.x%l+l)%l,p.y=(p.y%m+m)%m);d=Math.floor(p.x);e=Math.floor(p.y);if(Fa(d)&& -Fa(e)){f=[0,0,0,0];if(n){var n=p.x-d,p=p.y-e,t=rb(c,d,e,2,2);if(q){if(d===l-1||e===m-1)var q=rb(c,(d+1)%l,e,1,1),u=rb(c,d,(e+1)%m,1,1),c=rb(c,(d+1)%l,(e+1)%m,1,1),t=t.slice(0,4).concat(q,u,c)}else{if(-1===d||d===l-1)n=Math.round(n);if(-1===e||e===m-1)p=Math.round(p)}for(c=0;4>c;c++)f[c]=(1-p)*((1-n)*t[c]+n*t[c+4])+p*((1-n)*t[c+8]+n*t[c+12])}else f=rb(c,d,e,1,1);c=g.realVector(f)}else c=k}else c=k;return c};t.imagergb$4=function(a,b){var c=t.imagergba$4(a,b);return c===k?k:g.turnIntoCSList(c.value.slice(0, -3))};"use strict";var re=[{key:[":"],field:["."],deg:["\u00b0"],take:["_"]},{functionCall:!0},{rassoc:!0,pow:["^"],sqrt:["\u221a"]},{mul:["*","\u2062","\u22c5","\u00b7"],cross:["\u00d7"],div:["/","\u00f7","\u2215","\u2236"]},{add:["+"],sub:["-","\u2212"],neg:["!","\u00ac"]},{seq:[".."]},{eq:["==","\u225f"],ne:["!=","<>","\u2260"],lt:["<"],gt:[">"],le:["<=","\u2264","\u2266"],ge:[">=","\u2265","\u2267"],aeq:["~=","\u2248"],ane:["~!=","\u2249"],alt:["~<","\u2a89"],agt:["~>","\u2a8a"],ale:["~<=","\u2a85"], -age:["~>=","\u2a86"],"in":["\u2208"],nin:["\u2209"]},{and:["&","\u2227"],or:["%","\u2228"]},{rassoc:!0,prepend:["<:"]},{concat:["++","\u222a"],remove:["--","\u2216"],common:["~~","\u2229"],append:[":>"]},{rassoc:!0,assign:["="],define:[":="],undefine:[":=_"],bdefine:["::="]},{seq:[";"]},{modif:["->","\u2192"]},{rassoc:!0,list:[","]}],se=["+","-"],te=["!","\u221a"],ue=["\u00b0",":=_"],ve=[";",","],Cc=[],xa={},cd;(function(){var a=0;re.forEach(function(b){a+=2;var c=!!b.rassoc;b.functionCall&&(cd=a); -for(var d in b){var e=b[d];if("boolean"!==typeof e)for(var f={name:d,sym:e[0],symbols:e,rassoc:c,precedence:a,prefix:!1,postfix:!1,infix:!0,bare:!1},g=0;g<e.length;++g){var l=e[g];if(xa.hasOwnProperty(l))throw Error("Duplicate operator: "+l);xa[l]=f;Cc.push(l)}}});se.forEach(function(a){xa[a].prefix=!0});te.forEach(function(a){xa[a].prefix=!0;xa[a].infix=!1});ue.forEach(function(a){xa[a].postfix=!0;xa[a].infix=!1});ve.forEach(function(a){xa[a].prefix=!0;xa[a].postfix=!0;xa[a].infix=!0;xa[a].bare= -!0})})();Cc.sort(function(a,b){return b.length-a.length});var we="(?:[0-9](?: [0-9])*(?: \\.(?! \\.)(?: [0-9])*)?|\\.(?: [0-9])+)(?: [Ee](?: [+-])?(?: [0-9])+)?".replace(/ /g,"[ \t]*"),xe="(?:[\u207a\u207b] )?[\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079](?: [\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079])*".replace(/ /g,"[ \t]*"),ye="(?:[\u208a\u208b] )?[\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089](?: [\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089])*".replace(/ /g, -"[ \t]*"),Dc=function(a,b,c){var d,e,f=0,g="(?:[",l=b.length;for(d=0;d<l;++d)e=b.charCodeAt(d),55296<=e?(g+="]|"+b.charAt(d)+"[",f=56320):(g+=String.fromCharCode(e=f=a[e-32]+f),f+=a[b.charCodeAt(++d)-32],f!==e&&(f!==e+1&&(g+="-"),g+=String.fromCharCode(f)));return g+"]|["+c+"][\udc00-\udfff])"}([2,0,106,3,4,1,6,5,7,11,17,8,12,21,9,22,30,10,15,24,25,16,13,42,46,14,18,19,29,37,27,28,35,26,32,36,40,43,47,53,20,48,50,56,33,34,39,51,52,55,63,64,65,68,85,23,31,38,45,49,105,59,66,69,72,88,102,114,117,128, -157,191,41,44,54,60,67,70,71,73,74,75,76,80,81,82,83,84,86,87,89,93,94,98,99,107,108,116,122,130,132,134,138,160,165,185,195,196,255,268,277,310,332,339,362,365,390,449,457,470,512,513,541,568,582,619,673,726,768,820,921,991,1164,2684,6581,8453,11171,20949],"T4(4I!)!'!&/ 0 \u0096')2$+! !\u0083$ %## !(! ! ; u \u0086.\u0088 =#!+YoA& 87C% } !5%+%) #!*! <0a,!4B1%'!&-'!1!$!33`HsG$!;!+.52'(#%#- & !$#$!*!9% 2%H''%#- & % % %B# !H *+ - & % $$!;!5%3!,(#%#- & % $$!X% 5!:! '$ #$% ! %$%$ $)W!G( / 2$!> &%C( / . $$!L! %5%;( D#!*!* 4'&*$W + !#&]F %6&]% !#% !#!(# & ! !#% # %1!#$ !/#L!S( @?$\u00817-!*''#$!$%+ ',6!:= !&!#7 \u0090 ##& ! ##D ##B ##& ! ##9 K ##^Y2*V#'$\u009d#5 4&p((+, #2*2*2, 5OC!'!Uy.D !&_)0J<#$,E'4Q/1Pv!|8:&K<9%)E>@7 )@\u0080# #$%1gT\u008e#'#=#'#( ! ! ! 0#P & !$ &$##'',& &d!9!*,b!'!#. !$$(! ! ! # 1##&$'!G%\u00a58 8 \u0084(#$%6= !&!#Q+!*/1& & & & & & & &t!\u0097%E$&%'V( z #&D${:Aj2\u0099\u00a6q\u00a9E\u00a4UZ#\u008d$2)%-8*0#_J+#b#M#(S1 # /0O2[R'$! !6>)/A?+8<!*$ .)$ D3 (-/$!$[ !$%#$#! !4 #1+ 6'#'#'1& & 7 .)c0\u00a86/'I\u00a7\u0093#\\N&6$&! . , $ ! % % \u007fM\u0092;R#Gh)d$ \u0085=4(4,a$'#'#'# \ud800!) 4 : % 9#6@\u0082\u0094?$IIX*5 ((=)<#@'(\ud801!f~N.Of\u008f1-)(\ud802!'#! E %$!#/)/10^: %)-)4nQ(%T!5# AZ?$?C( >?G)-):9*\ud803!`KJ9J\ud804#PriL3>@7M$!6F2#/! !C* 3V& ! # 9 .+8N(#%#- & % $$!;!6$\ud805eF-% !\u008987#=F-!k7x4\ud806\u0087RB!\u0095K\ud808!\u00a2\ud809e\u008a\ud80d!8\ud811!\u009c\ud81a!\u009b+0c<;F*#BH&:\ud81b\u00a0U,!l,\ud82c!%\ud82f!\"&,$++.\ud835!w m %#!#%## ) ! & S ##( & > # $ !$& \u0091#3 3 0 3 0 3 0 3 0 3 (\ud83a!\u008b\ud83b\u0098# A % !#! . # ! !(!'! ! ! % !#! ! ! ! ! % !## & # # ! . 5& $ 5\ud869!\u009f7\u008c\ud86d!\u00a1,g\ud86e!<#\u00a3\ud873!\u009e\ud87e!\u009a", -"\ud80c\ud840-\ud868\ud86a-\ud86c\ud86f-\ud872"),ze=("#(?: [1-9])?|(?:'|"+Dc+")(?: (?:[0-9']|"+Dc+"))*").replace(/ /g,"[ \t]*"),$c=["([ \t\n]+)|(//.*)|(/\\*)","("+we+")","("+Cc.map(Zc).join("|")+")","("+"[](){}||".split("").map(Zc).join("|")+")","("+ye+")","("+xe+")","("+ze+")",'("[^"]*")|($)'].join("|"),Ae=new RegExp("[ \t]*".replace(/\*$/,"+"),"g"),Ec="ANY WS COMMENT START_COMMENT NUM OP BRA SUB SUP ID STR EOF".split(" ");(function(){var a=(new RegExp($c,"g")).exec("");if(a.hasOwnProperty(Ec.length))throw Error("RE has more groups than expected"); -if(!a.hasOwnProperty(Ec.length-1))throw Error("RE has fewer groups than expected");})();kb.prototype.advanceBy=function(a){this.advanceTo(this.pos+a)};kb.prototype.advanceTo=function(a){for(this.pos=a;this.bols[0]<=a;)this.bol=this.bols.shift(),this.line++};kb.prototype.curPos=function(){return{row:this.line,col:this.pos-this.bol,pos:this.pos}};kb.prototype.nextInternal=function(){var a=this.re.exec(this.input);if(a.index!==this.pos)throw ha("Invalid token",this.curPos(),this.input.substring(this.pos, -a.index));var b=this.curPos();this.advanceBy(a[0].length);var c=this.curPos(),d;for(d=1;null==a[d];++d);return{start:b,end:c,raw:a[0],text:a[0].replace(Ae,""),toktype:Ec[d]}};kb.prototype.next=function(){var a;do if(a=this.nextInternal(),"START_COMMENT"===a.toktype){var b=/\*\/|\/\*/g;b.lastIndex=a.start.pos+2;for(var c=1,d;0<c;)if(d=b.exec(this.input))"/*"===d[0]?++c:--c;else throw ha("Unterminated comment",a.start,a.text);this.re.lastIndex=b.lastIndex;this.advanceTo(b.lastIndex);a.end=this.curPos(); -a.raw=this.input.substring(a.start.pos,a.end.pos);a.text=a.raw;a.toktype="COMMENT"}while("WS"===a.toktype||"COMMENT"===a.toktype);return a};var Be={ctype:"void"};Eb.prototype.postprocess=function(a){if(null===a)return Be;if(a){if("infix"===a.ctype)if(":="===a.oper){var b=a.args[0];if("function"===b.ctype)b.args.forEach(function(c){if(null===c||"variable"!==c.ctype)throw ha("Function argument must be an identifier",c.start||a.start);});else if("variable"!==b.ctype)throw ha(a.oper+" can only be used to define functions or variables", -a.start);}else if(","===a.oper)throw ha("comma may only be used to delimit list elements",a.start);a.args&&(a.args=a.args.map(this.postprocess,this));if(a.modifs)for(var c in a.modifs)a.modifs[c]=this.postprocess(a.modifs[c]);if("paren"===a.ctype)return a.args[0];if("infix"===a.ctype){if("."===a.oper){if(!a.args[1]||"variable"!==a.args[1].ctype)throw ha("Field name must be identifier",a.start,a.text);a.ctype="field";a.obj=a.args[0];a.key=a.args[1].name;delete a.args}this.infixmap&&(a.impl=this.infixmap[a.oper])}else"variable"=== -a.ctype?this.usedVariables[a.name]=!0:"function"===a.ctype&&(this.usedFunctions[a.oper]=!0)}if("infix"===a.ctype)return{ctype:"infix",oper:String(a.oper),args:[a.args[0],a.args[1]],impl:a.impl};if("variable"===a.ctype)return{ctype:"variable",name:String(a.name)};if("number"===a.ctype)return{ctype:"number",value:{real:+a.value.real,imag:+a.value.imag}};if("string"===a.ctype)return{ctype:"string",value:String(a.value)};if("list"===a.ctype)return{ctype:"list",value:a.value};if("function"===a.ctype)return{ctype:"function", -oper:String(a.oper),args:a.args,modifs:a.modifs};if("field"===a.ctype)return{ctype:"field",obj:a.obj,key:String(a.key)};throw Error("Unsupported AST node of type "+a.ctype);};Eb.prototype.parse=function(a){try{var b=bd(new kb(a));if("EOF"!==b.closedBy.toktype)throw ha("Closing bracket never opened.",b.closedBy.start,b.closedBy.text);return this.postprocess(b.expr)}catch(c){return c.ctype="error",c}};"undefined"!==typeof process&&"undefined"!==typeof module&&"undefined"!==typeof module.exports&&"undefined"=== -typeof window&&(module.exports.Parser=Eb,module.exports.Tokenizer=kb,module.exports.unicodeLetters=Dc,module.exports.parse=function(a){return(new Eb).parse(a)});var Nc={},Fc;Fc=[0,0,0,0,0,0,0,0,0,0,0,0];t.playsin$1=function(a,b){var c=B(a[0]),d=0;if("number"===c.ctype){var e;void 0!==b.line&&(e=A(b.line),"number"===e.ctype&&(d=Math.floor(e.value.real),0>d&&(d=0),10<d&&(d=10)));c=c.value.real;0!==Fc[d]&&Fc[d].set({freq:c})}return k};var P={printArr:function(a){for(var b=a.value.length,c=[],d=[],e= -!1,f=0;f<b;f++)c[f]=a.value[f].value.real,d[f]=a.value[f].value.imag,0!==d[f]&&(e=!0);console.log(c);e&&console.log(d)},zero:function(a){for(var b=[],c=l.real(0),d=0;d<a.value.real;d++)b[d]=c;return g.turnIntoCSList(b)},number:function(a,b){var c=P.zero(b);c.value[0]=a;return c},variable:function(a,b){var c=P.zero(b);c.value[0]=a;c.value[1]=l.real(1);return c},add:function(a,b){return g.add(a,b)},sub:function(a,b){return g.sub(a,b)},mult:function(a,b){if(a.value.length!==b.value.length)return console.error("dims don't fit return nada"), -k;for(var c=a.value.length,d=P.zero(l.real(c)),e=l.real(0),f=0;f<c;f++){for(var g=0;g<=f;g++)e=l.add(e,l.mult(a.value[g],b.value[f-g]));d.value[f]=e;e=l.real(0)}return d},pow:function(a,b){if(0>b.value.real||b.value.real!==Math.floor(b.value.real))return P.root(a,b);for(var c=a,d=1;d<b.value.real;d++)c=P.mult(c,a);return c},root:function(a,b){var c=l.real(0),d=l.real(1),e=l.add(d,b),f=a.value.length,g=P.zero(l.real(f));g.value[0]=l.pow(a.value[0],b);for(var k=c,m,n,p=1;p<f;p++){n=l.real(p);for(var q= -1;q<=p;q++)m=l.mult(e,l.real(q)),m=l.div(m,n),m=l.sub(m,d),m=l.mult(m,a.value[q]),m=l.mult(m,g.value[p-q]),k=l.add(k,m);k=l.div(k,a.value[0]);g.value[p]=k;k=c}return g},findFirstNoneZero:function(a,b,c){for(var d=Infinity,e=Infinity,f=c;f<a.value.length;f++)if(1E-12<l.abs2(a.value[f]).value.real){d=f;break}for(a=c;a<b.value.length;a++)if(1E-12<l.abs2(b.value[a]).value.real){e=a;break}return[d,e]},div:function(a,b){if(a.value.length!==b.value.length)return console.log("dims don't fit - return nada"), -k;for(var c=a.value.length,d=l.real(0),e=P.zero(l.real(c)),f=d,g,m=0;m<c;m++){g=P.findFirstNoneZero(a,b,m);m<g[0]&&g[0]===g[1]&&Infinity!==g[0]&&(a.value.splice(m,g[0]),b.value.splice(m,g[0]),e.value.splice(m,g[0]),c-=g[0]);g=a.value[m];for(var n=0;n<m;n++)f=l.add(f,l.mult(e.value[n],b.value[m-n]));g=l.sub(g,f);g=l.div(g,b.value[0]);e.value[m]=g;f=d}return e},exp:function(a){var b=l.real(0),c=a.value.length,d=P.zero(l.real(c)),e=b,f;d.value[0]=l.exp(a.value[0]);for(var g=1;g<c;g++){for(var k=1;k<= -g;k++)f=l.mult(l.real(k),a.value[k]),f=l.mult(f,d.value[g-k]),e=l.add(e,f);d.value[g]=l.div(e,l.real(g));e=b}return d},log:function(a){var b=l.real(0),c=a.value.length,d=P.zero(l.real(c));d.value[0]=l.log(a.value[0]);for(var e=b,f,g,k=1;k<c;k++){f=a.value[k];for(var m=1;m<k;m++)g=l.mult(l.real(m),d.value[m]),g=l.mult(g,a.value[k-m]),e=l.add(e,g);e=l.div(e,l.real(k));f=l.sub(f,e);f=l.div(f,a.value[0]);d.value[k]=f;e=b}return d},sincos:function(a){var b=l.real(0),c=a.value.length,d=P.zero(l.real(c)), -e=P.zero(l.real(c));d.value[0]=l.sin(a.value[0]);e.value[0]=l.cos(a.value[0]);for(var f=b,g=b,k,m,n,p=1;p<c;p++){n=l.real(p);for(var q=1;q<=p;q++)m=l.mult(l.real(q),a.value[q]),k=l.mult(m,e.value[p-q]),m=l.mult(m,d.value[p-q]),g=l.add(g,k),f=l.add(f,m);g=l.div(g,n);f=l.div(f,l.neg(n));d.value[p]=g;e.value[p]=f;f=g=b}P.sinsave=d;P.cossave=e;return[d,e]},sin:function(a){return P.sincos(a)[0]},cos:function(a){return P.sincos(a)[1]},faculty:function(a){var b=[];b[0]=l.real(1);for(var c=1,d=1;d<=a.value.real;d++)c*= -d,b[d]=l.real(c);return b=g.turnIntoCSList(b)},diff:function(a,b,c,d){var e;if("variable"===a.ctype)e=a.name!==b?P.number(A(a),d):P.variable(c,d);else if("number"===a.ctype)e=P.number(a,d);else{if("infix"===a.ctype){if("*"===a.oper)return P.mult(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d));if("^"===a.oper)return P.pow(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d).value[0]);if("/"===a.oper)return P.div(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d));if("+"===a.oper)return P.add(P.diff(a.args[0], -b,c,d),P.diff(a.args[1],b,c,d));if("-"===a.oper)return P.sub(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d));console.log("infix not found",a.oper);return k}if("function"===a.ctype){if("exp$1"===a.oper)return P.exp(P.diff(a.args[0],b,c,d));if("log$1"===a.oper)return P.log(P.diff(a.args[0],b,c,d));if("sin$1"===a.oper)return P.sin(P.diff(a.args[0],b,c,d));if("cos$1"===a.oper)return P.cos(P.diff(a.args[0],b,c,d))}else return console.log("ctype not found",a.ctype),k}return e},adevaluate:function(a,b, -c,d){a=P.diff(a,b,c,d);d=P.faculty(d);for(b=2;b<a.value.length;b++)a.value[b]=l.mult(a.value[b],d.value[b]);return a},autodiff:function(a,b,c,d){for(var e=[],f=c.value.length,l,k=0;k<f;k++)l=P.adevaluate(a,b,c.value[k],d),e[k]=l;return e=g.turnIntoCSList(e)}},x={handleModifs:function(a,b){x.dashing&&x.unSetDash();x.colorraw=null;x.fillcolorraw=null;x.fillrule="nonzero";x.size=null;0>=x.psize&&(x.psize=0);0>=x.lsize&&(x.lsize=0);x.overhang=1;x.dashing=!1;x.isArrow=!1;x.arrowSides="==>";x.arrowposition= -1;x.headlen=10;x.arrowShape=x.arrowShapes.line;x.alpha=z.drawingstate.alpha;x.fillalpha=0;x.bold="";x.italics="";x.family="sans-serif";x.align=0;x.xOffset=0;x.yOffset=0;x.lineCap="round";x.lineJoin="round";x.miterLimit=10;var c,d;for(c in a){var e=a[c];e&&((d=b[c])?(!0===d&&(d=x.modifHandlers[c]),d(A(e))):console.log("Modifier not supported: "+c))}null!==x.size?x.psize=x.lsize=x.size:(x.psize=z.drawingstate.pointsize,x.lsize=z.drawingstate.linesize);x.dashing&&x.dashing(x.lsize);null!==x.colorraw? -x.pointColor=x.lineColor=x.textColor=x.makeColor(x.colorraw):1===x.alpha?(x.pointColor=z.drawingstate.pointcolor,x.lineColor=z.drawingstate.linecolor,x.textColor=z.drawingstate.textcolor):(x.pointColor=x.makeColor(z.drawingstate.pointcolorraw),x.lineColor=x.makeColor(z.drawingstate.linecolorraw),x.textColor=x.makeColor(z.drawingstate.textcolorraw));x.black=1===x.alpha?"rgb(0,0,0)":"rgba(0,0,0,"+x.alpha+")";x.fillColor=x.fillcolorraw&&0<x.fillalpha?x.makeColor(x.fillcolorraw,x.fillalpha):null},modifHandlers:{size:function(a){"number"=== -a.ctype&&(x.size=a.value.real,0>x.size&&(x.size=0),1E3<x.size&&(x.size=1E3))},color:function(a){g.isNumberVector(a).value&&3===a.value.length&&(x.colorraw=[a.value[0].value.real,a.value[1].value.real,a.value[2].value.real])},fillcolor:function(a){g.isNumberVector(a).value&&3===a.value.length&&(x.fillcolorraw=[a.value[0].value.real,a.value[1].value.real,a.value[2].value.real])},alpha:function(a){"number"===a.ctype&&(x.alpha=a.value.real)},fillalpha:function(a){"number"===a.ctype&&(x.fillalpha=a.value.real)}, -dashpattern:function(a){if("list"===a.ctype){for(var b=[],c=0,d=0;c<a.value.length;c++)"number"===a.value[c].ctype&&(b[d++]=a.value[c].value.real);x.dashing=x.setDash.bind(null,b)}},dashtype:function(a){if("number"===a.ctype)a=Math.floor(a.value.real);else if("string"===a.ctype)a=a.value;else return;if(a=x.dashTypes[a])x.dashing=x.setDash.bind(null,a)},dashing:function(a){"number"===a.ctype&&(a=Math.floor(a.value.real),x.dashing=x.setDash.bind(null,[2*a,a]))},overhang:function(a){"number"===a.ctype&& -(x.overhang=x.overhang*a.value.real+(1-x.overhang)*(1-a.value.real))},arrow:function(a){"boolean"===a.ctype?x.isArrow=a.value:console.error("arrow needs to be of type boolean")},arrowshape:function(a){"string"!==a.ctype?console.error("arrowshape needs to be of type string"):x.arrowShapes.hasOwnProperty(a.value)?(x.arrowShape=x.arrowShapes[a.value],x.isArrow=!0,x.arrowShape.deprecated&&(console.log("arrowshape "+a.value+" is deprecated, use "+x.arrowShape.deprecated+" instead."),x.arrowShape.deprecated= -null)):(a=Object.keys(x.arrowShapes),a.sort(),a=a.join(", "),console.error("arrowshape needs to be one of "+a))},arrowsides:function(a){"string"!==a.ctype?console.error("arrowsides is not of type string"):"==>"!==a.value&&"<==>"!==a.value&&"<=="!==a.value?console.error("arrowsides is unknows"):(x.arrowSides=a.value,x.isArrow=!0)},arrowposition:function(a){"number"!==a.ctype?console.error("arrowposition is not of type number"):0>a.value.real?console.error("arrowposition has to be positive"):1<a.value.real? -x.overhang=x.overhang*a.value.real+(1-x.overhang)*(1-a.value.real):(x.arrowposition=a.value.real,x.isArrow=!0)},arrowsize:function(a){"number"!==a.ctype?console.error("arrowsize is not of type number"):0>a.value.real?console.error("arrowsize has to be positive"):x.headlen*=a.value.real},bold:function(a){"boolean"===a.ctype&&a.value&&(x.bold="bold ")},italics:function(a){"boolean"===a.ctype&&a.value&&(x.italics="italic ")},family:function(a){"string"===a.ctype&&(x.family=a.value)},align:function(a){"string"=== -a.ctype&&(a=a.value,"left"===a&&(x.align=0),"right"===a&&(x.align=1),"mid"===a&&(x.align=.5))},x_offset:function(a){"number"===a.ctype&&(x.xOffset=a.value.real)},y_offset:function(a){"number"===a.ctype&&(x.yOffset=a.value.real)},offset:function(a){"list"===a.ctype&&2===a.value.length&&"number"===a.value[0].ctype&&"number"===a.value[1].ctype&&(x.xOffset=a.value[0].value.real,x.yOffset=a.value[1].value.real)},lineCap:function(a){"string"!==a.ctype||"round"!==a.value&&"square"!==a.value&&"butt"!==a.value|| -(x.lineCap=a.value)},lineJoin:function(a){"string"!==a.ctype||"round"!==a.value&&"bevel"!==a.value&&"miter"!==a.value||(x.lineJoin=a.value)},fillrule:function(a){"string"!==a.ctype||"nonzero"!==a.value&&"evenodd"!==a.value||(x.fillrule=a.value)},miterLimit:function(a){"number"===a.ctype&&0<a.value.real&&(x.miterLimit=Math.round(a.value.real))}},lineModifs:{size:!0,color:!0,alpha:!0,dashpattern:!0,dashtype:!0,dashing:!0,overhang:!0,arrow:!0,arrowshape:!0,arrowsides:!0,arrowposition:!0,arrowsize:!0, -lineCap:!0,lineJoin:!0,miterLimit:!0},pointModifs:{size:!0,color:!0,alpha:!0}};x.pointAndLineModifs=x.lineModifs;x.conicModifs={size:!0,color:!0,alpha:!0,fillcolor:!0,fillrule:!0,fillalpha:!0,lineCap:!0,lineJoin:!0,miterLimit:!0};x.textModifs={size:!0,color:!0,alpha:!0,bold:!0,italics:!0,family:!0,align:!0,x_offset:!0,y_offset:!0,offset:!0};x.makeColor=function(a,b){void 0===b&&(b=x.alpha);return"rgba("+Math.floor(255*a[0])+","+Math.floor(255*a[1])+","+Math.floor(255*a[2])+","+b+")"};x.preDrawCurve= -function(){y.lineWidth=x.lsize;y.lineCap=x.lineCap;y.lineJoin=x.lineJoin;y.mozFillRule=x.fillrule;y.fillrule=x.fillrule;y.miterLimit=x.miterLimit;y.strokeStyle=x.lineColor};x.arrowShapes={"default":{close:!1,fill:!1,ratio:1,deprecated:"line"},line:{close:!1,fill:!1,ratio:1},empty:{close:!0,fill:!1,ratio:1},hollow:{close:!0,fill:!1,ratio:1,deprecated:"empty"},full:{close:!0,fill:!0,ratio:1},jet:{close:!0,fill:!0,ratio:1.5},delta:{close:!0,fill:!0,ratio:1.5,deprecated:"jet"}};x.clipSegment=function(a, -b){var c=b.x-a.x,d=b.y-a.y,e=x.clipLineCore(-d,c,a.x*b.y-b.x*a.y);if(2!==e.length)return[];var f=e[0],e=e[1],g=1/(c*c+d*d),l=((f.x-a.x)*c+(f.y-a.y)*d)*g,c=((e.x-a.x)*c+(e.y-a.y)*d)*g;0>l&&(f=a);1<l&&(f=b);0>c&&(e=a);1<c&&(e=b);return f===e?[]:[f,e]};x.drawsegcore=function(a,b){function c(a,b,c,h){var d=a-h*q+.5*t,e=b-h*t-.5*q,f=a-h*q-.5*t;h=b-h*t+.5*q;y.beginPath();x.arrowShape.fill&&(y.lineWidth=x.lsize/2);y.moveTo(d,e);y.lineTo(a,b);y.lineTo(f,h);x.arrowShape.close&&(y.fillStyle=x.lineColor,y.lineTo(a- -c*q,b-c*t),y.closePath(),x.arrowShape.fill&&y.fill());y.stroke()}var d=z.drawingstate.matrix,e=a.x*d.a-a.y*d.b+d.tx,f=a.x*d.c-a.y*d.d-d.ty,g=b.x*d.a-b.y*d.b+d.tx,l=b.x*d.c-b.y*d.d-d.ty,k=x.overhang,m=1-k,d=k*e+m*g,n=k*f+m*l,p=k*g+m*e,k=k*l+m*f;if(0>d||d>da||0>n||n>ca||0>p||p>da||0>k||k>ca){k=x.clipSegment({x:d,y:n},{x:p,y:k});if(2!==k.length||.01>x.lsize)return;d=k[0].x;n=k[0].y;p=k[1].x;k=k[1].y}x.preDrawCurve();if(!x.isArrow||e===f&&g===l).01>x.lsize||(y.beginPath(),y.moveTo(d,n),y.lineTo(p,k), -y.stroke());else{var e=g-e,f=l-f,g=x.headlen/Math.sqrt(e*e+f*f),q=e*g,t=f*g,l=x.arrowposition,m=1-l,f=l*d+m*p,e=l*n+m*k,g=l*p+m*d,l=l*k+m*n,m=x.arrowSides;y.beginPath();x.arrowShape.close?("<==>"===m||"<=="===m?(1>x.arrowposition&&(y.moveTo(d,n),y.lineTo(f,e)),y.moveTo(f+q,e+t)):y.moveTo(d,n),"==>"===m||"<==>"===m?(y.lineTo(g-q,l-t),1>x.arrowposition&&(y.moveTo(g,l),y.lineTo(p,k))):y.lineTo(p,k)):(y.moveTo(d,n),y.lineTo(p,k));y.stroke();"==>"!==m&&"<==>"!==m||c(g,l,1,x.arrowShape.ratio);"<=="!==m&& -"<==>"!==m||c(f,e,-1,-x.arrowShape.ratio)}};x.drawpoint=function(a){var b=z.drawingstate.matrix,c=a.x*b.a-a.y*b.b+b.tx;a=a.x*b.c-a.y*b.d-b.ty;y.lineWidth=.3*x.psize;y.beginPath();y.arc(c,a,x.psize,0,2*Math.PI);y.fillStyle=x.pointColor;y.fill();y.beginPath();y.arc(c,a,1.15*x.psize,0,2*Math.PI);y.fillStyle=x.black;y.strokeStyle=x.black;y.stroke()};x.clipLineCore=function(a,b,c){var d=Math.SQRT1_2*x.lsize,e=0-d,f=da+d,g=0-d,d=ca+d,l=0>e*a+g*b+c,k=0>f*a+g*b+c,m=0>e*a+d*b+c,n=0>f*a+d*b+c,p=[];l!==k&&p.push({x:(-c- -b*g)/a,y:g});k!==n&&p.push({x:f,y:(-c-a*f)/b});m!==n&&p.push({x:(-c-b*d)/a,y:d});l!==m&&p.push({x:e,y:(-c-a*e)/b});return p};x.clipLine=function(a){a=g.normalizeMax(g.productVM(a,z.toMat()));return x.clipLineCore(a.value[0].value.real,a.value[1].value.real,a.value[2].value.real)};x.drawline=function(a){g._helper.isAlmostReal(a)&&(a=x.clipLine(a),2===a.length&&.01<=x.lsize&&(x.preDrawCurve(),y.beginPath(),y.moveTo(a[0].x,a[0].y),y.lineTo(a[1].x,a[1].y),y.stroke()))};x.drawRaySegment=function(a,b){var c= -D.extractPoint(a),d=D.extractPoint(b);if(c.ok&&d.ok){var e=c.x-d.x,f=c.y-d.y,g=25E3/z.drawingstate.matrix.sdet/Math.sqrt(e*e+f*f),e=e*g,f=f*g;x.drawsegcore(c,{x:c.x+e,y:c.y+f});x.drawsegcore(d,{x:d.x-e,y:d.y-f})}};x.dashTypes={solid:[],dashed:[10,10],tightdash:[10,4],dotted:[1,3],dashdot:[10,5,1,5],"dashvalue.solid":[],"dashvalue.dashed":[10,10],"dashvalue.tightdash":[10,4],"dashvalue.dotted":[1,3],"dashvalue.dashdot":[10,5,1,5],0:[],1:[10,10],2:[10,4],3:[1,3],4:[10,5,1,5]};x.setDash=function(a,b){var c= -Math.sqrt(b);a=a.slice();for(var d=0;d<a.length;d++)a[d]*=c;y.webkitLineDash=a;y.setLineDash(a);y.mozDash=a};x.unSetDash=function(){y.webkitLineDash=[];y.setLineDash([]);y.mozDash=[]};dd.prototype={set fillStyle(a){var b=this;Rb(a,function(a,d,e,f){b._fill="#"+lb(a.toString(16),2)+lb(d.toString(16),2)+lb(e.toString(16),2);b._fillOpacity=255===f?null:f})},set strokeStyle(a){var b=this;Rb(a,function(a,d,e,f){b._stroke="#"+lb(a.toString(16),2)+lb(d.toString(16),2)+lb(e.toString(16),2);b._strokeOpacity= -255===f?null:f})},clearRect:function(){},beginPath:function(){this._path=[]},_pathcmd:function(){this._path.push.apply(this._path,arguments)},closePath:function(){this._pathcmd("Z")},moveTo:function(a,b){this._pathcmd("M",a,b)},lineTo:function(a,b){this._pathcmd("L",a,b)},bezierCurveTo:function(a,b,c,d,e,f){this._pathcmd("C",a,b,c,d,e,f)},quadraticCurveTo:function(a,b,c,d){this._pathcmd("Q",a,b,c,d)},arc:function(a,b,c,d,e,f){var g=c*Math.cos(d)+a,l=c*Math.sin(d)+b,k=c*Math.cos(e)+a,m=c*Math.sin(e)+ -b;e=f?d-e:e-d;e>=2*Math.PI?this._pathcmd(this._path.length?"L":"M",g,l,"A",c,c,0,0,f?1:0,a-c*Math.cos(d),b-c*Math.sin(d),"A",c,c,0,0,f?1:0,g,l):this._pathcmd(this._path.length?"L":"M",g,l,"A",c,c,0,e>Math.PI?1:0,f?1:0,k,m)},rect:function(a,b,c,d){this._pathcmd("M",a,b,"h",c,"v",d,"h",-c,"z")},_cmd:function(a){1!==this.globalAlpha?(this._body.push('<g opacity="'+this.globalAlpha+'">'),this._body.push(a),this._body.push("</g>")):this._body.push(a)},_attrs:function(a){var b="",c;for(c in a)null!==a[c]&& -(b+=" "+c+'="'+a[c]+'"');return b},fill:function(){this._cmd("<path"+this._attrs({d:this._path.join(" "),fill:this._fill,"fill-opacity":this._fillOpacity})+"/>")},stroke:function(){this._cmd("<path"+this._attrs({d:this._path.join(" "),stroke:this._stroke,"stroke-opacity":this._strokeOpacity,"stroke-width":this.lineWidth,"stroke-linecap":this.lineCap,"stroke-linejoin":this.lineJoin,"stroke-miterlimit":"miter"===this.lineJoin?this.miterLimit:null})+"/>")},clip:function(){++this._clipIndex;this._body.push('<clipPath id="clip'+ -this._clipIndex+'"><path d="'+this._path.join(" ")+'"/></clipPath>','<g clip-path="url(#clip'+this._clipIndex+')">');this._saveStack[this._saveStack.length-1]+="</g>"},save:function(){this._saveStack.push("")},restore:function(){this._body.push(this._saveStack.pop());0===this._saveStack.length&&this._saveStack.push("")},_transform:function(a){this._body.push('<g transform="'+a+'">');this._saveStack[this._saveStack.length-1]+="</g>"},translate:function(a,b){this._transform("translate("+a+" "+b+")")}, -rotate:function(a){this._transform("rotate("+Math.PI/180*a+")")},scale:function(a,b){this._transform("scale("+a+" "+b+")")},transform:function(a,b,c,d,e,f){this._transform("matrix("+[a,b,c,d,e,f].join(" ")+")")},drawImage:function(a,b,c){if(3!==arguments.length)throw Error("SvgWriterContext only supports 3-argument version of drawImage");var d=this._imgcache.indexOf(a);if(-1===d){var d=this._imgcache.length,e;e=a.cachedDataURL?a.cachedDataURL:fd(a);this._defs.push('<image id="img'+d+'" x="0" y="0" width="'+ -a.width+'" height="'+a.height+'" xlink:href="'+e+'"/>');this._imgcache.push(a)}this._cmd('<use x="'+b+'" y="'+c+'" xlink:href="#img'+d+'"/>')},toBlob:function(){for(;1<this._saveStack.length||""!==this._saveStack[0];)this.restore();var a='<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="'+this.width+'px" height="'+this.height+'px">\n'+this._defs.join("\n")+'\n</defs>\n<g stroke="none" fill="none">\n'+ -this._body.join("\n")+"\n</g>\n</svg>\n";return new Blob([a],{type:"image/svg+xml"})}};ed.prototype={_cmd:function(){this._body.push(Array.prototype.join.call(arguments," "))},_setAlpha:function(a,b,c){var d=Math.round(255*a*this._globalAlpha);b+=d;this._extGState[b]="<< /"+c+" "+d/255+" >>";this._cmd("/"+b,"gs");return a},set globalAlpha(a){this._globalAlpha=a;this._setAlpha(this._strokeAlpha,"As","CA");this._setAlpha(this._fillAlpha,"Af","ca")},set fillStyle(a){var b=this;Rb(a,function(a,d,e,f){b._cmd(a/ -255,d/255,e/255,"rg");b._setAlpha(b._fillAlpha=f,"Af","ca")})},set strokeStyle(a){var b=this;Rb(a,function(a,d,e,f){b._cmd(a/255,d/255,e/255,"RG");b._setAlpha(b._strokeAlpha=f,"As","CA")})},set lineWidth(a){this._cmd(a,"w")},set lineCap(a){this._cmd({butt:0,round:1,square:2}[a],"J")},set lineJoin(a){this._cmd({miter:0,round:1,bevel:2}[a],"j")},set miterLimit(a){this._cmd(a,"M")},clearRect:function(){},beginPath:function(){this._pathUsed=!1},closePath:function(){this._cmd("h")},moveTo:function(a,b){this._cmd(this._xPos= -a,this._yPos=-b,"m")},lineTo:function(a,b){this._cmd(this._xPos=a,this._yPos=-b,"l")},bezierCurveTo:function(a,b,c,d,e,f){this._cmd(a,-b,c,-d,this._xPos=e,this._yPos=-f,"c")},quadraticCurveTo:function(a,b,c,d){this.bezierCurveTo((2*a+this._xPos)/3,(2*b-this._yPos)/3,(c+2*a)/3,(d+2*b)/3,c,d)},_kappa:.5522847498307935,arc:function(a,b,c,d,e,f){if(0===d&&e===2*Math.PI)d=this._kappa*c,this.moveTo(a+c,b),this.bezierCurveTo(a+c,b+d,a+d,b+c,a,b+c),this.bezierCurveTo(a-d,b+c,a-c,b+d,a-c,b),this.bezierCurveTo(a- -c,b-d,a-d,b-c,a,b-c),this.bezierCurveTo(a+d,b-c,a+c,b-d,a+c,b);else throw Error("PdfWriterContext.arc only supports full circles");},rect:function(a,b,c,d){this._cmd(a,-b,c,-d,"re")},_usePath:function(a){if(this._pathUsed){var b=this._body[this._pathUsed],c={"S + f":"B","f + S":"B","W n + S":"W S","W n + f":"W f","S + W n":"W S","f + W n":"W f","B + W n":"W B","W S + f":"W B","W f + S":"W B"}[b+" + "+a];if(!c)throw Error("Don't know how to combine '"+b+"' and '"+a+"'");this._body.splice(this._pathUsed, -1);a=c}this._pathUsed=this._body.length;this._cmd(a)},fill:function(){this._usePath("f")},stroke:function(){this._usePath("S")},clip:function(){this._usePath("W n")},save:function(){this._cmd("q")},restore:function(){this._cmd("Q")},translate:function(a,b){this.transform(1,0,0,1,a,b)},rotate:function(a){var b=Math.cos(a);a=Math.sin(a);this.transform(b,a,-a,b,0,0)},scale:function(a,b){this.transform(a,0,0,b,0,0)},transform:function(a,b,c,d,e,f){this._cmd(a,-b,-c,d,e,-f,"cm")},_png:function(a){if("data:image/png;base64,"!== -a.substr(0,22))return{error:"Not a base64-encoded PNG file"};a=Wd(a.substr(22));var b=Xd(a);console.log("PNG chunks:",b.map(function(a){return a.type}));if("IHDR"!==b[0].type)throw Error("Image does not start with an IHDR");var c=b[0].data;a=(c[0]<<24|c[1]<<16|c[2]<<8|c[3])>>>0;var d=(c[4]<<24|c[5]<<16|c[6]<<8|c[7])>>>0,e=c[8],f=c[9],g=0===(f&2),l=0!==(f&4),k=c[10],m=c[11],c=c[12];if(0!==k)throw Error("Unsupported PNG compression method: "+k);if(0!==m)throw Error("Unsupported PNG filter method: "+ -m);if(0!==c)return{error:"Interlaced image not supported"};if(0!==(f&1))return{error:"Indexed PNG image not supported"};m=null;f=g?1:3;k=b.filter(function(a){return"IDAT"===a.type}).map(function(a){return a.data});if(l){l=window.pako;m=new l.Inflate;for(b=0;b<k.length;++b)m.push(k[b],b+1===k.length);if(m.err)throw Error(m.err);m=m.result;c=e>>>3;if(m.length!==d*(a*(f+1)*c+1))throw Error("Data length mismatch");for(var n=f*c,k=new Uint8Array(d*(a*n+1)),p=new Uint8Array(d*(a*c+1)),q=0,t=0,u=0,v=0;v< -d;++v){k[t++]=p[u++]=m[q++];for(var w=0;w<a;++w){for(b=0;b<n;++b)k[t++]=m[q++];for(b=0;b<c;++b)p[u++]=m[q++]}}if(q!==m.length||t!==k.length||u!==p.length)throw Error("Seems we garbled our index computation somehow");p=l.deflate(p);m=this._strm({Type:"/XObject",Subtype:"/Image",Width:a,Height:d,ColorSpace:"/DeviceGray",BitsPerComponent:e,Filter:"/FlateDecode",DecodeParms:this._dict({Predictor:15,Colors:1,BitsPerComponent:e,Columns:a})},p).ref;k=[l.deflate(k)]}var x=0;k.forEach(function(a){x+=a.length}); -return this._obj([this._dict({Type:"/XObject",Subtype:"/Image",Name:"/img"+this._imgcache.length,Width:a,Height:d,ColorSpace:g?"/DeviceGray":"/DeviceRGB",SMask:m,BitsPerComponent:e,Length:x,Filter:"/FlateDecode",DecodeParms:this._dict({Predictor:15,Colors:f,BitsPerComponent:e,Columns:a})}),"\nstream\n"].concat(k,["\nendstream"]))},drawImage:function(a,b,c){if(3!==arguments.length)throw Error("PdfWriterContext only supports 3-argument version of drawImage");var d=this._imgcache.indexOf(a);if(-1=== -d){d=this._imgcache.length;this._imgcache.push(a);var e=this._png(a.cachedDataURL||"");e.hasOwnProperty("error")&&(e=this._png(fd(a)));if(e.hasOwnProperty("error"))throw Error(e.error);this._xobjects["img"+d]=e.ref}this._cmd("q");this._setAlpha(1,"Af","ca");this._cmd(a.width,0,0,a.height,b,-c-a.height,"cm");this._cmd("/img"+d,"Do");this._cmd("Q")},_dict:function(a){var b="<<",c;for(c in a)b+=" /"+c+" "+a[c];return b+" >>"},_obj:function(a,b){b||(b=this._nextIndex++);Array.isArray(a)||(a=[this._dict(a)]); -a.index=b;a.ref=b+" 0 R";a.offset=this._offset;var c=0;a.unshift(b+" 0 obj\n");a.push("\nendobj\n");for(var d=0;d<a.length;++d)c+=a[d].length;this._offset+=c;this._objects.push(a);return a},_strm:function(a,b,c){a.Length=b.length;return this._obj([this._dict(a),"\nstream\n",b,"\nendstream"],c)},toBlob:function(){var a;a="["+[0,-this.height,this.width,0].join(" ")+"]";this._obj({Type:"/Catalog",Pages:"2 0 R"},1);this._obj({Type:"/Pages",Kids:"[3 0 R]",Count:1},2);this._obj({Type:"/Page",Parent:"2 0 R", -MediaBox:a,Contents:"4 0 R",Resources:this._dict({ProcSet:"[/PDF /Text /ImageB /ImageC /ImageI]",XObject:this._dict(this._xobjects),ExtGState:this._dict(this._extGState)})},3);var b=this._body.join("\n"),c=new Uint8Array(b.length);for(a=0;a<b.length;++a)c[a]=b.charCodeAt(a)&255;b=window.pako.deflate(c);this._strm({Filter:"/FlateDecode"},b,4);var b=this._objects,d=[];for(a=1;a<b.length;++a)d[b[a].index]=b[a];c="xref\n0 "+d.length+"\n";for(a=0;a<d.length;++a)c=d[a]?c+(lb(String(d[a].offset),10)+" 00000 n \n"): -c+"0000000000 65535 f \n";a="trailer\n"+this._dict({Size:d.length,Root:"1 0 R"})+"\nstartxref\n"+this._offset+"\n%%EOF\n";b=Array.prototype.concat.apply([],b);b.push(c,a);return new Blob(b,{type:"application/pdf"})}};var Fb=null;jb.push(gd);oa.exportSVG=function(){hd(dd)};oa.exportPDF=function(){wa.loadScript("pako","pako.min.js",function(){hd(ed)})};oa.exportPNG=function(){id(y.canvas.toDataURL())};var id=function(a){var b=document.createElement("a");document.body.appendChild(b);b.style="display: none"; -b.href=a;b.download="CindyJSExport";b.click();setTimeout(function(){document.body.removeChild(b);gd()},100)},qc="Move",Hb,ua=[],Ua=0,Zd=0,sb=0,G={Delete:{}};G.Delete.actions=[];G.Delete.actions[0]={};G.Delete.actions[0].event="mousedown";G.Delete.actions[0].tooltip="...";G.Delete.actions[0]["do"]=function(){fa=Gb(X);null!==fa&&nd(fa.mover.name);return!0};G.Move={};G.Move.actions=[];G.Move.actions[0]={};G.Move.actions[0].event="mousedown";G.Move.actions[0].tooltip="Move free elements by dragging the mouse"; -G.Move.actions[0]["do"]=function(){for(var a=X,b=null,c=1E6,d,e=0;e<u.free.length;e++){var f=u.free[e];if(!f.pinned&&!1!==f.visible&&!0!==f.tmp){var k,m,n,p=z.drawingstate.matrix.sdet;if("P"===f.kind){m=g.normalizeZ(f.homog);if(!g._helper.isAlmostReal(m))continue;k=m.value[0].value.real-a.x;m=m.value[1].value.real-a.y;n=Math.sqrt(k*k+m*m);if(f.narrow&&n>("number"===typeof f.narrow?f.narrow:20)/p)continue}else if("C"===f.kind)m=u.csnames[f.args[0]],n=f.radius,k=l.div(m.homog.value[0],m.homog.value[2]).value.real, -m=l.div(m.homog.value[1],m.homog.value[2]).value.real,k-=a.x,m-=a.y,n=Math.sqrt(k*k+m*m)-n.value.real,m=k=0,0>n&&(n=-n),n+=30/p;else if("L"===f.kind)k=f.homog,n=l,m=n.add(n.mult(k.value[0],n.conjugate(k.value[0])),n.mult(k.value[1],n.conjugate(k.value[1]))),m=g.scaldiv(n.sqrt(m),k),n=m.value[0].value.real*a.x+m.value[1].value.real*a.y+m.value[2].value.real,k=-m.value[0].value.real*n,m=-m.value[1].value.real*n,0>n&&(n=-n),n+=25/p;else if("Text"===f.kind){if(!f.homog||f.dock||!f._bbox)continue;m=z.from(a.x, -a.y,1);k=Math.max(0,m[0]-f._bbox.right,f._bbox.left-m[0]);m=Math.max(0,m[1]-f._bbox.bottom,f._bbox.top-m[1]);n=Math.sqrt(k*k+m*m);if(20<n)continue;n/=p;m=g.normalizeZ(f.homog);if(!g._helper.isAlmostReal(m))continue;k=m.value[0].value.real-a.x;m=m.value[1].value.real-a.y}else continue;n<c+.2/p&&(c=n,b=f,d={x:k,y:m})}}console.log("Moving "+(b?b.name:"nothing"));fa=null===b?null:{mover:b,offset:d,prev:{x:a.x,y:a.y}};return!0};G.Point={};G.Point.actions=[];G.Point.actions[0]={};G.Point.actions[0].event= -"mousedown";G.Point.actions[0].tooltip="Add a single point with the mouse";G.Point.actions[0]["do"]=function(){Ha({type:"Free",name:Ta(),labeled:!0,pos:[ta[0],ta[1],1]});return!0};G.Mid={};G.Mid.actions=[];G.Mid.actions[0]={};G.Mid.actions[0].event="mousedown";G.Mid.actions[0].tooltip="Construct two points and their midpoint by dragging";G.Mid.actions[0]["do"]=function(){mb();return!0};G.Mid.actions[1]={};G.Mid.actions[1].event="mousemove";G.Mid.actions[1]["do"]=function(){Sb("Mid");return!0};G.Mid.actions[2]= -{};G.Mid.actions[2].event="mouseup";G.Mid.actions[2]["do"]=function(){tb();return!0};G.Circle={};G.Circle.actions=[];G.Circle.actions[0]={};G.Circle.actions[0].event="mousedown";G.Circle.actions[0].tooltip="Construct two points and a circle by dragging the mouse";G.Circle.actions[0]["do"]=function(){mb();return!0};G.Circle.actions[1]={};G.Circle.actions[1].event="mousemove";G.Circle.actions[1]["do"]=function(){Sb("CircleMP");return!0};G.Circle.actions[2]={};G.Circle.actions[2].event="mouseup";G.Circle.actions[2]["do"]= -function(){tb();return!0};G.Compass={};G.Compass.actions=[];G.Compass.actions[0]={};G.Compass.actions[0].event="mousedown";G.Compass.actions[0].tooltip="...";G.Compass.actions[0]["do"]=function(){mb();return!0};G.Compass.actions[1]={};G.Compass.actions[1].event="mousedown";G.Compass.actions[1].tooltip="...";G.Compass.actions[1]["do"]=function(){mb();return!0};G.Compass.actions[2]={};G.Compass.actions[2].event="mousedown";G.Compass.actions[2].tooltip="...";G.Compass.actions[2]["do"]=function(){mb(); -Ha({type:"Compass",name:Ta(),labeled:!0,args:[ua[0].name,ua[1].name,ua[2].name]});return!0};G.Line={};G.Line.actions=[];G.Line.actions[0]={};G.Line.actions[0].event="mousedown";G.Line.actions[0].tooltip="Construct two points and their connecting line by dragging the mouse";G.Line.actions[0]["do"]=function(){mb();return!0};G.Line.actions[1]={};G.Line.actions[1].event="mousemove";G.Line.actions[1]["do"]=function(){Sb("Join");return!0};G.Line.actions[2]={};G.Line.actions[2].event="mouseup";G.Line.actions[2]["do"]= -function(){tb();return!0};G.Segment={};G.Segment.actions=[];G.Segment.actions[0]={};G.Segment.actions[0].event="mousedown";G.Segment.actions[0].tooltip="Draw a segment by dragging the mouse";G.Segment.actions[0]["do"]=function(){mb();return!0};G.Segment.actions[1]={};G.Segment.actions[1].event="mousemove";G.Segment.actions[1]["do"]=function(){Sb("Segment");return!0};G.Segment.actions[2]={};G.Segment.actions[2].event="mouseup";G.Segment.actions[2]["do"]=function(){tb();return!0};G.Parallel={};G.Parallel.actions= -[];G.Parallel.actions[0]={};G.Parallel.actions[0].event="mousedown";G.Parallel.actions[0].tooltip="Construct a parallel line by dragging a line";G.Parallel.actions[0]["do"]=function(){return ld()};G.Parallel.actions[1]={};G.Parallel.actions[1].event="mousemove";G.Parallel.actions[1]["do"]=function(){var a={type:"Free",name:Ta(),labeled:!0,pos:[ta[0],ta[1],1],tmp:!0},a=Ha(a);Hb=Ha({type:"Para",name:Ta(),labeled:!0,args:[ua[0].name,a.name]});sc(a);return!0};G.Parallel.actions[2]={};G.Parallel.actions[2].event= -"mouseup";G.Parallel.actions[2]["do"]=function(){tb();return!0};G.Orthogonal={};G.Orthogonal.actions=[];G.Orthogonal.actions[0]={};G.Orthogonal.actions[0].event="mousedown";G.Orthogonal.actions[0].tooltip="Construct a orthogonal line by dragging a line";G.Orthogonal.actions[0]["do"]=function(){if(ld()){var a={type:"Free",name:Ta(),labeled:!0,pos:[ta[0],ta[1],1],tmp:!0},a=Ha(a);Hb=Ha({type:"Perp",name:Ta(),labeled:!0,args:[ua[0].name,a.name]});sc(a);return!0}return!1};G.Orthogonal.actions[1]={};G.Orthogonal.actions[1].event= -"mouseup";G.Orthogonal.actions[1]["do"]=function(){tb();return!0};G.Intersection={};G.Intersection.actions=[];G.Intersection.actions[0]={};G.Intersection.actions[0].event="mousedown";G.Intersection.actions[0].tooltip="Select two elements to define their intersection";G.Intersection.actions[0]["do"]=function(){return md()};G.Intersection.actions[1]={};G.Intersection.actions[1].event="mousedown";G.Intersection.actions[1]["do"]=function(){return md()?(Hb=Ha({type:"Meet",name:Ta(),labeled:!0,args:[ua[0].name, -ua[1].name]}),!0):!1};var $a={},z={drawingstate:{}};z.drawingstate.linecolor="rgb(0,0,255)";z.drawingstate.linecolorraw=[0,0,1];z.drawingstate.pointcolor="rgb(0,255,0)";z.drawingstate.pointcolorraw=[0,1,0];z.drawingstate.textcolor="rgb(0,0,0)";z.drawingstate.textcolorraw=[0,0,0];z.drawingstate.alpha=1;z.drawingstate.pointsize=4;z.drawingstate.linesize=1;z.drawingstate.textsize=null;z.drawingstate.matrix={};z.drawingstate.matrix.a=25;z.drawingstate.matrix.b=0;z.drawingstate.matrix.c=0;z.drawingstate.matrix.d= -25;z.drawingstate.matrix.tx=250.5;z.drawingstate.matrix.ty=250.5;z.drawingstate.matrix.det=z.drawingstate.matrix.a*z.drawingstate.matrix.d-z.drawingstate.matrix.b*z.drawingstate.matrix.c;z.drawingstate.matrix.sdet=Math.sqrt(z.drawingstate.matrix.det);z.drawingstate.initialmatrix={};z.drawingstate.initialmatrix.a=z.drawingstate.matrix.a;z.drawingstate.initialmatrix.b=z.drawingstate.matrix.b;z.drawingstate.initialmatrix.c=z.drawingstate.matrix.c;z.drawingstate.initialmatrix.d=z.drawingstate.matrix.d; -z.drawingstate.initialmatrix.tx=z.drawingstate.matrix.tx;z.drawingstate.initialmatrix.ty=z.drawingstate.matrix.ty;z.drawingstate.initialmatrix.det=z.drawingstate.matrix.det;z.drawingstate.initialmatrix.sdet=z.drawingstate.matrix.sdet;z.clone=function(a){if(null===a||"object"!==typeof a)return a;var b=a.constructor(),c;for(c in a)b[c]=z.clone(a[c]);return b};$a.backup=z.clone(z.drawingstate);$a.stack=[];z.clone(z.drawingstate);z.reset=function(){z.drawingstate.matrix.a=z.drawingstate.initialmatrix.a; -z.drawingstate.matrix.b=z.drawingstate.initialmatrix.b;z.drawingstate.matrix.c=z.drawingstate.initialmatrix.c;z.drawingstate.matrix.d=z.drawingstate.initialmatrix.d;z.drawingstate.matrix.tx=z.drawingstate.initialmatrix.tx;z.drawingstate.matrix.ty=z.drawingstate.initialmatrix.ty;z.drawingstate.matrix.det=z.drawingstate.initialmatrix.det;z.drawingstate.matrix.sdet=z.drawingstate.initialmatrix.sdet};z.from=function(a,b,c){a/=c;b/=c;c=z.drawingstate.matrix;return[a*c.a-b*c.b+c.tx,a*c.c-b*c.d-c.ty]};z.to= -function(a,b){var c=z.drawingstate.matrix,d=a-c.tx,e=b+c.ty;return[(d*c.d-e*c.b)/c.det,-(-d*c.c+e*c.a)/c.det,1]};z.toMat=function(){var a=z.drawingstate.matrix;return g.realMatrix([[a.d,-a.b,-a.tx*a.d-a.ty*a.b],[a.c,-a.a,-a.tx*a.c-a.ty*a.a],[0,0,a.det]])};z.dumpTrafo=function(){function a(a){return Math.round(1E3*a)/1E3}var b=z.drawingstate.matrix;console.log("a:"+a(b.a)+" b:"+a(b.b)+" c:"+a(b.c)+" d:"+a(b.d)+" tx:"+a(b.ty)+" ty:"+a(b.tx))};z.setMat=function(a,b,c,d,e,f){var g=z.drawingstate.matrix; -g.a=a;g.b=b;g.c=c;g.d=d;g.tx=e;g.ty=f;g.det=a*d-b*c;g.sdet=Math.sqrt(g.det)};z.scaleAndOrigin=function(a,b,c){z.setMat(a,0,0,a,b,c)};z.visibleRect=function(a,b,c,d){var e=c-a,f=b-d,e=da*f<ca*e?da/e:ca/f;z.setMat(e,0,0,e,(da-e*(a+c))/2,(ca-e*(b+d))/2)};z.applyMat=function(a,b,c,d,e,f){var g=z.drawingstate.matrix;z.setMat(g.a*a+g.c*b,g.b*a+g.d*b,g.a*c+g.c*d,g.b*c+g.d*d,g.a*e+g.c*f+g.tx,g.b*e+g.d*f+g.ty)};z.translate=function(a,b){z.applyMat(1,0,0,1,a,b)};z.rotate=function(a){var b=Math.cos(a);a=Math.sin(a); -z.applyMat(b,a,-a,b,0,0)};z.scale=function(a){z.applyMat(a,0,0,a,0,0)};z.gsave=function(){$a.stack.push(z.clone(z.drawingstate))};z.grestore=function(){0!==$a.stack.length&&(z.drawingstate=$a.stack.pop())};z.greset=function(){z.drawingstate=z.clone($a.backup);z.drawingstate.matrix.ty-=ca;z.drawingstate.initialmatrix.ty-=ca;$a.stack=[]};z.createnewbackup=function(){z.drawingstate.initialmatrix.a=z.drawingstate.matrix.a;z.drawingstate.initialmatrix.b=z.drawingstate.matrix.b;z.drawingstate.initialmatrix.c= -z.drawingstate.matrix.c;z.drawingstate.initialmatrix.d=z.drawingstate.matrix.d;z.drawingstate.initialmatrix.tx=z.drawingstate.matrix.tx;z.drawingstate.initialmatrix.ty=z.drawingstate.matrix.ty;z.drawingstate.initialmatrix.det=z.drawingstate.matrix.det;z.drawingstate.initialmatrix.sdet=z.drawingstate.matrix.sdet;$a.backup=z.clone(z.drawingstate)};z.makecolor=function(a,b,c){a=Math.floor(255*a);b=Math.floor(255*b);c=Math.floor(255*c);return 1===z.drawingstate.alpha?"rgb("+a+","+b+","+c+")":"rgba("+ -a+","+b+","+c+","+z.drawingstate.alpha+")"};z.setcolor=function(a){var b=a.value[0].value.real,c=a.value[1].value.real;a=a.value[2].value.real;z.drawingstate.linecolor=z.drawingstate.pointcolor=z.makecolor(b,c,a);z.drawingstate.linecolorraw=z.drawingstate.pointcolorraw=[b,c,a]};z.setlinecolor=function(a){var b=a.value[0].value.real,c=a.value[1].value.real;a=a.value[2].value.real;z.drawingstate.linecolor=z.makecolor(b,c,a);z.drawingstate.linecolorraw=[b,c,a]};z.settextcolor=function(a){var b=a.value[0].value.real, -c=a.value[1].value.real;a=a.value[2].value.real;z.drawingstate.textcolor=z.makecolor(b,c,a);z.drawingstate.textcolorraw=[b,c,a]};z.setpointcolor=function(a){var b=a.value[0].value.real,c=a.value[1].value.real;a=a.value[2].value.real;z.drawingstate.pointcolor=z.makecolor(b,c,a);z.drawingstate.pointcolorraw=[b,c,a]};z.setalpha=function(a){z.drawingstate.alpha=a.value.real;z.drawingstate.linecolor=z.makecolor(z.drawingstate.linecolorraw[0],z.drawingstate.linecolorraw[1],z.drawingstate.linecolorraw[2]); -z.drawingstate.pointcolor=z.makecolor(z.drawingstate.pointcolorraw[0],z.drawingstate.pointcolorraw[1],z.drawingstate.pointcolorraw[2]);z.drawingstate.textcolor=z.makecolor(z.drawingstate.textcolorraw[0],z.drawingstate.textcolorraw[1],z.drawingstate.textcolorraw[2])};z.setpointsize=function(a){z.drawingstate.pointsize=a.value.real};z.setlinesize=function(a){z.drawingstate.linesize=a.value.real};z.settextsize=function(a){z.drawingstate.textsize=a.value.real};var la={clip:"none",pointColor:[1,0,0],lineColor:[0, -0,1],pointSize:5,lineSize:1,alpha:1,overhangLine:1,overhangSeg:1,dimDependent:.7,fontFamily:"sans-serif",textsize:20,lineHeight:1.45};p.defaultAppearance&&$d(p.defaultAppearance);var Ub={},ud={UL:0,UR:1,LR:2,LL:3},vc=["in","out","good","backup"],hb=new Float64Array(0),db={};vc.forEach(function(a){db[a]=hb});var ma=hb,Ma=hb,za=hb,va,Aa,fb,Ja,vb,wc=!1,wd={toString:function(){return"RefineException"}},zd=null,L=null;p.enableTraceLog&&(L={logLength:Infinity,fullLog:[],currentMouseAndScripts:null,currentMover:null, -currentStep:null,currentElement:null,currentParam:null,labelTracing2:w.wrap("tracing2"),labelTracing4:w.wrap("tracing4"),labelTracingSesq:w.wrap("tracingSesq"),postMouseHooks:[]},"number"===typeof p.enableTraceLog&&(L.logLength=p.enableTraceLog),oa.getTraceLog=fe,oa.formatTraceLog=ge,oa.addTraceHook=L.postMouseHooks.push.bind(L.postMouseHooks));Na.stateSize=12;xc.stateSize=24;var ib=[];gb.P=function(a){u.lines.forEach(function(b){b=Dd(a,b);b.holds()&&ib.push(b)});u.conics.forEach(function(b){b=Ed(a, -b);b.holds()&&ib.push(b)})};gb.L=function(a){u.points.forEach(function(b){b=Dd(b,a);b.holds()&&ib.push(b)})};gb.S=gb.L;gb.C=function(a){u.points.forEach(function(b){b=Ed(b,a);b.holds()&&ib.push(b)})};var m={_helper:{},RandomLine:{}};m.RandomLine.kind="L";m.RandomLine.signature=[];m.RandomLine.updatePosition=function(a){a.homog=g.realVector([Math.random()-.5,Math.random()-.5,Math.random()-.5]);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};m.FreeLine={};m.FreeLine.kind="L";m.FreeLine.signature= -[];m.FreeLine.isMovable=!0;m.FreeLine.initialize=function(a){a=m._helper.initializeLine(a);T(a)};m.FreeLine.getParamForInput=function(a,b,c){"mouse"===c?(a=g.cross(b,g.ez),a=g.cross(a,b)):a="homog"===c?b:g.turnIntoCSList([l.zero,l.zero,l.zero]);return g.normalizeMax(a)};m.FreeLine.getParamFromState=function(a){return Z(3)};m.FreeLine.putParamToState=function(a,b){T(b)};m.FreeLine.updatePosition=function(a){var b=Z(3);T(b);a.homog=w.withUsage(b,"Line")};m.FreeLine.stateSize=6;m.RandomPoint={};m.RandomPoint.kind= -"P";m.RandomPoint.signature=[];m.RandomPoint.updatePosition=function(a){a.homog=g.realVector([100*Math.random(),100*Math.random(),100*Math.random()]);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};m.Join={};m.Join.kind="L";m.Join.signature=["P","P"];m.Join.updatePosition=function(a){a.homog=g.cross(u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};m.Segment={};m.Segment.kind="S";m.Segment.signature=["P", -"P"];m.Segment.updatePosition=function(a){var b=u.csnames[a.args[0]],c=u.csnames[a.args[1]];m.Segment.setSegmentPos(a,g.cross(b.homog,c.homog),g.scalmult(c.homog.value[2],b.homog),g.scalmult(b.homog.value[2],c.homog))};m.Segment.setSegmentPos=function(a,b,c,d){b=g.normalizeMax(b);a.homog=w.withUsage(b,"Line");b=g.turnIntoCSList([c,d]);b=g.normalizeMax(b);a.startpos=b.value[0];a.endpos=b.value[1]};m.Meet={};m.Meet.kind="P";m.Meet.signature=["L","L"];m.Meet.updatePosition=function(a){a.homog=g.cross(u.csnames[a.args[0]].homog, -u.csnames[a.args[1]].homog);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};m.Meet.visiblecheck=function(a){var b=!0,c=u.csnames[a.args[0]],d=u.csnames[a.args[1]];"S"===c.kind&&(b=sd(a,c));b&&"S"===d.kind&&(b=sd(a,d));a.isshowing=b};m._helper.midpoint=function(a,b){return g.normalizeMax(g.add(g.scalmult(b.value[2],a),g.scalmult(a.value[2],b)))};m.Mid={};m.Mid.kind="P";m.Mid.signature=["P","P"];m.Mid.updatePosition=function(a){var b=m._helper.midpoint(u.csnames[a.args[0]].homog, -u.csnames[a.args[1]].homog);a.homog=w.withUsage(b,"Point")};m.Perp={};m.Perp.kind="L";m.Perp.signature=["L","P"];m.Perp.updatePosition=function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog,b=g.turnIntoCSList([b.value[0],b.value[1],l.zero]);a.homog=g.cross(b,c);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};m.Para={};m.Para.kind="L";m.Para.signature=["L","P"];m.Para.updatePosition=function(a){var b=u.csnames[a.args[1]].homog;a.homog=g.cross(g.cross(g.linfty, -u.csnames[a.args[0]].homog),b);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};m.Horizontal={};m.Horizontal.kind="L";m.Horizontal.signature=["P"];m.Horizontal.updatePosition=function(a){a.homog=g.cross(g.ex,u.csnames[a.args[0]].homog);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};m.HorizontalLine={};m.HorizontalLine.kind="L";m.HorizontalLine.signature=[];m.HorizontalLine.isMovable=!0;m.HorizontalLine.initialize=function(a){a=m._helper.initializeLine(a); -a=g.turnIntoCSList([l.zero,a.value[1],a.value[2]]);a=g.normalizeMax(a);T(a)};m.HorizontalLine.getParamForInput=function(a,b,c){if("mouse"===c)b=g.cross(b,g.ex);else if("homog"===c){if(0!==b.value[0].real||0!==b.value[0].imag)b=g.turnIntoCSList([l.zero,b.value[1],b.value[2]])}else b=g.turnIntoCSList([l.zero,l.zero,l.zero]);return g.normalizeMax(b)};m.HorizontalLine.getParamFromState=function(a){return Z(3)};m.HorizontalLine.putParamToState=function(a,b){T(b)};m.HorizontalLine.updatePosition=function(a){var b= -Z(3);T(b);a.homog=w.withUsage(b,"Line")};m.HorizontalLine.stateSize=6;m.Vertical={};m.Vertical.kind="L";m.Vertical.signature=["P"];m.Vertical.updatePosition=function(a){a.homog=g.cross(g.ey,u.csnames[a.args[0]].homog);a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};m.VerticalLine={};m.VerticalLine.kind="L";m.VerticalLine.signature=[];m.VerticalLine.isMovable=!0;m.VerticalLine.initialize=function(a){a=m._helper.initializeLine(a);a=g.turnIntoCSList([a.value[0],l.zero,a.value[2]]); -a=g.normalizeMax(a);T(a)};m.VerticalLine.getParamForInput=function(a,b,c){if("mouse"===c)b=g.cross(b,g.ey);else if("homog"===c){if(0!==b.value[1].real||0!==b.value[1].imag)b=g.turnIntoCSList([b.value[0],l.zero,b.value[2]])}else b=g.turnIntoCSList([l.zero,l.zero,l.zero]);return g.normalizeMax(b)};m.VerticalLine.getParamFromState=function(a){return Z(3)};m.VerticalLine.putParamToState=function(a,b){T(b)};m.VerticalLine.updatePosition=function(a){var b=Z(3);T(b);a.homog=w.withUsage(b,"Line")};m.VerticalLine.stateSize= -6;m.LineByFixedAngle={};m.LineByFixedAngle.kind="L";m.LineByFixedAngle.signature=["L","P"];m.LineByFixedAngle.initialize=function(a){var b=l._helper.input(a.angle),c=l.cos(b),b=l.sin(b);a.rot=g.turnIntoCSList([g.turnIntoCSList([b,c,l.zero]),g.turnIntoCSList([l.neg(c),b,l.zero]),g.turnIntoCSList([l.zero,l.zero,l.zero])])};m.LineByFixedAngle.updatePosition=function(a){var b=u.csnames[a.args[1]],c=g.productMV(a.rot,u.csnames[a.args[0]].homog);a.homog=g.cross(b.homog,c);a.homog=g.normalizeMax(a.homog); -a.homog=w.withUsage(a.homog,"Line")};m.Through={};m.Through.kind="L";m.Through.signature=["P"];m.Through.isMovable=!0;m.Through.initialize=function(a){a=a.dir?w.wrap(a.dir):g.realVector([a.pos[1],-a.pos[0],0]);T(a)};m.Through.getParamForInput=function(a,b,c){a="dir"===c||"mouse"===c?g.cross(u.csnames[a.args[0]].homog,b):"homog"===c?b:g.turnIntoCSList([l.zero,l.zero,l.zero]);a=g.cross(g.linfty,a);return g.normalizeMax(a)};m.Through.getParamFromState=function(a){return Z(3)};m.Through.putParamToState= -function(a,b){T(b)};m.Through.updatePosition=function(a){var b=Z(3);T(b);b=g.cross(u.csnames[a.args[0]].homog,b);b=g.normalizeMax(b);a.homog=w.withUsage(b,"Line")};m.Through.stateSize=6;m.Through.set_angle=function(a,b){if("number"===b.ctype){var c=l.cos(b),d=l.sin(b),c=g.turnIntoCSList([c,d,l.real(0)]);Ia(a,c,"dir")}};m.Through.set_slope=function(a,b){if("number"===b.ctype){var c=g.turnIntoCSList([l.real(1),b,l.real(0)]);Ia(a,c,"dir")}};m.Free={};m.Free.kind="P";m.Free.signature=[];m.Free.isMovable= -!0;m.Free.initialize=function(a){a=m._helper.initializePoint(a);T(a)};m.Free.getParamForInput=function(a,b,c){if("mouse"===c&&cc&&0!==Wa){b=g.normalizeZ(b);a=b.value[0].value.real;c=b.value[1].value.real;var d=Math.round(a/Wa)*Wa,e=Math.round(c/Wa)*Wa;.2>Math.abs(d-a)&&.2>Math.abs(e-c)&&(b=g.realVector([d,e,1]))}return g.normalizeMax(b)};m.Free.getParamFromState=function(a){return Z(3)};m.Free.putParamToState=function(a,b){T(b)};m.Free.updatePosition=function(a){var b=Z(3);T(b);a.homog=w.withUsage(b, -"Point")};m.Free.stateSize=6;m._helper.projectPointToLine=function(a,b){var c=g.turnIntoCSList([b.value[0],b.value[1],l.zero]),c=g.cross(c,a);return g.normalizeMax(g.cross(c,b))};m.PointOnLine={};m.PointOnLine.kind="P";m.PointOnLine.signature=["L"];m.PointOnLine.isMovable=!0;m.PointOnLine.initialize=function(a){var b=m._helper.initializePoint(a);a=u.csnames[a.args[0]].homog;var b=m._helper.projectPointToLine(b,a),b=g.normalizeMax(b),c=g.cross(g.linfty,b);g.normalizeMax(c);T(b);T(a);fb=!1};m.PointOnLine.updatePosition= -function(a,b){var c,d=u.csnames[a.args[0]].homog;c=Z(3);Z(3);if(!b){va=a.stateIdx;var e=ma;ma=za;var f=Z(3),l=Z(3);ma=e;e=g.cross(l,d);g._helper.isAlmostZero(e)&&(e=g.cross(g.linfty,d));f=m._helper.CircleMP(e,f);f=m._helper.IntersectLC(d,f);e=m._helper.pointReflection(e,c);c=Ad(f[0],f[1],c,e)[0]}c=g.normalizeMax(c);T(c);T(d);a.homog=w.withUsage(c,"Point")};m.PointOnLine.getParamForInput=function(a,b,c){return b=m._helper.projectPointToLine(b,u.csnames[a.args[0]].homog)};m.PointOnLine.getParamFromState= -function(a){return Z(3)};m.PointOnLine.putParamToState=function(a,b){return T(b)};m.PointOnLine.stateSize=12;m.PointOnCircle={};m.PointOnCircle.kind="P";m.PointOnCircle.signature=["C"];m.PointOnCircle.isMovable=!0;m.PointOnCircle.initialize=function(a){var b=u.csnames[a.args[0]];a=g.normalizeZ(m._helper.initializePoint(a));var c=g.normalizeZ(m._helper.CenterOfCircle(b.matrix)),d=g.sub(a,c),d=g.turnIntoCSList([d.value[1],l.neg(d.value[0]),l.zero]),c=g.cross(a,c),b=m._helper.IntersectLC(c,b.matrix), -c=g.projectiveDistMinScal(a,b[0]);g.projectiveDistMinScal(a,b[1])<c?(a=b[1],b=b[0]):(a=b[0],b=b[1]);T(d);T(a);T(b);fb=!1};m.PointOnCircle.putParamToState=function(a,b){T(b)};m.PointOnCircle.getParamFromState=function(a){return Z(3)};m.PointOnCircle.getParamForInput=function(a,b,c){c=g.normalizeZ(m._helper.CenterOfCircle(u.csnames[a.args[0]].matrix));b=g.sub(b,c);va=a.stateIdx;a=Z(3);var d=g.normalizeZ(Z(3));c=g.sub(d,c);0>l.sub(l.mult(a.value[0],c.value[1]),l.mult(a.value[1],c.value[0])).value.real&& -(b=g.neg(b));return g.turnIntoCSList([b.value[1],l.neg(b.value[0]),l.zero])};m.PointOnCircle.parameterPath=function(a,b,c,d,e){d=g.normalizeAbs(d);e=g.normalizeAbs(e);var f=g.scalproduct(d,e);if(0<=f.value.real)return xd(a,b,c,d,e);a=g.turnIntoCSList([l.sub(d.value[1],e.value[1]),l.sub(e.value[0],d.value[0]),l.zero]);f=g.scalproduct(d,a);0>f.value.real&&(a=g.neg(a));0>b?(b=2*b+1,c=b*b,f=.25/(1+c),c=l.complex(2*b*f+.25,(1-c)*f)):(b=2*b-1,c=b*b,f=.25/(1+c),c=l.complex(2*b*f+.75,(1-c)*f));var k=l.sub(l.real(1), -c);b=l.mult(c,c);f=l.mult(k,k);c=l.mult(c,k);d=g.scalmult(f,d);d=g.add(d,g.scalmult(c,a));return d=g.add(d,g.scalmult(b,e))};m.PointOnCircle.updatePosition=function(a){var b=Z(3);T(b);var c=u.csnames[a.args[0]],b=g.productMV(c.matrix,b),c=m._helper.IntersectLC(b,c.matrix),c=Na(c[0],c[1]),b=g.normalizeMax(c.value[0]);a.homog=w.withUsage(b,"Point");a.antipodalPoint=c.value[1]};m.PointOnCircle.stateSize=6+Na.stateSize;m.OtherPointOnCircle={};m.OtherPointOnCircle.kind="P";m.OtherPointOnCircle.signature= -["P"];m.OtherPointOnCircle.signatureConstraints=function(a){return"PointOnCircle"===u.csnames[a.args[0]].type};m.OtherPointOnCircle.updatePosition=function(a){var b=u.csnames[a.args[0]].antipodalPoint,b=g.normalizeMax(b);a.homog=w.withUsage(b,"Point")};m.PointOnSegment={};m.PointOnSegment.kind="P";m.PointOnSegment.signature=["S"];m.PointOnSegment.isMovable=!0;m.PointOnSegment.initialize=function(a){var b=m._helper.initializePoint(a);a=m.PointOnSegment.getParamForInput(a,b);Va(a)};m.PointOnSegment.getParamForInput= -function(a,b){var c=u.csnames[a.args[0]],d=c.homog,d=g.turnIntoCSList([d.value[0],d.value[1],l.zero]),e=g.sub(c.startpos,c.endpos),c=g.crossratio3(e,c.startpos,c.endpos,b,d);0>c.value.real&&(c=l.complex(0,c.value.imag));1<c.value.real&&(c=l.complex(1,c.value.imag));return c};m.PointOnSegment.getParamFromState=function(a){return wb()};m.PointOnSegment.putParamToState=function(a,b){Va(b)};m.PointOnSegment.updatePosition=function(a){var b=wb();Va(b);var c=u.csnames[a.args[0]],d=c.startpos,c=g.sub(c.endpos, -d),b=g.add(d,g.scalmult(b,c)),b=g.normalizeMax(b);a.homog=w.withUsage(b,"Point")};m.PointOnSegment.stateSize=2;m._helper.projectPointToCircle=function(a,b){var c=m._helper.CenterOfCircle(a.matrix),c=g.normalizeMax(c),c=g.normalizeMax(g.cross(b,c)),c=m._helper.IntersectLC(c,a.matrix),d=g.projectiveDistMinScal(b,c[0]),e=g.projectiveDistMinScal(b,c[1]);return d<e?c[0]:c[1]};m.PointOnArc={};m.PointOnArc.kind="P";m.PointOnArc.signature=["C"];m.PointOnArc.signatureConstraints=function(a){return u.csnames[a.args[0]].isArc}; -m.PointOnArc.isMovable=!0;m.PointOnArc.initialize=function(a){var b=m._helper.initializePoint(a);a=m.PointOnArc.getParamForInput(a,b);T(a)};m.PointOnArc.getParamForInput=function(a,b){var c=u.csnames[a.args[0]],d=m._helper.projectPointToCircle(c,b),c=g.normalizeMax(g.crossratio3harm(c.startPoint,c.endPoint,c.viaPoint,d,g.ii)),d=l.div(c.value[0],c.value[1]);0>d.value.real&&(c=-1>d.value.real?g.realVector([1,0]):g.realVector([0,1]));return c};m.PointOnArc.getParamFromState=function(a){return Z(2)}; -m.PointOnArc.putParamToState=function(a,b){T(b)};m.PointOnArc.updatePosition=function(a){var b=u.csnames[a.args[0]],c=b.startPoint,d=b.viaPoint,e=b.endPoint,f=g.ii,k=g.cross(c,f),d=g.cross(d,f),n=g.cross(e,f),n=g.turnIntoCSList([k,n]),k=g.transpose(n),n=g.conjugate(n),k=g.productMM(n,k),d=g.productMV(n,d),k=g.productMV(g.adjoint2(k),d),d=k.value[0],k=k.value[1],n=Z(2);T(n);c=g.normalizeMax(g.add(g.scalmult(l.mult(d,n.value[0]),c),g.scalmult(l.mult(k,n.value[1]),e)));b=m._helper.conicOtherIntersection(b.matrix, -f,c);a.homog=w.withUsage(b,"Point")};m.PointOnArc.stateSize=4;m._helper.CenterOfCircle=function(a){return g.turnIntoCSList([a.value[2].value[0],a.value[2].value[1],l.neg(a.value[0].value[0])])};m._helper.CenterOfConic=function(a){a=g.adjoint3(a);return{ctype:"list",value:[a.value[2].value[0],a.value[2].value[1],a.value[2].value[2]]}};m.CenterOfConic={};m.CenterOfConic.kind="P";m.CenterOfConic.signature=["C"];m.CenterOfConic.updatePosition=function(a){var b=m._helper.CenterOfConic(u.csnames[a.args[0]].matrix); -a.homog=b;a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};m._helper.CircleMP=function(a,b){var c=a.value[0],d=a.value[1],e=l.neg(a.value[2]),f=l.zero,c=g.turnIntoCSList([g.turnIntoCSList([e,f,c]),g.turnIntoCSList([f,e,d]),g.turnIntoCSList([c,d,f])]),e=w.mult(w.mult(b,c),b),d=w.mult(w.mult(b,g.fund),b),e=w.mult(e,g.fund),c=w.mult(d,c);return g.sub(e,c)};m.CircleMP={};m.CircleMP.kind="C";m.CircleMP.signature=["P","P"];m.CircleMP.updatePosition=function(a){a.matrix=m._helper.CircleMP(u.csnames[a.args[0]].homog, -u.csnames[a.args[1]].homog);a.matrix=g.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Circle")};m.CircleMr={};m.CircleMr.kind="C";m.CircleMr.signature=["P"];m.CircleMr.isMovable=!0;m.CircleMr.initialize=function(a){Va(l.real(a.radius))};m.CircleMr.getParamForInput=function(a,b,c){if("radius"===c)return b;a=u.csnames[a.args[0]].homog;a=g.normalizeZ(a);b=g.normalizeZ(b);b=g.sub(a,b);return b=g.abs(b)};m.CircleMr.getParamFromState=function(a){return wb()};m.CircleMr.putParamToState=function(a, -b){Va(b)};m.CircleMr.updatePosition=function(a){var b=wb();Va(b);var c=u.csnames[a.args[0]].homog,d=l.mult(c.value[2],b),d=l.mult(d,d);if(!l._helper.isFinite(d)&&!l._helper.isNaN(d))return g.fund;c=m._helper.ScaledCircleMrr(c,d);a.matrix=w.withUsage(c,"Circle");a.radius=b};m.CircleMr.stateSize=2;m.CircleMr.set_radius=function(a,b){"number"===b.ctype&&Ia(a,b,"radius")};m._helper.ScaledCircleMrr=function(a,b){var c=a.value[0],d=a.value[1],e=l.neg(a.value[2]),e=g.scalmult(e,g.turnIntoCSList([c,d,e])).value, -c=g.turnIntoCSList([c,d]),c=l.sub(g.scalproduct(c,c),b),e=m._helper.buildConicMatrix([e[2],l.zero,e[2],e[0],e[1],c]);return g.normalizeMax(e)};m.Compass={};m.Compass.kind="C";m.Compass.signature=["P","P","P"];m.Compass.updatePosition=function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog,d=u.csnames[a.args[2]].homog,e=b.value[2],f=c.value[2],k=d.value[2],b=g.scalmult(l.mult(f,k),b),c=g.scalmult(l.mult(e,k),c),d=g.scalmult(l.mult(e,f),d),b=g.sub(c,b),d=m._helper.ScaledCircleMrr(d, -g.scalproduct(b,b));a.matrix=w.withUsage(d,"Circle")};m._helper.getConicType=function(a){if(1E-16>l.abs(g.det(a)).value.real)return"degenerate";var b=l.mult(a.value[0].value[0],a.value[1].value[1]),b=l.sub(b,l.pow(a.value[0].value[1],l.real(2))),b=b.value.real;return 1E-16>Math.abs(b)?"parabola":1E-16<b?"ellipsoid":"hyperbola"};m._helper.ConicBy5=function(a,b,c,d,e,f){a=g.turnIntoCSList([g.cross(c,d)]);var k=g.turnIntoCSList([g.cross(b,e)]);b=g.turnIntoCSList([g.cross(b,c)]);d=g.turnIntoCSList([g.cross(d, -e)]);return m._helper.conicFromTwoDegenerates(a,k,b,d,f)};m._helper.conicFromTwoDegenerates=function(a,b,c,d,e){a=w.mult(g.transpose(b),a);c=w.mult(g.transpose(d),c);a=g.add(a,g.transpose(a));c=g.add(c,g.transpose(c));d=w.mult(w.mult(e,a),e);e=w.mult(w.mult(e,c),e);c=w.mult(d,c);e=w.mult(e,a);return g.sub(c,e)};m.ConicBy5={};m.ConicBy5.kind="C";m.ConicBy5.signature=["P","P","P","P","P"];m.ConicBy5.updatePosition=function(a){var b=m._helper.ConicBy5(a,u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog, -u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog);a.matrix=b;a.matrix=g.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};m.FreeConic={};m.FreeConic.kind="C";m.FreeConic.signature=[];m.FreeConic.initialize=function(a){var b;b=a.pos?m._helper.inputConic(a.pos):g.zeromatrix(l.real(3),l.real(3));m.FreeConic.putParamToState(a,b)};m.FreeConic.getParamForInput=function(a,b,c){return g.normalizeMax(b)};m.FreeConic.getParamFromState=function(a){return m._helper.buildConicMatrix(Z(6).value)}; -m.FreeConic.putParamToState=function(a,b){for(var c=0;3>c;++c)for(var d=0;d<=c;++d)Va(b.value[c].value[d])};m.FreeConic.updatePosition=function(a){var b=Z(6);T(b);a.matrix=m._helper.buildConicMatrix(b.value);a.matrix=g.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};m.FreeConic.set_matrix=function(a,b){g._helper.isNumberMatrixMN(b,3,3)&&Ia(a,g.add(b,g.transpose(b)),"matrix")};m.FreeConic.stateSize=12;m._helper.buildConicMatrix=function(a){var b=a[1],c=a[2],d=a[3],e=a[4],f=a[5];return g.turnIntoCSList([g.turnIntoCSList([a[0], -b,d]),g.turnIntoCSList([b,c,e]),g.turnIntoCSList([d,e,f])])};m._helper.splitDegenConic=function(a){var b=g.adjoint3(a),c=0,d,e,f=l.abs2(b.value[0].value[0]).value.real;for(d=1;3>d;d++)e=l.abs2(b.value[d].value[d]).value.real,e>f&&(c=d,f=e);d=l.sqrt(l.mult(l.real(-1),b.value[c].value[c]));if(1E-16>l.abs2(d).value.real)return a=g.turnIntoCSList([l.zero,l.zero,l.zero]),[a,a];c=l.real(c+1);e=g.column(b,c);e=g.scaldiv(d,e);d=e.value[0];f=e.value[1];e=e.value[2];d=g.turnIntoCSList([g.turnIntoCSList([l.real(0), -e,l.mult(l.real(-1),f)]),g.turnIntoCSList([l.mult(l.real(-1),e),l.real(0),d]),g.turnIntoCSList([f,l.mult(l.real(-1),d),l.real(0)])]);a=g.add(a,d);var k=0;for(d=f=b=0;3>d;d++)for(c=0;3>c;c++)e=l.abs2(a.value[d].value[c]).value.real,e>f&&(k=d,b=c,f=e);d=a.value[k];a=g.transpose(a);a=a.value[b];d=g.normalizeMax(d);a=g.normalizeMax(a);d=w.withUsage(d,"Line");a=w.withUsage(a,"Line");return[d,a]};m._helper.inputConic=function(a){var b="xx xy yy xz yz zz".split(" ").map(function(b){var d=l._helper.input(a[b]); -b[0]!==b[1]&&(d=l.realmult(.5,d));return d});return m._helper.buildConicMatrix(b)};m.SelectConic={};m.SelectConic.kind="C";m.SelectConic.signature=["Cs"];m.SelectConic.initialize=function(a){if(void 0!==a.index)return a.index-1;var b=m._helper.inputConic(a.pos);a=u.csnames[a.args[0]].results;for(var c=g.conicDist(b,a[0]),d=0,e=1;e<a.length;++e){var f=g.conicDist(b,a[e]);f<c&&(c=f,d=e)}return d};m.SelectConic.updatePosition=function(a){a.matrix=u.csnames[a.args[0]].results[a.param];a.matrix=g.normalizeMax(a.matrix); -a.matrix=w.withUsage(a.matrix,"Conic")};m._helper.ConicBy4p1l=function(a,b,c,d,e,f){var k=g.scalproduct(b,f),n=g.scalproduct(c,f),p=g.scalproduct(d,f),q=g.scalproduct(e,f),t=g.det3(c,d,e),u=g.det3(b,c,e),v=g.det3(b,d,e),w=g.det3(b,c,d),x=l.mult,n=l.sqrt(x(x(n,q),x(t,u))),k=l.sqrt(x(x(k,p),x(v,w))),p=g.cross(g.cross(b,d),f);f=g.cross(g.cross(c,e),f);p=g.scalmult(n,p);k=g.scalmult(k,f);f=g.normalizeMax(g.add(p,k));k=g.normalizeMax(g.sub(p,k));k=Na(f,k);f=m._helper.ConicBy5(a,b,c,d,e,k.value[0]);a=m._helper.ConicBy5(a, -b,c,d,e,k.value[1]);return[g.normalizeMax(f),g.normalizeMax(a)]};m.ConicBy4p1l={};m.ConicBy4p1l.kind="Cs";m.ConicBy4p1l.signature=["P","P","P","P","L"];m.ConicBy4p1l.updatePosition=function(a){var b=m._helper.ConicBy4p1l(a,u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog);a.results=b};m.ConicBy4p1l.stateSize=Na.stateSize;m._helper.ConicBy3p2l=function(a,b,c,d,e){function f(a,b,c,d){return l.sub(l.mult(a,d),l.mult(b, -c))}var k=g.cross(a,b),m=g.cross(d,e);d=g.cross(d,k);e=g.cross(e,k);k=g.turnIntoCSList([d,e,m]);c=g.productVM(c,g.adjoint3(k));m=g.adjoint3(g.turnIntoCSList([g.scalmult(c.value[0],d),g.scalmult(c.value[1],e),g.scalmult(c.value[2],m)]));c=g.transpose(m);d=l.mult;e=g.productMV(c,a);a=e.value[0];e=e.value[1];k=g.productMV(c,b);b=k.value[0];var k=k.value[1],n=l.sqrt(d(a,e)),p=l.sqrt(d(b,k)),q,t=Array(4);for(q=0;4>q;++q){var u=(q&2)-1,v=d(l.real(((q&1)<<1)-1),n),w=d(l.real(u),p),x=f(e,v,k,w),y=f(b,w,a, -v),u=f(a,e,b,k),z=l.add(l.add(f(b,k,a,e),f(k,w,e,v)),f(w,b,v,a)),v=d(x,x),w=d(y,y),A=d(z,z),B=d(x,y),x=d(x,z),y=d(y,z),B=l.sub(B,d(l.real(.5),d(u,u))),u=g.turnIntoCSList([g.turnIntoCSList([v,B,x]),g.turnIntoCSList([B,w,y]),g.turnIntoCSList([x,y,A])]),u=g.productMM(m,g.productMM(u,c)),u=g.turnIntoCSList([u.value[0].value[0],u.value[0].value[1],u.value[0].value[2],u.value[1].value[1],u.value[1].value[2],u.value[2].value[2]]);t[q]=u}return t};m.ConicBy3p2l={};m.ConicBy3p2l.kind="Cs";m.ConicBy3p2l.signature= -["P","P","P","L","L"];m.ConicBy3p2l.updatePosition=function(a){for(var b=m._helper.ConicBy3p2l(u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog),b=Bd(b),c=Array(4),d=0;4>d;++d){var e=b[d].value;c[d]=g.turnIntoCSList([g.turnIntoCSList([e[0],e[1],e[2]]),g.turnIntoCSList([e[1],e[3],e[4]]),g.turnIntoCSList([e[2],e[4],e[5]])])}a.results=c};m.ConicBy3p2l.stateSize=48;m.ConicBy2p3l={};m.ConicBy2p3l.kind="Cs";m.ConicBy2p3l.signature= -["P","P","L","L","L"];m.ConicBy2p3l.updatePosition=function(a){for(var b=m._helper.ConicBy3p2l(u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog,u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog),b=Bd(b),c=Array(4),d=0;4>d;++d){var e=b[d].value,e=g.turnIntoCSList([g.turnIntoCSList([e[0],e[1],e[2]]),g.turnIntoCSList([e[1],e[3],e[4]]),g.turnIntoCSList([e[2],e[4],e[5]])]);c[d]=g.normalizeMax(g.adjoint3(e))}a.results=c};m.ConicBy2p3l.stateSize=48;m.ConicBy1p4l={};m.ConicBy1p4l.kind= -"Cs";m.ConicBy1p4l.signature=["P","L","L","L","L"];m.ConicBy1p4l.updatePosition=function(a){var b=m._helper.ConicBy4p1l(a,u.csnames[a.args[1]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog,u.csnames[a.args[0]].homog),c=b[0],b=b[1],c=g.adjoint3(c),b=g.adjoint3(b),b=[c,b];a.results=b};m.ConicBy1p4l.stateSize=Na.stateSize;m.ConicParabolaPL={};m.ConicParabolaPL.kind="C";m.ConicParabolaPL.signature=["P","L"];m.ConicParabolaPL.updatePosition=function(a){var b=u.csnames[a.args[0]].homog.value, -c=u.csnames[a.args[1]].homog.value,d=l.mult,e=l.neg,f=l.add,k=l.sub,n=b[0],p=b[1],q=b[2],t=c[0],b=c[1],c=c[2],v=d(q,q),x=d(t,t),y=d(b,b),z=d(q,c),A=e(q),q=f(x,y),y=d(v,y),x=d(v,x),e=d(e(v),d(t,b)),t=d(A,f(d(n,q),d(z,t))),b=d(A,f(d(p,q),d(z,b))),d=k(d(f(d(n,n),d(p,p)),q),d(v,d(c,c))),d=m._helper.buildConicMatrix([y,e,x,t,b,d]),d=g.normalizeMax(d);a.matrix=w.withUsage(d,"Conic")};m.ConicBy2Foci1P={};m.ConicBy2Foci1P.kind="Cs";m.ConicBy2Foci1P.signature=["P","P","P"];m.ConicBy2Foci1P.updatePosition= -function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog,d=u.csnames[a.args[2]].homog,e=g.ii,f=g.jj,k=g.normalizeMax(g.cross(b,d)),n=g.normalizeMax(g.cross(c,d)),p=g.normalizeMax(g.cross(d,e)),d=g.normalizeMax(g.cross(d,f)),n=m._helper.coHarmonic(p,d,k,n),k=g.normalizeMax(n[0]),n=g.normalizeMax(n[1]),e=g.turnIntoCSList([e]),p=g.turnIntoCSList([f]),d=g.turnIntoCSList([b]),q=g.turnIntoCSList([c]),f=m._helper.conicFromTwoDegenerates(e,p,d,q,k),f=g.normalizeMax(f),e=m._helper.conicFromTwoDegenerates(e, -p,d,q,n),e=g.normalizeMax(e),f=g.normalizeMax(g.adjoint3(f)),e=g.normalizeMax(g.adjoint3(e));"ellipsoid"!==m._helper.getConicType(f)&&(k=f,f=e,e=k);g.almostequals(b,c).value&&(b=l.real(3),e=g.zeromatrix(b,b));a.results=[f,e]};m.ConicBy2Pol1P={};m.ConicBy2Pol1P.kind="C";m.ConicBy2Pol1P.signature=["P","L","P","L","P"];m.ConicBy2Pol1P.updatePosition=function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog,d=u.csnames[a.args[2]].homog,e=u.csnames[a.args[3]].homog,f=u.csnames[a.args[4]].homog, -k=g.scalproduct,m=g.scalmult,n=g.sub,p=g.productMM,q=l.realmult,t=g.transpose,v=g.turnIntoCSList,x=n(m(k(c,b),f),m(q(2,k(c,f)),b)),y=n(m(k(e,d),f),m(q(2,k(e,f)),d)),z=v([g.cross(b,f)]),f=v([g.cross(d,f)]),y=p(t(z),v([g.cross(b,y)])),v=p(t(f),v([g.cross(d,x)])),p=p(t(z),f),b=k(b,e),c=k(d,c),d=g.add(m(c,y),m(b,v)),d=n(d,m(q(2,l.mult(b,c)),p)),d=g.add(d,t(d)),d=g.normalizeMax(d),d=w.withUsage(d,"Conic");a.matrix=d};m.ConicBy2Pol1L={};m.ConicBy2Pol1L.kind="C";m.ConicBy2Pol1L.signature=["P","L","P","L", -"L"];m.ConicBy2Pol1L.updatePosition=function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog,d=u.csnames[a.args[2]].homog,e=u.csnames[a.args[3]].homog,f=u.csnames[a.args[4]].homog,k=g.scalproduct,m=g.scalmult,n=g.productMM,p=l.mult,q=g.transpose,t=g.turnIntoCSList,v=k(c,b),x=k(c,d),y=k(e,b),z=k(e,d),A=k(f,b),k=k(f,d),B=t([g.sub(m(p(y,k),c),m(p(x,A),e))]),b=g.add(n(q(t([m(p(y,x),f)])),t([g.sub(g.add(m(l.sub(p(v,k),p(x,A)),e),m(l.sub(p(z,A),p(y,k)),c)),m(g.det3(c,e,f),g.cross(b,d)))])), -n(q(B),B)),b=g.add(b,q(b)),b=g.normalizeMax(b),b=w.withUsage(b,"Conic");a.matrix=b};m._helper.conic1Pol3Inc=function(a,b,c,d,e){var f=g.scalproduct,k=g.scalmult,m=g.productMM,n=g.cross,p=l.realmult,q=l.mult,t=g.transpose,u=g.turnIntoCSList,v=g.det3,w=v(a,c,d),x=u([n(c,e)]),y=u([n(a,e)]),z=u([n(c,d)]),A=f(b,a),B=f(b,c);b=f(b,e);n=u([n(d,g.sub(k(A,e),k(p(2,b),a)))]);x=k(w,m(t(x),n));a=p(2,l.add(q(v(a,d,e),B),q(w,b)));a=l.sub(q(v(c,d,e),A),a);x=g.add(x,k(a,m(t(y),z)));x=g.add(x,t(x));return x=g.normalizeMax(x)}; -m.ConicBy1Pol3P={};m.ConicBy1Pol3P.kind="C";m.ConicBy1Pol3P.signature=["P","L","P","P","P"];m.ConicBy1Pol3P.updatePosition=function(a){var b=m._helper.conic1Pol3Inc(u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog),b=w.withUsage(b,"Conic");a.matrix=b};m.ConicBy1Pol3L={};m.ConicBy1Pol3L.kind="C";m.ConicBy1Pol3L.signature=["P","L","L","L","L"];m.ConicBy1Pol3L.updatePosition=function(a){var b=m._helper.conic1Pol3Inc(u.csnames[a.args[1]].homog, -u.csnames[a.args[0]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog),b=g.normalizeMax(g.adjoint3(b)),b=w.withUsage(b,"Conic");a.matrix=b};m._helper.coHarmonic=function(a,b,c,d){var e=g.realVector([100*Math.random(),100*Math.random(),1]),f=g.det3(e,c,a),k=g.det3(e,c,b);c=g.det3(e,d,a);d=g.det3(e,d,b);d=l.sqrt(l.mult(d,k));f=l.sqrt(l.mult(c,f));a=w.mult(a,d);f=w.mult(b,f);b=g.add(a,f);a=g.sub(a,f);return[b,a]};m.ConicInSquare={};m.ConicInSquare.kind="C";m.ConicInSquare.signature= -["P","P","P","P"];m.ConicInSquare.updatePosition=function(a){var b=D.basismap(u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog),c=l.one,c=m._helper.buildConicMatrix([c,c,c,l.real(-3),c,c]),b=g.adjoint3(b),b=g.productMM(g.productMM(g.transpose(b),c),b),b=g.normalizeMax(b);a.matrix=w.withUsage(b,"Conic")};m.ConicBy5lines={};m.ConicBy5lines.kind="C";m.ConicBy5lines.signature=["L","L","L","L","L"];m.ConicBy5lines.updatePosition=function(a){var b= -m._helper.ConicBy5(a,u.csnames[a.args[0]].homog,u.csnames[a.args[1]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[4]].homog),b=g.adjoint3(b);a.matrix=b;a.matrix=g.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};m.ConicFromPrincipalDirections={};m.ConicFromPrincipalDirections.kind="C";m.ConicFromPrincipalDirections.signature=["P","P","P"];m.ConicFromPrincipalDirections.updatePosition=function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog, -d=u.csnames[a.args[2]].homog,e=m._helper.pointReflection(b,c),f=g.cross(c,b),b=g.turnIntoCSList([f.value[0],f.value[1],l.zero]),f=g.turnIntoCSList([f]),c=g.turnIntoCSList([g.cross(c,b)]),e=g.turnIntoCSList([g.cross(e,b)]);a.matrix=m._helper.conicFromTwoDegenerates(f,f,c,e,d);a.matrix=g.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};m.CircleBy3={};m.CircleBy3.kind="C";m.CircleBy3.signature=["P","P","P"];m.CircleBy3.updatePosition=function(a){var b=m._helper.ConicBy5(a,u.csnames[a.args[0]].homog, -u.csnames[a.args[1]].homog,g.ii,g.jj,u.csnames[a.args[2]].homog);a.matrix=g.normalizeMax(b);a.matrix=w.withUsage(a.matrix,"Circle")};m.ArcBy3={};m.ArcBy3.kind="C";m.ArcBy3.signature=["P","P","P"];m.ArcBy3.updatePosition=function(a){m.CircleBy3.updatePosition(a);a.startPoint=u.csnames[a.args[0]].homog;a.viaPoint=u.csnames[a.args[1]].homog;a.endPoint=u.csnames[a.args[2]].homog};m.ArcBy3.initialize=function(a){a.startPoint=u.csnames[a.args[0]].homog;a.viaPoint=u.csnames[a.args[1]].homog;a.endPoint=u.csnames[a.args[2]].homog; -a.isArc=!0};m.PolarOfPoint={};m.PolarOfPoint.kind="L";m.PolarOfPoint.signature=["P","C"];m.PolarOfPoint.updatePosition=function(a){var b=w.mult(u.csnames[a.args[1]].matrix,u.csnames[a.args[0]].homog),b=g.normalizeMax(b);a.homog=w.withUsage(b,"Line")};m.PolarOfLine={};m.PolarOfLine.kind="P";m.PolarOfLine.signature=["L","C"];m.PolarOfLine.updatePosition=function(a){var b=u.csnames[a.args[0]],c=g.adjoint3(u.csnames[a.args[1]].matrix),b=w.mult(c,b.homog),b=g.normalizeMax(b);a.homog=w.withUsage(b,"Point")}; -m.AngleBisector={};m.AngleBisector.kind="Ls";m.AngleBisector.signature=["L","L","P"];m.AngleBisector.updatePosition=function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog,d=u.csnames[a.args[2]].homog,e=g.add,f=g.sub,k=g.abs,l=g.cross,m=g.scalmult,n=g.normalizeMax,p=g._helper.isAlmostZero,q=g.linfty,t=m(k(l(l(q,c),q)),b),b=m(k(l(l(q,b),q)),c),f=f(t,b),e=e(t,b);p(f)&&(f=l(l(l(q,e),q),d));p(e)&&(e=l(l(l(q,f),q),d));a.results=Na(n(f),n(e))};m.AngleBisector.stateSize=Na.stateSize;m._helper.IntersectLC= -function(a,b){var c=l,d=g.crossOperator(a),e=g.transpose(d),e=w.mult(e,w.mult(b,d)),f=g.maxIndex(a,l.abs2),k,m,n,p;0===f?(f=e.value[1].value[1],k=e.value[1].value[2],m=e.value[2].value[1],n=e.value[2].value[2],p=a.value[0]):1===f?(f=e.value[0].value[0],k=e.value[0].value[2],m=e.value[2].value[0],n=e.value[2].value[2],p=a.value[1]):(f=e.value[0].value[0],k=e.value[0].value[1],m=e.value[1].value[0],n=e.value[1].value[1],p=a.value[2]);c=c.div(c.sqrt(c.sub(c.mult(k,m),c.mult(f,n))),p);c=g.add(e,g.scalmult(c, -d));f=g.maxIndex(c,g.abs2);d=c.value[f];d=g.normalizeMax(d);d=w.withUsage(d,"Point");c=g.transpose(c);f=g.maxIndex(c,g.abs2);c=c.value[f];c=g.normalizeMax(c);c=w.withUsage(c,"Point");return[d,c]};m.IntersectLC={};m.IntersectLC.kind="Ps";m.IntersectLC.signature=["L","C"];m.IntersectLC.updatePosition=function(a){var b=m._helper.IntersectLC(u.csnames[a.args[0]].homog,u.csnames[a.args[1]].matrix);a.results=Na(b[0],b[1])};m.IntersectLC.stateSize=Na.stateSize;m.OtherIntersectionCL={};m.OtherIntersectionCL.kind= -"P";m.OtherIntersectionCL.signature=["C","L","P"];m.OtherIntersectionCL.updatePosition=function(a){var b=u.csnames[a.args[2]].homog,c=m._helper.IntersectLC(u.csnames[a.args[1]].homog,u.csnames[a.args[0]].matrix),d=c[0],c=c[1],e=g.projectiveDistMinScal(d,b),b=g.projectiveDistMinScal(c,b);a.homog=e<b?c:d;a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};m.IntersectCirCir={};m.IntersectCirCir.kind="Ps";m.IntersectCirCir.signature=["C","C"];m.IntersectCirCir.updatePosition=function(a){var b= -u.csnames[a.args[0]].matrix,c=u.csnames[a.args[1]].matrix,d=g.scalmult(c.value[0].value[0],b.value[2]),c=g.scalmult(b.value[0].value[0],c.value[2]),d=g.sub(d,c),d=g.turnIntoCSList([d.value[0],d.value[1],l.realmult(.5,d.value[2])]),d=g.normalizeMax(d),b=m._helper.IntersectLC(d,b);a.results=Na(b[0],b[1])};m.IntersectCirCir.stateSize=Na.stateSize;m.OtherIntersectionCC={};m.OtherIntersectionCC.kind="P";m.OtherIntersectionCC.signature=["C","C","P"];m.OtherIntersectionCC.updatePosition=function(a){var b= -u.csnames[a.args[0]].matrix,c=u.csnames[a.args[1]].matrix,d=u.csnames[a.args[2]].homog,e=g.scalmult(c.value[0].value[0],b.value[2]),c=g.scalmult(b.value[0].value[0],c.value[2]),e=g.sub(e,c),e=g.turnIntoCSList([e.value[0],e.value[1],l.realmult(.5,e.value[2])]),e=g.normalizeMax(e),e=m._helper.IntersectLC(e,b),b=e[0],e=e[1],c=g.projectiveDistMinScal(b,d),d=g.projectiveDistMinScal(e,d);a.homog=c<d?e:b;a.homog=g.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};m._helper.IntersectConicConic= -function(a,b){var c=a.value[0],d=a.value[1],e=a.value[2],f=b.value[0],k=b.value[1],n=b.value[2],p=g.det3(c,d,e),q=l.add(l.add(g.det3(c,d,n),g.det3(c,k,e)),g.det3(f,d,e)),c=l.add(l.add(g.det3(c,k,n),g.det3(f,d,n)),g.det3(f,k,e)),f=g.det3(f,k,n),n=l.abs2(p).value.real,k=l.abs2(f).value.real;n<k&&(n=a,a=b,b=n,n=f,f=p,p=n,n=c,c=q,q=n,n=k);1E-24>n?(p=a,c=b):(q=l.solveCubic(p,q,c,f),c=l.abs2(l.sub(q[0],q[1])).value.real,f=l.abs2(l.sub(q[0],q[2])).value.real,k=l.abs2(l.sub(q[1],q[2])).value.real,c>f?(p= -q[1],q=c>k?q[0]:q[2]):(p=q[2],q=f>k?q[0]:q[1]),p=g.add(g.scalmult(p,a),b),c=g.add(g.scalmult(q,a),b));q=m._helper.splitDegenConic(p);p=q[0];q=q[1];c=m._helper.splitDegenConic(c);k=c[0];f=c[1];c=g.cross(p,k);k=g.cross(q,k);p=g.cross(p,f);q=g.cross(q,f);c=g.normalizeMax(c);k=g.normalizeMax(k);p=g.normalizeMax(p);q=g.normalizeMax(q);c=w.withUsage(c,"Point");k=w.withUsage(k,"Point");p=w.withUsage(p,"Point");q=w.withUsage(q,"Point");return[c,k,p,q]};m.IntersectConicConic={};m.IntersectConicConic.kind= -"Ps";m.IntersectConicConic.signature=["C","C"];m.IntersectConicConic.updatePosition=function(a){var b=m._helper.IntersectConicConic(u.csnames[a.args[0]].matrix,u.csnames[a.args[1]].matrix),b=xc(b[0],b[1],b[2],b[3]);a.results=b};m.IntersectConicConic.stateSize=xc.stateSize;m.SelectP={};m.SelectP.kind="P";m.SelectP.signature=["Ps"];m.SelectP.initialize=function(a){if(void 0!==a.index)return a.index-1;var b=u.csnames[a.args[0]].results.value;a=m._helper.initializePoint(a);for(var c=g.projectiveDistMinScal(a, -b[0]),d=0,e=1;e<b.length;++e){var f=g.projectiveDistMinScal(a,b[e]);f<c&&(c=f,d=e)}return d};m.SelectP.updatePosition=function(a){a.homog=u.csnames[a.args[0]].results.value[a.param]};m.SelectL={};m.SelectL.kind="L";m.SelectL.signature=["Ls"];m.SelectL.initialize=function(a){if(void 0!==a.index)return a.index-1;var b=u.csnames[a.args[0]].results.value;a=m._helper.initializeLine(a);for(var c=g.projectiveDistMinScal(a,b[0]),d=0,e=1;e<b.length;++e){var f=g.projectiveDistMinScal(a,b[e]);f<c&&(c=f,d=e)}return d}; -m.SelectL.updatePosition=function(a){a.homog=u.csnames[a.args[0]].results.value[a.param];a.homog=w.withUsage(a.homog,"Line")};m._helper.moebiusStep=function(a,b,c){var d=l.add,e=l.sub,f=l.mult,g=a.value[0],k=a.value[1];a=a.value[2];var m=b.value[0],n=b.value[1];b=b.value[2];var p=c.value[0],q=c.value[1],t=c.value[2];c=e(f(b,p),f(m,t));var u=e(f(b,q),f(n,t)),p=e(f(g,t),f(a,p)),q=e(f(k,t),f(a,q));return[e(f(g,c),f(k,u)),d(f(k,c),f(g,u)),f(a,c),f(a,u),e(f(m,p),f(n,q)),d(f(n,p),f(m,q)),f(b,p),f(b,q)]}; -m.TrMoebius={};m.TrMoebius.kind="Mt";m.TrMoebius.signature="PPPPPP".split("");m.TrMoebius.updatePosition=function(a){var b=l.neg,c=m._helper.moebiusStep(u.csnames[a.args[0]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[4]].homog),d=m._helper.moebiusStep(u.csnames[a.args[1]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[5]].homog),d=g.normalizeMax(g.matrix([[d[0],b(d[1]),d[4],b(d[5])],[d[1],d[0],d[5],d[4]],[d[2],b(d[3]),d[6],b(d[7])],[d[3],d[2],d[7],d[6]]])),b=g.normalizeMax(g.matrix([[c[6], -b(c[4])],[c[7],b(c[5])],[b(c[2]),c[0]],[b(c[3]),c[1]]])),b=g.normalizeMax(g.productMM(d,b));a.moebius={anti:!1,ar:b.value[0].value[0],ai:b.value[1].value[0],br:b.value[0].value[1],bi:b.value[1].value[1],cr:b.value[2].value[0],ci:b.value[3].value[0],dr:b.value[2].value[1],di:b.value[3].value[1]};m._helper.moebiusPair(a)};m._helper.moebiusPair=function(a){var b=a.moebius,c=l.neg,d=b.anti?c:w.identity;a.mat1=g.normalizeMax(g.matrix([[c(b.cr),d(b.ci),c(b.dr)],[b.ci,d(b.cr),b.di],[b.ar,c(d(b.ai)),b.br]])); -a.mat2=g.normalizeMax(g.matrix([[c(b.ci),c(d(b.cr)),c(b.di)],[c(b.cr),d(b.ci),c(b.dr)],[b.ai,d(b.ar),b.bi]]))};m.TrInverseMoebius={};m.TrInverseMoebius.kind="Mt";m.TrInverseMoebius.signature=["Mt"];m.TrInverseMoebius.updatePosition=function(a){var b=u.csnames[a.args[0]].moebius,c=l.neg,d=b.anti?c:w.identity;a.moebius={anti:b.anti,ar:b.dr,ai:d(b.di),br:c(b.br),bi:c(d(b.bi)),cr:c(b.cr),ci:c(d(b.ci)),dr:b.ar,di:d(b.ai)};m._helper.moebiusPair(a)};m.TrMoebiusP={};m.TrMoebiusP.kind="P";m.TrMoebiusP.signature= -["Mt","P"];m.TrMoebiusP.updatePosition=function(a){var b=u.csnames[a.args[0]],c=u.csnames[a.args[1]].homog,d=g.productMV(b.mat1,c),b=g.productMV(b.mat2,c);a.homog=g.normalizeMax(g.cross(d,b));a.homog=w.withUsage(a.homog,"Point")};m._helper.TrMoebiusP=function(a,b){var c=g.productMV(b.mat1,a),d=g.productMV(b.mat2,a);return g.normalizeMax(g.cross(c,d))};m.TrMoebiusL={};m.TrMoebiusL.kind="C";m.TrMoebiusL.signature=["Mt","L"];m.TrMoebiusL.updatePosition=function(a){var b=u.csnames[a.args[0]],c=u.csnames[a.args[1]].homog, -d=function(){var a=g.realVector([Math.random()-.5,Math.random()-.5,Math.random()-.5]);return g.normalizeMax(a)},e=g.cross(d(),c),f=g.cross(d(),c),c=g.cross(d(),c),e=m._helper.TrMoebiusP(e,b),f=m._helper.TrMoebiusP(f,b),b=m._helper.TrMoebiusP(c,b);a.matrix=g.normalizeMax(m._helper.ConicBy5(null,e,f,b,g.ii,g.jj));a.matrix=w.withUsage(a.matrix,"Circle")};m.TrMoebiusS={};m.TrMoebiusS.kind="C";m.TrMoebiusS.signature=["Mt","S"];m.TrMoebiusS.updatePosition=function(a){var b=u.csnames[a.args[0]],c=u.csnames[a.args[1]], -d=c.startpos,c=c.endpos,e=g.add(d,c),d=m._helper.TrMoebiusP(d,b),e=m._helper.TrMoebiusP(e,b),b=m._helper.TrMoebiusP(c,b);a.startPoint=d;a.viaPoint=e;a.endPoint=b;a.isArc=!0;a.matrix=g.normalizeMax(m._helper.ConicBy5(null,d,e,b,g.ii,g.jj));a.matrix=w.withUsage(a.matrix,"Circle")};m.TrMoebiusC={};m.TrMoebiusC.kind="C";m.TrMoebiusC.signature=["Mt","C"];m.TrMoebiusC.signatureConstraints=function(a){return"Circle"===u.csnames[a.args[1]].matrix.usage};m.TrMoebiusC.updatePosition=function(a){var b=u.csnames[a.args[0]], -c=u.csnames[a.args[1]].matrix,d=function(){var a=g.realVector([Math.random()-.5,Math.random()-.5,Math.random()-.5]);return g.normalizeMax(a)},e=m._helper.IntersectLC(d(),c),d=m._helper.IntersectLC(d(),c),c=e[1],d=d[1],e=m._helper.TrMoebiusP(e[0],b),c=m._helper.TrMoebiusP(c,b),b=m._helper.TrMoebiusP(d,b);a.matrix=g.normalizeMax(m._helper.ConicBy5(null,e,c,b,g.ii,g.jj));a.matrix=w.withUsage(a.matrix,"Circle")};m.TrMoebiusArc={};m.TrMoebiusArc.kind="C";m.TrMoebiusArc.signature=["Mt","C"];m.TrMoebiusArc.signatureConstraints= -function(a){return u.csnames[a.args[1]].isArc};m.TrMoebiusArc.updatePosition=function(a){var b=u.csnames[a.args[0]],c=u.csnames[a.args[1]],d=c.viaPoint,e=c.endPoint,c=m._helper.TrMoebiusP(c.startPoint,b),d=m._helper.TrMoebiusP(d,b),b=m._helper.TrMoebiusP(e,b);a.startPoint=c;a.viaPoint=d;a.endPoint=b;a.isArc=!0;a.matrix=g.normalizeMax(m._helper.ConicBy5(null,c,d,b,g.ii,g.jj));a.matrix=w.withUsage(a.matrix,"Circle")};m._helper.trBuildMatrix=function(a,b){var c=b(0),d=b(1),e=g.productMM(d,g.adjoint3(c)); -a.matrix=g.normalizeMax(e);e=g.transpose(g.productMM(c,g.adjoint3(d)));a.dualMatrix=g.normalizeMax(e)};m.TrProjection={};m.TrProjection.kind="Tr";m.TrProjection.signature="PPPPPPPP".split("");m.TrProjection.updatePosition=function(a){m._helper.trBuildMatrix(a,function(b){return D.basismap(u.csnames[a.args[0+b]].homog,u.csnames[a.args[2+b]].homog,u.csnames[a.args[4+b]].homog,u.csnames[a.args[6+b]].homog)})};m.TrAffine={};m.TrAffine.kind="Tr";m.TrAffine.signature="PPPPPP".split("");m.TrAffine.updatePosition= -function(a){var b=l.mult,c=g.scalmult,d=g.turnIntoCSList,e=g.transpose,f=g.normalizeMax,k=g.productMM,m=g.adjoint3,n=d([u.csnames[a.args[0]].homog,u.csnames[a.args[2]].homog,u.csnames[a.args[4]].homog]),p=d([u.csnames[a.args[1]].homog,u.csnames[a.args[3]].homog,u.csnames[a.args[5]].homog]),q=e(n),e=e(p),t=q.value[2].value,v=e.value[2].value,w=[b(t[0],v[2]),b(t[1],v[0]),b(t[2],v[1])],q=m(q).value;a.matrix=f(k(e,d([c(b(w[0],v[1]),q[0]),c(b(w[1],v[2]),q[1]),c(b(w[2],v[0]),q[2])])));q=n.value;a.dualMatrix= -f(k(m(p),d([c(b(t[2],w[1]),q[0]),c(b(t[0],w[2]),q[1]),c(b(t[1],w[0]),q[2])])))};m.TrSimilarity={};m.TrSimilarity.kind="Tr";m.TrSimilarity.signature=["P","P","P","P"];m.TrSimilarity.updatePosition=function(a){m._helper.trBuildMatrix(a,function(b){return D.basismap(u.csnames[a.args[0+b]].homog,u.csnames[a.args[2+b]].homog,g.ii,g.jj)})};m.TrTranslation={};m.TrTranslation.kind="Tr";m.TrTranslation.signature=["P","P"];m.TrTranslation.updatePosition=function(a){var b=u.csnames[a.args[0]].homog,c=u.csnames[a.args[1]].homog, -d=g.cross(b,c).value,b=l.mult(b.value[2],c.value[2]),c=g.turnIntoCSList,e=l.neg,f=l.zero,d=c([c([b,f,d[1]]),c([f,b,e(d[0])]),c([f,f,b])]),d=g.normalizeMax(d);a.matrix=d;b=e(d.value[0].value[0]);d=c([c([b,f,f]),c([f,b,f]),c([d.value[0].value[2],d.value[1].value[2],b])]);a.dualMatrix=d};m.TrReflectionP={};m.TrReflectionP.kind="Tr";m.TrReflectionP.signature=["P"];m.TrReflectionP.updatePosition=function(a){var b=u.csnames[a.args[0]].homog.value,c=l.realmult(-.5,b[2]),d=l.zero,b=g.turnIntoCSList([g.turnIntoCSList([c, -d,b[0]]),g.turnIntoCSList([d,c,b[1]]),g.turnIntoCSList([d,d,l.neg(c)])]),b=g.normalizeMax(b);a.matrix=b;a.dualMatrix=g.transpose(b)};m.TrReflectionL={};m.TrReflectionL.kind="Tr";m.TrReflectionL.signature=["L"];m.TrReflectionL.updatePosition=function(a){var b=l.mult,c=l.realmult,d=l.zero,e=u.csnames[a.args[0]].homog.value,f=e[0],k=e[1],e=e[2],m=b(f,f),n=b(k,k),p=c(-.5,l.sub(m,n)),q=b(f,k),b=g.turnIntoCSList([g.turnIntoCSList([l.neg(p),q,b(f,e)]),g.turnIntoCSList([q,p,b(k,e)]),g.turnIntoCSList([d,d, -c(-.5,l.add(m,n))])]),b=g.normalizeMax(b);a.matrix=b;a.dualMatrix=g.transpose(b)};m.TrReflectionS={};m.TrReflectionS.kind="Tr";m.TrReflectionS.signature=["S"];m.TrReflectionS.updatePosition=m.TrReflectionL.updatePosition;m.TrReflectionC={};m.TrReflectionC.kind="Mt";m.TrReflectionC.signature=["C"];m.TrReflectionC.signatureConstraints=function(a){return"Circle"===u.csnames[a.args[0]].matrix.usage};m.TrReflectionC.updatePosition=function(a){var b=u.csnames[a.args[0]].matrix,c=b.value[0].value[2],d=b.value[1].value[2], -e=l.neg;a.moebius={anti:!0,ar:c,ai:d,br:b.value[2].value[2],bi:l.zero,cr:e(b.value[0].value[0]),ci:l.zero,dr:e(c),di:d};m._helper.moebiusPair(a)};m.TrInverse={};m.TrInverse.kind="Tr";m.TrInverse.signature=["Tr"];m.TrInverse.updatePosition=function(a){var b=u.csnames[a.args[0]];a.dualMatrix=g.transpose(b.matrix);a.matrix=g.transpose(b.dualMatrix)};m.TransformC={};m.TransformC.kind="C";m.TransformC.signature=["Tr","C"];m.TransformC.updatePosition=function(a){var b=u.csnames[a.args[0]].dualMatrix,b= -g.productMM(g.productMM(b,u.csnames[a.args[1]].matrix),g.transpose(b)),b=g.normalizeMax(b);a.matrix=w.withUsage(b,"Conic")};m.TransformArc={};m.TransformArc.kind="C";m.TransformArc.signature=["Tr","C"];m.TransformArc.signatureConstraints=function(a){return u.csnames[a.args[0]].isArc};m.TransformArc.updatePosition=function(a){var b=u.csnames[a.args[0]].matrix,c=u.csnames[a.args[1]],d=c.viaPoint,e=c.endPoint,c=g.normalizeMax(g.productMV(b,c.startPoint)),d=g.normalizeMax(g.productMV(b,d)),b=g.normalizeMax(g.productMV(b, -e));a.startPoint=c;a.viaPoint=d;a.endPoint=b;a.isArc=!0;a.matrix=g.normalizeMax(m._helper.ConicBy5(null,c,d,b,g.ii,g.jj));a.matrix=w.withUsage(a.matrix,"Circle")};m.TransformP={};m.TransformP.kind="P";m.TransformP.signature=["Tr","P"];m.TransformP.updatePosition=function(a){a.homog=g.normalizeMax(g.productMV(u.csnames[a.args[0]].matrix,u.csnames[a.args[1]].homog));a.homog=w.withUsage(a.homog,"Point")};m.TransformL={};m.TransformL.kind="L";m.TransformL.signature=["Tr","L"];m.TransformL.updatePosition= -function(a){a.homog=g.normalizeMax(g.productMV(u.csnames[a.args[0]].dualMatrix,u.csnames[a.args[1]].homog));a.homog=w.withUsage(a.homog,"Line")};m.TransformS={};m.TransformS.kind="S";m.TransformS.signature=["Tr","S"];m.TransformS.updatePosition=function(a){var b=u.csnames[a.args[0]],c=u.csnames[a.args[1]];m.Segment.setSegmentPos(a,g.productMV(b.dualMatrix,c.homog),g.productMV(b.matrix,c.startpos),g.productMV(b.matrix,c.endpos))};m.TransformPolygon={};m.TransformPolygon.kind="Poly";m.TransformPolygon.signature= -["Tr","Poly"];m.TransformPolygon.updatePosition=function(a){var b=u.csnames[a.args[0]].matrix;a.vertices=g.turnIntoCSList(u.csnames[a.args[1]].vertices.value.map(function(a){a=g.normalizeMax(g.productMV(b,a));return a=w.withUsage(a,"Point")}))};m._helper.pointReflection=function(a,b){return g.normalizeMax(g.sub(g.scalmult(l.realmult(2,b.value[2]),a),g.scalmult(a.value[2],b)))};m._helper.conicOtherIntersection=function(a,b,c){var d=g.productMV(a,c);a=g.scalproduct(c,d);d=g.scalproduct(b,d);d=l.realmult(-2, -d);b=g.scalmult(a,b);c=g.scalmult(d,c);c=g.add(b,c);return c=g.normalizeMax(c)};m.Dist={};m.Dist.kind="V";m.Dist.signature=["P","P"];m.Dist.updatePosition=function(a){var b=u.csnames[a.args[1]].homog;a.value=g.abs(g.sub(g.normalizeZ(u.csnames[a.args[0]].homog),g.normalizeZ(b)))};m.Angle={};m.Angle.kind="V";m.Angle.signature=["L","L","P"];m.Angle.initialize=function(a){void 0===a.angle&&(a.angle=.5*Math.PI);Va(l._helper.input(a.angle))};m.Angle.updatePosition=function(a){var b=u.csnames[a.args[1]].homog, -c=u.csnames[a.args[2]].homog,d=g.cross(u.csnames[a.args[0]].homog,g.linfty),b=g.cross(b,g.linfty),c=g.crossratio3(d,b,g.ii,g.jj,c),c=l.mult(l.complex(0,.5),l.log(c)),d=(wb().value.real-c.value.real)/Math.PI,b=Math.round(d);!fb&&.01<Math.abs(b-d)&&Vb();c=l.complex(b*Math.PI+c.value.real,c.value.imag);Va(c);a.value=w.withUsage(c,"Angle")};m.Angle.stateSize=2;m.Text={};m.Text.kind="Text";m.Text.signature="**";m.Text.isMovable=!0;m.Text.updatePosition=Pa;m.Text.initialize=function(a){a.text=String(a.text); -a.pos&&(a.homog=m._helper.initializePoint(a));a.dock&&(a.dock.offset=a.dock.offset&&2===a.dock.offset.length?g.realVector([+a.dock.offset[0],+a.dock.offset[1]]):g.realVector([0,0]))};m.Text.getParamForInput=function(a,b,c){return m.Free.getParamForInput(a,b,c)};m.Text.getParamFromState=function(a){return a.homog};m.Text.putParamToState=function(a,b){a.homog=b};m.Calculation={};m.Calculation.kind="Text";m.Calculation.signature="**";m.Calculation.isMovable=!0;m.Calculation.updatePosition=Pa;m.Calculation.initialize= -function(a){m.Text.initialize(a);a.calculation=Ra(a.text)};m.Calculation.getText=function(a){return ba(A(a.calculation))};m.Calculation.getParamForInput=m.Text.getParamForInput;m.Calculation.getParamFromState=m.Text.getParamFromState;m.Calculation.putParamToState=m.Text.putParamToState;m.Equation={};m.Equation.kind="Text";m.Equation.isMovable=!0;m.Equation.signature="**";m.Equation.updatePosition=Pa;m.Equation.initialize=function(a){m.Text.initialize(a);a.calculation=Ra(a.text)};m.Equation.getText= -function(a){return a.text+" = "+ba(A(a.calculation))};m.Equation.getParamForInput=m.Text.getParamForInput;m.Equation.getParamFromState=m.Text.getParamFromState;m.Equation.putParamToState=m.Text.putParamToState;m.Evaluate={};m.Evaluate.kind="Text";m.Evaluate.isMovable=!0;m.Evaluate.signature="**";m.Evaluate.updatePosition=Pa;m.Evaluate.initialize=function(a){m.Text.initialize(a);a.calculation=Ra(a.text)};m.Evaluate.getText=function(a){A(a.calculation);return a.text};m.Evaluate.getParamForInput=m.Text.getParamForInput; -m.Evaluate.getParamFromState=m.Text.getParamFromState;m.Evaluate.putParamToState=m.Text.putParamToState;m.Plot={};m.Plot.kind="Text";m.Plot.isMovable=!0;m.Plot.signature="**";m.Plot.updatePosition=Pa;m.Plot.initialize=function(a){m.Text.initialize(a);a.calculation=Ra("plot(("+a.text+"))")};m.Plot.getText=function(a){A(a.calculation);return a.text};m.Plot.getParamForInput=m.Text.getParamForInput;m.Plot.getParamFromState=m.Text.getParamFromState;m.Plot.putParamToState=m.Text.putParamToState;m.Button= -{};m.Button.kind="Text";m.Button.signature="**";m.Button.isMovable=!0;m.Button.updatePosition=Pa;m.Button.initialize=function(a){var b=document.createElement("button");yc(a,"click",b)};m.Button.getParamForInput=m.Text.getParamForInput;m.Button.getParamFromState=m.Text.getParamFromState;m.Button.putParamToState=m.Text.putParamToState;m.Button.set_fillcolor=function(a,b){g._helper.isNumberVecN(b,3)&&(a.fillcolor=b.value.map(function(a){return a.value.real}),a.html.style.backgroundColor=x.makeColor(a.fillcolor, -a.fillalpha))};m.ToggleButton={};m.ToggleButton.kind="Text";m.ToggleButton.signature="**";m.ToggleButton.isMovable=!0;m.ToggleButton.updatePosition=Pa;m.ToggleButton.initialize=function(a){var b;b=void 0;void 0===b&&(b="CindyJSid");b+=++Oa;var c=document.createElement("input"),d=document.createElement("label");c.setAttribute("id",b);d.setAttribute("for",b);c.setAttribute("type","checkbox");a.pressed&&(c.checked=!0);a.checkbox=c;yc(a,"change",c,d)};m.ToggleButton.getParamForInput=m.Text.getParamForInput; -m.ToggleButton.getParamFromState=m.Text.getParamFromState;m.ToggleButton.putParamToState=m.Text.putParamToState;m.ToggleButton.set_fillcolor=m.Button.set_fillcolor;m.EditableText={};m.EditableText.kind="Text";m.EditableText.isMovable=!0;m.EditableText.signature=[];m.EditableText.updatePosition=Pa;m.EditableText.initialize=function(a){var b=document.createElement("input");b.setAttribute("type","text");b.className="CindyJS-editabletext";Fa(a.minwidth)&&(b.style.width=a.minwidth-3+"px");"string"===typeof a.text&& -(b.value=a.text);b.addEventListener("keydown",function(a){13===a.keyCode&&b.blur()});yc(a,"change",b)};m.EditableText.getText=function(a){return!1};m.EditableText.getParamForInput=m.Text.getParamForInput;m.EditableText.getParamFromState=m.Text.getParamFromState;m.EditableText.putParamToState=m.Text.putParamToState;m.EditableText.set_fillcolor=m.Button.set_fillcolor;m.EditableText.get_currenttext=function(a){return w.string(String(a.html.value))};m.EditableText.set_currenttext=function(a,b){a.html.value= -ba(b)};m.EditableText.get_text=m.EditableText.get_currenttext;m.EditableText.set_text=m.EditableText.set_currenttext;m._helper.initializePoint=function(a){var b=0,c=0,d=0;if(a.pos){if("list"===a.pos.ctype&&g.isNumberVector(a.pos))return a.pos;2===a.pos.length&&(b=a.pos[0],c=a.pos[1],d=1);3===a.pos.length&&(b=a.pos[0],c=a.pos[1],d=a.pos[2])}a=g.turnIntoCSList([l._helper.input(b),l._helper.input(c),l._helper.input(d)]);return a=g.normalizeMax(a)};m._helper.initializeLine=function(a){var b=0,c=0,d=0; -if(a.pos){if("list"===a.pos.ctype&&g.isNumberVector(a.pos))return a.pos;3===a.pos.length&&(b=a.pos[0],c=a.pos[1],d=a.pos[2])}a=g.turnIntoCSList([l._helper.input(b),l._helper.input(c),l._helper.input(d)]);return a=g.normalizeMax(a)};m.Poly={};m.Poly.kind="Poly";m.Poly.signature="P*";m.Poly.updatePosition=function(a){a.vertices=g.turnIntoCSList(a.args.map(function(a){return u.csnames[a].homog}))};var tc={CircleByRadius:"CircleMr",IntersectionCircleCircle:"IntersectCirCir",IntersectionConicConic:"IntersectConicConic", -FreePoint:"Free",Orthogonal:"Perp",Parallel:"Para",Pole:"PolarOfLine",Polar:"PolarOfPoint",Arc:"ArcBy3",EuclideanMid:"Mid",AngularBisector:"AngleBisector",TransformConic:"TransformC",TransformSegment:"TransformS",TrMoebiusSegment:"TrMoebiusS",ReflectCC:"TrMoebiusC",ReflectCL:"TrMoebiusL",ReflectCP:"TrMoebiusP",ReflectCArc:"TrMoebiusArc",ReflectCS:"TrMoebiusS",TrMoebiusCircle:"TrMoebiusC"},rd={CircleMFixedr:function(a){a.pinned=!0;a.type="CircleMr";return[a]},CircleByFixedRadius:function(a){a.pinned= -!0;a.type="CircleMr";return[a]},IntersectionConicLine:function(a){a.args=[a.args[1],a.args[0]];a.type="IntersectLC";return[a]},angleBisector:function(a){var b={name:a.name+"_Intersection",type:"Meet",args:a.args,visible:!1};a.type="AngleBisector";a.args=[a.args[0],a.args[1],b.name];return[b,a]},Transform:function(a){var b=u.csnames[a.args[1]],b={Tr:"Transform",Mt:"TrMoebius"}[u.csnames[a.args[0]].kind]+(b.isArc?"Arc":b.kind);if(m.hasOwnProperty(b))return a.type=b,[a];console.log(b+" not implemented yet"); -return[]},TrReflection:function(a){var b="TrReflection"+u.csnames[a.args[0]].kind;if(m.hasOwnProperty(b))return a.type=b,[a];console.log(b+" not implemented yet");return[]}},le="align alpha angle args arrow arrowposition arrowshape arrowsides arrowsize clip color dashtype drawtrace fillalpha fillcolor filled labeled labelpos name overhang pinned printname radius size text text_fontfamily textbold textitalics textsize tracedim tracelength traceskip tracing type visible".split(" ");oa.saveState=function(){return{geometry:me()}}; -var ra={},Jd,Ib,Kd,Ld;Jd=[[],[.2],[.075,.225],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]];Ib=[0,.2,.3,.8,8/9,1,1];Kd=[35/384,0,500/1113,125/192,-2187/6784,11/84,0];Ld=[5179/57600,0,7571/16695,.6140625,-92097/339200,187/2100,.025];var Ba,ga=[],zc=[],ic=!1;ra.tick=function(a){a/=Mb;for(var b=0;b<Mb;b++)ra.tick1(a),Cb+=a,A(S.simulationstep)};ra.tick1=function(a){for(var b=a,c=0;0<a&&c< -.999*a||0>a&&c>.999*a;)b=ra.oneRKStep(b),c+=b,b=Math.min(2*b,a-c),b=Math.max(b,1E-16),ra.restorePosition(),ra.doCollisions(),ra.calculateForces(),ra.moveToFinalPos();return!0};ra.restorePosition=function(){Ba.forEach(function(a){O[a.type].restorePos(a,9)})};ra.doCollisions=function(){Ba.forEach(function(a){O[a.type].doCollisions(a)})};ra.calculateForces=function(){Ba.forEach(function(a){O[a.type].calculateForces(a)})};ra.moveToFinalPos=function(){Ba.forEach(function(a){O[a.type].move(a)})};ra.oneRKStep= -function(a){for(var b=function(a){Ba.forEach(function(b){O[b.type].initRK(b,a);O[b.type].storePosition(b)})},c=function(a){Ba.forEach(function(b){O[b.type].setToTimestep(b,Ib[a])})},d=function(a){Ba.forEach(function(b){O[b.type].proceedMotion(b,Ib[a],a,Jd[a])})},e=function(){Ba.forEach(function(a){O[a.type].resetForces(a)})},f=function(a){Ba.forEach(function(b){O[b.type].calculateDelta(b,a)})},g=function(b){var c=0;Ba.forEach(function(a){O[a.type].proceedMotion(a,Ib[6],7,Kd);O[a.type].savePos(a,8); -O[a.type].proceedMotion(a,Ib[6],7,Ld);O[a.type].savePos(a,9);c+=O[a.type].sqDist(a,8,9)});return c=Math.sqrt(c)/a},k=function(a){Ba.forEach(function(a){O[a.type].recallPosition(a)})},l=!1;!l;){b(a);for(var m=0;7>m;m++)c(m),d(m),e(),ra.calculateForces(),f(m);g(a)>O.env.errorbound&&a>O.env.lowestdeltat?(a/=O.env.slowdownfactor,k()):l=!0}return a};var O={Mass:{reset:function(a,b){a.vel=[0,0,0];a.pos=[0,0,0,0];a.el=b;"undefined"===typeof a.mass&&(a.mass=1);"undefined"===typeof a.charge&&(a.charge=0); -"undefined"===typeof a.friction&&(a.friction=0);a.lnfrict=0;"undefined"===typeof a.limitspeed&&(a.limitspeed=!1);"undefined"===typeof a.fixed&&(a.fixed=!1);"undefined"===typeof a.radius&&(a.radius=1);a.internalmove=!1;a.fx=0;a.fy=0;a.fz=0;a.vx=a.vx||0;a.vy=a.vy||0;a.vz=a.vz||0;a.mtype=0;a.env=O.env;a.deltat=0;a.mx=0;a.my=0;a.mz=0;a.mvx=0;a.mvy=0;a.mvz=0;a.dx=[0,0,0,0,0,0,0,0,0,0];a.dy=[0,0,0,0,0,0,0,0,0,0];a.dz=[0,0,0,0,0,0,0,0,0,0];a.dvx=[0,0,0,0,0,0,0,0,0,0];a.dvy=[0,0,0,0,0,0,0,0,0,0];a.dvz=[0, -0,0,0,0,0,0,0,0,0];a.midx=0;a.midy=0;a.midz=0;a.lx=0;a.ly=0;a.lz=0},resetForces:function(a){a.fx=0;a.fy=0;a.fz=0},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){var c=D.extractPoint(a.el.homog);a.x=c.x;a.y=c.y;a.z=0;a.xo=a.x;a.yo=a.y;a.zo=a.z;a.vxo=a.vx;a.vyo=a.vy;a.vzo=a.vz;a.deltat=b;a.fx=0;a.fy=0;a.fz=0},setVelocity:function(a,b,c,d){d||(d=0);a.vx=b;a.vy=c;a.vz=d},move:function(a){a.pos=[a.x,a.y,1];a.internalmove=!0;fa&&X.down&&a.el===fa.mover||Ia(a.el,g.realVector(a.pos),"homog"); -a.el.sx=a.x;a.el.sy=a.y;a.internalmove=!1},proceedMotion:function(a,b,c,d){if(!a.fixed)for(a.x=a.mx,a.y=a.my,a.z=a.mz,a.vx=a.mvx,a.vy=a.mvy,a.vz=a.mvz,b=0;b<c;b++)a.x+=d[b]*a.dx[b]*a.deltat,a.y+=d[b]*a.dy[b]*a.deltat,a.z+=d[b]*a.dz[b]*a.deltat,a.vx+=d[b]*a.dvx[b]*a.deltat,a.vy+=d[b]*a.dvy[b]*a.deltat,a.vz+=d[b]*a.dvz[b]*a.deltat},calculateForces:function(a){var b=Math.sqrt(a.vx*a.vx+a.vy*a.vy+a.vz*a.vz);a.lnfrict=-Math.log((1-a.friction)*(1-a.env.friction)*(.1<b&&a.limitSpeed?.1/b:1));a.fx+=-a.vx* -a.lnfrict*a.mass;a.fy+=-a.vy*a.lnfrict*a.mass;a.fz+=-a.vz*a.lnfrict*a.mass},calculateDelta:function(a,b){a.dx[b]=a.vx;a.dy[b]=a.vy;a.dz[b]=a.vz;a.dvx[b]=a.fx/a.mass;a.dvy[b]=a.fy/a.mass;a.dvz[b]=a.fz/a.mass},savePos:function(a,b){a.dx[b]=a.x;a.dy[b]=a.y;a.dz[b]=a.z;a.dvx[b]=a.vx;a.dvy[b]=a.vy;a.dvz[b]=a.vz},restorePos:function(a,b){a.fixed||(a.x=a.dx[b],a.y=a.dy[b],a.z=a.dz[b],a.vx=a.dvx[b],a.vy=a.dvy[b],a.vz=a.dvz[b])},sqDist:function(a,b,c){var d=(a.dx[b]-a.dx[c])*(a.dx[b]-a.dx[c]),d=d+(a.dy[b]- -a.dy[c])*(a.dy[b]-a.dy[c]),d=d+(a.dz[b]-a.dz[c])*(a.dz[b]-a.dz[c]),d=d+(a.dvx[b]-a.dvx[c])*(a.dvx[b]-a.dvx[c]),d=d+(a.dvy[b]-a.dvy[c])*(a.dvy[b]-a.dvy[c]);return d+=(a.dvz[b]-a.dvz[c])*(a.dvz[b]-a.dvz[c])},kineticEnergy:function(a){return.5*a.mass*(a.vx*a.vx+a.vy*a.vy+a.vz*a.vz)},storePosition:function(a){a.mx=a.x;a.my=a.y;a.mz=a.z;a.mvx=a.vx;a.mvy=a.vy;a.mvz=a.vz},recallPosition:function(a){a.fixed||(a.x=a.mx,a.y=a.my,a.z=a.mz,a.vx=a.mvx,a.vy=a.mvy,a.vz=a.mvz)},doCollisions:function(a){}},Sun:{reset:function(a, -b){a.vel=[0,0,0];a.pos=[0,0,0,0];a.el=b;"undefined"===typeof a.mass&&(a.mass=10);"undefined"===typeof a.friction&&(a.friction=0);a.charge=0;a.x=0;a.y=0;a.z=0},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){var c=D.extractPoint(a.el.homog);a.x=c.x;a.y=c.y;a.z=0},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateDelta:function(a,b){},calculateForces:function(a){for(var b=a.x,c=a.y,d=a.z,e=0;e<ga.length;e++){var f= -ga[e],g=f.behavior.x,k=f.behavior.y,l=f.behavior.z,m=Math.sqrt((b-g)*(b-g)+(c-k)*(c-k)+(d-l)*(d-l)),k=(c-k)*a.mass*f.behavior.mass/(m*m*m),l=(d-l)*a.mass*f.behavior.mass/(m*m*m);f.behavior.fx+=(b-g)*a.mass*f.behavior.mass/(m*m*m)*f.behavior.mass;f.behavior.fy+=k*f.behavior.mass;f.behavior.fz+=l*f.behavior.mass}},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}}, -Velocity:{reset:function(a){var b=u.csnames[a.geo[1]];console.log(b);var c=D.extractPoint(b.homog);a=D.extractPoint(u.csnames[a.geo[2]].homog);b=b.behavior;O[b.type].setVelocity(b,a.x-c.x,a.y-c.y,0)},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){var b=u.csnames[a.geo[2]];if(!fa||!X.down||b!==fa.mover){var c=u.csnames[a.geo[1]];a=D.extractPoint(c.homog);c=c.behavior;a=g.realVector([a.x+c.vx,a.y+c.vy,1]); -Ia(b,a,"homog")}},proceedMotion:function(a,b,c,d){},calculateForces:function(a){},calculateDelta:function(a,b){},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}},Gravity:{reset:function(a,b){a.vel=[0,0,0];a.pos=[0,0,0,0];a.el=b;"undefined"===typeof a.strength&&(a.strength=1);a.namea=b.args[0];a.nameb=b.args[1];a.ma=u.csnames[a.namea];a.mb=u.csnames[a.nameb]}, -resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateDelta:function(a,b){},calculateForces:function(a){var b=D.extractPoint(a.ma.homog),c=D.extractPoint(a.mb.homog),d=(c.x-b.x)*a.strength;a=(c.y-b.y)*a.strength;for(b=0;b<ga.length;b++)c=ga[b],c.behavior.fx+=d*c.behavior.mass,c.behavior.fy+=a*c.behavior.mass,c.behavior.fz+=0*c.behavior.mass},savePos:function(a,b){}, -restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}},Spring:{reset:function(a,b){a.el=b;"undefined"===typeof a.strength&&(a.strength=1);"undefined"===typeof a.amplitude&&(a.amplitude=0);"undefined"===typeof a.phase&&(a.phase=0);"undefined"===typeof a.speed&&(a.speed=1);"undefined"===typeof a.l0&&(a.l0=0);"undefined"===typeof a.stype&&(a.stype=1);"undefined"===typeof a.readOnInit&& -(a.readOnInit=!1);a.namea=b.args[0];a.nameb=b.args[1];a.ma=u.csnames[a.namea];a.mb=u.csnames[a.nameb];var c=D.extractPoint(a.ma.homog),d=D.extractPoint(a.mb.homog);a.l0=Math.sqrt((c.x-d.x)*(c.x-d.x)+(c.y-d.y)*(c.y-d.y));a.env=O.env},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateForces:function(a){var b,c,d,e;!a.ma.behavior||fa&&X.down&&a.ma===fa.mover?(c=D.extractPoint(a.ma.homog), -b=c.x,d=c.y):(b=a.ma.behavior.x,d=a.ma.behavior.y);!a.mb.behavior||fa&&X.down&&a.mb===fa.mover?(e=D.extractPoint(a.mb.homog),c=e.x,e=e.y):(c=a.mb.behavior.x,e=a.mb.behavior.y);var f=Math.sqrt((b-c)*(b-c)+(d-e)*(d-e)),g=a.l0,k=a.stype;1===k&&(g=0);var l=0;if(2===k||3===k)l=a.ma.behavior.mass*a.mb.behavior.mass*a.strength;2===k&&(l=-l);var m,n;if(0===f||0!==k&&1!==k)if(a.ma.behavior&&a.mb.behavior&&0!==f){if(f*=f*f,2===k||3===k)m=(b-c)*l/f,n=(d-e)*l/f}else m=n=0;else m=-(b-c)*a.strength*(f-g)/f*a.env.springstrength, -n=-(d-e)*a.strength*(f-g)/f*a.env.springstrength;a.ma.behavior&&(a.ma.behavior.fx+=m,a.ma.behavior.fy+=n);a.mb.behavior&&(a.mb.behavior.fx-=m,a.mb.behavior.fy-=n)},calculateDelta:function(a,b){},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}},det:function(a,b,c,d,e,f){return c*f-e*d+e*b-a*f+a*d-c*b},Bouncer:{reset:function(a,b){a.el=b;"undefined"===typeof a.xdamp&& -(a.xdamp=0);"undefined"===typeof a.ydamp&&(a.ydamp=0);"undefined"===typeof a.motorchanger&&(a.motorchanger=!0);a.namea=b.args[0];a.nameb=b.args[1];a.ma=u.csnames[a.namea];a.mb=u.csnames[a.nameb];var c=D.extractPoint(a.ma.homog),d=D.extractPoint(a.mb.homog);a.x1o=1.01*c.x-.01*d.x;a.y1o=1.01*c.y-.01*d.y;a.x2o=1.01*d.x-.01*c.x;a.y2o=1.01*d.y-.01*c.y;a.env=O.env},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){a.deltat=b},setVelocity:function(a,b,c,d){},move:function(a){}, -proceedMotion:function(a,b,c,d){},calculateForces:function(a){},calculateDelta:function(a,b){},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){for(var b=D.extractPoint(a.ma.homog),c=D.extractPoint(a.mb.homog),d=b.x,b=b.y,e=c.x,c=c.y,f=a.x1o,g=a.y1o,k=a.x2o,m=a.y2o,n=Math.sqrt((d-e)*(d-e)+(b-c)*(b-c)),p=(d-e)/n,n=(b-c)/n,q=0;q<ga.length;q++){var t=ga[q], -u=t.behavior.xo,v=t.behavior.yo,w=t.behavior.x,x=t.behavior.y,y=l.mult(l.complex(f,g),l.complex(e,c)),z=l.mult(l.complex(k,m),l.complex(d,b)),y=l.sub(y,z),z=l.mult(l.complex(u,v),l.complex(d,b)),y=l.add(y,z),z=l.mult(l.complex(u,v),l.complex(e,c)),y=l.sub(y,z),z=l.sub(l.complex(f,g),l.complex(k,m)),y=l.div(y,z);0>O.det(d,b,e,c,w,x)*O.det(d,b,e,c,y.value.real,y.value.imag)&&0>O.det(d,b,w,x,y.value.real,y.value.imag)*O.det(e,c,w,x,y.value.real,y.value.imag)&&(v=t.behavior.mvx+a.deltat*(-y.value.real+ -t.behavior.xo),w=t.behavior.mvy+a.deltat*(-y.value.imag+t.behavior.yo),u=p*v+n*w,v=n*v-p*w,t.behavior.x=y.value.real,t.behavior.y=y.value.imag,t.behavior.vx=p*u*(1-a.xdamp),t.behavior.vy=n*u*(1-a.xdamp),t.behavior.vx+=-n*v*(1-a.ydamp),t.behavior.vy+=p*v*(1-a.ydamp))}a.x1o=d;a.y1o=b;a.x2o=e;a.y2o=c}},Environment:{init:function(a){"undefined"===typeof a.gravity&&(a.gravity=0);"undefined"===typeof a.friction&&(a.friction=0);"undefined"===typeof a.springstrength&&(a.springstrength=1);"undefined"!==typeof a.accuracy&& -(Mb=a.accuracy);"undefined"!==typeof a.deltat&&sa(a.deltat/.6);"undefined"===typeof a.charges&&(a.charges=!1);"undefined"===typeof a.balls&&(a.balls=!1);"undefined"===typeof a.newton&&(a.newton=!1);"undefined"===typeof a.ballInteractionBoosting&&(a.ballInteractionBoosting=1);O.env=a;a.errorbound=.001;a.lowestdeltat=1E-7;a.slowdownfactor=2},reset:function(a){},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){}, -proceedMotion:function(a,b,c,d){},calculateForces:function(a){var b,c,d,e,f,g,k,l,m,n;if(a.newton)for(b=0;b<ga.length-1;b++)for(c=ga[b],d=c.behavior.x,e=c.behavior.y,f=b+1;f<ga.length;f++)g=ga[f],k=g.behavior.x,l=g.behavior.y,n=Math.sqrt((d-k)*(d-k)+(e-l)*(e-l)),k=(d-k)*c.behavior.mass*g.behavior.mass/(n*n*n),l=(e-l)*c.behavior.mass*g.behavior.mass/(n*n*n),c.behavior.fx-=k,c.behavior.fy-=l,g.behavior.fx+=k,g.behavior.fy+=l;if(a.charges)for(b=0;b<ga.length-1;b++)for(c=ga[b],d=c.behavior.x,e=c.behavior.y, -f=b+1;f<ga.length;f++)g=ga[f],k=g.behavior.x,l=g.behavior.y,n=Math.sqrt((d-k)*(d-k)+(e-l)*(e-l)),k=(d-k)*c.behavior.charge*g.behavior.charge/(n*n*n),l=(e-l)*c.behavior.charge*g.behavior.charge/(n*n*n),c.behavior.fx+=k,c.behavior.fy+=l,g.behavior.fx-=k,g.behavior.fy-=l;if(a.balls)for(b=0;b<ga.length-1;b++)if(c=ga[b],0!==c.behavior.radius)for(d=c.behavior.x,e=c.behavior.y,f=b+1;f<ga.length;f++)g=ga[f],0!==g.behavior.radius&&(k=g.behavior.x,l=g.behavior.y,m=c.behavior.radius+g.behavior.radius,n=Math.sqrt((d- -k)*(d-k)+(e-l)*(e-l)),0===a.ballInteractionBoosting?(k=(d-k)/(n*n*n)*(n>m?0:(n-m)*(n-m)),l=(e-l)/(n*n*n)*(n>m?0:(n-m)*(n-m))):1===a.ballInteractionBoosting?(k=(d-k)/(n*n*n*n)*(n>m?0:(n-m)*(n-m)),l=(e-l)/(n*n*n*n)*(n>m?0:(n-m)*(n-m))):(k=(d-k)/(n*n*n*n*n)*(n>m?0:(n-m)*(n-m)),l=(e-l)/(n*n*n*n*n)*(n>m?0:(n-m)*(n-m))),c.behavior.fx+=k,c.behavior.fy+=l,g.behavior.fx-=k,g.behavior.fy-=l);for(b=0;b<ga.length;b++)c=ga[b],c.behavior.fx+=0,c.behavior.fy+=-a.gravity*c.behavior.mass,c.behavior.fz+=0},calculateDelta:function(a, -b){},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}}};return oa};return E}(),createCindy=CindyJS;"undefined"!==typeof process&&"undefined"!==typeof module&&"undefined"!==typeof module.exports&&"undefined"===typeof window&&(module.exports=CindyJS); -//# sourceMappingURL=Cindy.js.map diff --git a/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/CindyJS.css b/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/CindyJS.css deleted file mode 100644 index 2fdefb34c40..00000000000 --- a/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/CindyJS.css +++ /dev/null @@ -1,121 +0,0 @@ -.CindyJS-toolbar button, .CindyJS-animbuttons button, .CindyJS-button button, .CindyJS-button label { - background-color: #bfc4d0; - border: 1px solid #d0d0d0; - box-shadow: inset 1px 1px 2px #fff, inset -1px -1px 2px #aaa; - outline: none; } - -.CindyJS-toolbar button:active, .CindyJS-animbuttons button:active, .CindyJS-toolbar button.CindyJS-active, .CindyJS-animbuttons button.CindyJS-active, .CindyJS-button button:active, .CindyJS-button label:active, .CindyJS-button input[type=checkbox]:checked + label { - background-color: #aaafbb; - box-shadow: inset 1px 1px 2px #999, inset -1px -1px 2px #ccc; } - -.CindyJS-toolbar, .CindyJS-animbuttons { - line-height: 0px; } - .CindyJS-toolbar button, .CindyJS-animbuttons button { - display: inline-block; - margin: 0px; - padding: 0px; } - .CindyJS-toolbar button:focus, .CindyJS-animbuttons button:focus { - border-color: #06f; } - .CindyJS-toolbar img, .CindyJS-animbuttons img { - margin: 0px; - border: none; - display: block; } - -.CindyJS-widget { - overflow: hidden; - z-index: 0; } - .CindyJS-widget canvas { - z-index: 1; } - .CindyJS-widget .CindyJS-baseline { - margin: 0px; - padding: 0px; - border: none; - position: absolute; - white-space: nowrap; - margin-top: -1000px; } - .CindyJS-widget .CindyJS-baseline > img { - margin: 0px; - padding: 0px; - border: none; - display: inline; - position: static; - vertical-align: baseline; - visibility: hidden; - margin-right: -1px; } - .CindyJS-widget .CindyJS-baseline .CindyJS-button { - display: inline-block; } - .CindyJS-widget .CindyJS-button { - position: relative; - z-index: 2; } - .CindyJS-widget .CindyJS-toolbar, .CindyJS-widget .CindyJS-animbuttons { - position: absolute; } - .CindyJS-widget .CindyJS-toolbar button, .CindyJS-widget .CindyJS-animbuttons button { - position: relative; - z-index: 3; } - .CindyJS-widget .CindyJS-animspeed { - position: relative; - z-index: 3; } - .CindyJS-widget .CindyJS-animcontrols { - bottom: 5px; - left: 5px; } - -.CindyJS-button input[type=checkbox] { - position: absolute; - left: -10000px; } - -.CindyJS-button button, .CindyJS-button label { - margin: -6px -7px; - padding: 5px 6px; - border-radius: 4px; } - -.CindyJS-button button:focus, .CindyJS-button input[type=checkbox]:focus + label { - box-shadow: 0px 0px 3px #06f, inset 1px 1px 2px #fff, inset -1px -1px 2px #aaa; } - -.CindyJS-button button:focus:active, .CindyJS-button input[type=checkbox]:focus:checked + label { - background-color: #aaafbb; - box-shadow: 0px 0px 3px #06f, inset 1px 1px 2px #999, inset -1px -1px 2px #ccc; } - -.CindyJS-editabletext { - border: 1px solid #000; - margin: -4px -4px -1px; - padding: 4px 4px 1px; } - .CindyJS-editabletext:focus { - box-shadow: 0px 0px 3px #06f; } - -.CindyJS-toolbar div { - line-height: 0px; } - -.CindyJS-toolbar span.CindyJS-spacer { - display: inline-block; - margin: 0px; - padding: 1px; - width: 32px; - height: 24px; } - -.CindyJS-animcontrols { - position: absolute; - background-color: #00f; - height: 36px; - width: 102px; } - .CindyJS-animcontrols .CindyJS-animspeed { - height: 10px; - width: 100%; - border-radius: 4px; - background-color: #ff7f7f; - box-shadow: inset 1px 1px 2px #999, inset -1px -1px 2px #ccc; } - .CindyJS-animcontrols .CindyJS-animspeed div { - width: 50%; - height: 100%; - border-radius: 4px; - background-color: #cc0000; - box-shadow: inset 1px 1px 2px #fff, inset -1px -1px 2px #aaa; } - .CindyJS-animcontrols .CindyJS-animbuttons { - white-space: nowrap; } - -.CindyJS-animbuttons button { - border-radius: 4px; - width: 34px; - height: 26px; - box-sizing: border-box; } - -/*# sourceMappingURL=CindyJS.css.map */
\ No newline at end of file diff --git a/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/ketcindylib.txt b/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/ketcindylib.txt deleted file mode 100644 index 72469da831a..00000000000 --- a/Master/texmf-dist/doc/support/ketcindy/ketmanual/CindyJS/ketcindylib.txt +++ /dev/null @@ -1,6419 +0,0 @@ -// 17.08.26 Slider -// 16.11.27 -Ketinit():=Ketinit(1); -Ketinit(sy):=Ketinit(sy,[-5,5],[-5,5]); -Ketinit(sy,rangex,rangey):=( - regional(pt,tmp,tmp1,tmp2); - PenThickInit=8; - ULEN="1cm"; - KETPICLAYER=20; - MilliIn=1/2.54*1000; - PenThick=round(MilliIn*0.02); - PenThickInit=PenThick; - TenSizeInit=0.02; - TenSize=TenSizeInit; - YaSize=1; YaAngle=18; YaPosition=1; - YaThick=1; YaStyle='tf'; - KETPICCOUNT=1; - KCOLOR=[0,0,0]; - GLIST=[]; - GCLIST=[]; -// GDATALIST=[]; - GOUTLIST=[]; - POUTLIST=[]; - VLIST=[]; - FUNLIST=[]; - LETTERlist=[]; - COM0thlist=[]; - COM1stlist=[]; - COM2ndlist=[]; - SCIWRLIST=[]; - SCIRELIST=[]; - ADDAXES="1"; - LFmark=unicode("000a"); - Dq=unicode("0022"); - WaitUnit=10; - CONTINUED=0; - OutComList=[]; - OutFileLIst=[]; // 15.10.22 - FigPdfList=[]; // 16.04.08 - ADDPACK=[]; // 16.05.16 - ErrFlag=0; - setdirectory(Dirwork); - if(isstring(Fhead), // 15.04.06 - Fnametex=Fhead+".tex"; - Fnamesci=Fhead+".sce"; - Fnamescibody=Fhead+"body.sce"; - Fnameout=Fhead+".txt"; - ); - if(!isstring(Mackc),// 16.06.07 - Mackc="sh"; - ); - ArrowlineNumber=1; // 15.01.05 - ArrowheadNumber=1; - BezierNumber=1; //15.01.03 - SCALEX=1; - SCALEY=sy; -// Setscaling(sy); - XMIN=rangex_1/SCALEX; - XMAX=rangex_2/SCALEX; - YMIN=rangey_1/SCALEY; - YMAX=rangey_2/SCALEY; - Setwindow("Msg=n"); // 16.05.31 -); - -DqDq(str):=unicode("0022")+str+unicode("0022"); - -Tab2list(dtstr):=Tab2list(dtstr,[]); -Tab2list(dtstr,options):=( -//help:Tab2list(datastr); -//help:Tab2list(options=[0]); - regional(dtall,dt,rep,out,crm,lfm,htm,first,tmp,tmp1,tmp2); - crm=unicode("000d"); - lfm=unicode("000a"); - htm=unicode("0009"); - rep=0; - if(length(options)>0,rep=options_1); - first=lfm; // 16.09.05from - if(indexof(dtstr,crm)>0, - first=crm; - if(indexof(dtstr,crm+lfm)>0, - first=first+lfm; - ); // 16.09.05upto - ); - tmp1=Indexall(dtstr,first); - tmp1=prepend(0,tmp1); - tmp1=append(tmp1,length(dtstr)); - dtall=[]; - forall(1..(length(tmp1)-1), - tmp=substring(dtstr,tmp1_#,tmp1_(#+1)-1); - if(length(tmp)>0, - dtall=append(dtall,tmp); - ); - ); - out=[]; - forall(dtall,dt, - tmp1=tokenize(dt,unicode("0009")); - tmp2=[]; - forall(tmp1, - if(isstring(#),tmp=parse(#),tmp=#); - if(!isreal(tmp), - if(length(#)>0,tmp=#,tmp=rep); - ); - tmp2=append(tmp2,tmp); - ); - out=append(out,tmp2); - ); - out; -); - -Columnlist(dt,list):=( // 16.09.04 -//help:Columnlist(dt,1..3); - apply(dt,#_list); -); - -Dispmat(dt):=( // 16.09.16 -//help:Dispmat(dt); - regional(htm,crm,lfm,row,tmp,tmp1,tmp2); - htm=unicode("0009"); - crm=unicode("000d"); - lfm=unicode("000a"); - tmp2=""; - forall(dt,row, - tmp1=""; - forall(row, - if(isstring(#), - tmp1=tmp1+#+htm; - , - tmp1=tmp1+text(#)+htm; - ); - ); - tmp1=substring(tmp1,0,length(tmp1)-1); - tmp1=tmp1+lfm; - tmp2=tmp2+tmp1; - ); - print(tmp2); - println(); -); - -norm(v1):=( // 16.09.01 -//help:norm([2,1,3]); - regional(out,tmp,tmp1,tmp2); - out=0; - forall(1..length(v1), - out=out+(v1_#)^2; - ); - out=sqrt(out); - out; -); -norm(v1,v2):=( - norm(v2-v1); -); - -// 16.03.28 -Removespace(str):=( -//help:Removespace(" a b c "); - regional(tmp,flg,out); - tmp=length(str)+1; - flg=0; - forall(1..length(str), - if(flg==0, - if((str_#)!=" ", - tmp=#; - flg=1; - ); - ); - ); - out=substring(str,tmp-1,length(str)); - flg=0; - tmp=0; - forall(reverse(1..length(out)), - if(flg==0, - if((out_#)!=" ", - tmp=#; - flg=1; - ); - ); - ); - out=substring(out,0,tmp); -); - -Indexall(str,key):=( - regional(rest,out,flg,tmp,tmp1,); - out=[]; - rest=str; - flg=0; - forall(1..length(str), - if(flg==0, - tmp=indexof(rest,key); - if(tmp>0, - tmp1=tmp+length(str)-length(rest); - out=append(out,tmp1); - rest=substring(rest,tmp,length(rest)); - , - flg=1; - ); - ); - ); - out; -); - -Changestyle(nameL,style):=( -//help:Changestyle(["sgAB"],["da"]); - regional(nmL,name,Ltype,Ltypeorg,Noflg,opcindy,tmp); - tmp=Divoptions(style); - Ltypeorg=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - if(islist(nameL),nmL=nameL,nmL=[nameL]); - forall(nmL,name, - Ltype=Ltypeorg; - GCLIST=select(GCLIST,#_1!=name); - COM2ndlist=select(COM2ndlist,indexof(#,"("+name)==0); // 15.05.23 - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - ); -); - -Op(n,object):=( // 16.05.25 -//help:Op(4,[1,2,3,4]); -//help:Op(3,"abcd"); - regional(out); - if(islist(object), - out=object_n; - , - if(isstring(object), - out=substring(object,n-1,n); - ); - ); - out; -); - -Toupper(str):=( - regional(alphabet,out,tmp,tmp1); - alphabet="abcdefghijklmnopqrstuvwxyz"; - out=""; - forall(1..length(str), - tmp=substring(str,#-1,#); - tmp1=indexof(alphabet,tmp); - if(tmp1>0, - out=out+unicode(text(tmp1+64),base->10); - , - out=out+tmp; - ); - ); - out; -); - -Textformat(value,dig):=( -//help:Textformat(2/3,4); -//help:Textformat([gr1,gr2],5); - regional(vv,tmp,tmp1); - if(islist(value), - tmp1="["; - forall(value, - tmp1=tmp1+Textformat(#,dig)+","; - ); - tmp1=substring(tmp1,0,length(tmp1)-1)+"]"; - , - if(ispoint(value) % isstring(value), -// vv=Lcrd(value); -// tmp1=Textformat(vv,dig); -// tmp1=text(value); // 15.04.07 - if(isstring(value),tmp1=Dq+value+Dq,tmp1=text(value)); // 15.10.02 - , - tmp1=format(value,dig); - ); - ); - tmp1; -); - -Sprintf(value,dig):=( -//help:Sprintf(5.1,4); - regional(vv,tmp,tmp1); - if(!islist(value), - vv=Textformat(value,dig); - if(indexof(vv,".")==0,vv=vv+"."); - vv=vv+"0000000000000000"; - tmp=indexof(vv,".")+dig; - vv=substring(vv,0,tmp); - , - vv=apply(value,Sprintf(#,dig)); - ); - vv; -); - -Assign(funstr,vrL):=( - regional(nn,out,tmp,tmp1); - nn=length(vrL)/2; - out=funstr; - forall(1..nn, - out=Assign(out,vrL_(2*#-1),vrL_(2*#)); - ); - out; -); - -Assign(funstr,varname,rep):=( -//help:Assign("x^2+a*x","a",1.3); -//help:Assign("a*x^2+b*x",["a",1,"b",2]); - regional(repstr,ii,jj,tmp,tmp1,tmp2,Notvar,Flg); - if(isstring(rep),repstr=rep,repstr="("+Textformat(rep,5)+")"); // 15.02.09, 07.06 - tmp=[46]; // 12.20 - tmp=concat(tmp,48..57); - tmp=concat(tmp,65..90); - tmp=concat(tmp,97..122); - Notvar=apply(tmp,unicode(text(#),base->10)); - tmp2=""; - forall(1..100, - ii=indexof(funstr,varname); - if(ii>0, - Flg=0; - if(ii>1, - tmp=substring(funstr,ii-2,ii-1); - if(contains(Notvar,tmp), - tmp2=tmp2+substring(funstr,0,ii); - funstr=substring(funstr,ii,length(funstr)); - Flg=1; - ); - ); - if(Flg==0, - jj=ii-1+length(varname); - if(jj<length(funstr), - tmp=substring(funstr,jj,jj+1)); - if(contains(Notvar,tmp), - tmp2=tmp2+substring(funstr,0,jj); - funstr=substring(funstr,jj,length(funstr)); - Flg=1; - ); - ); - if(Flg==0, - tmp2=tmp2+substring(funstr,0,ii-1)+repstr; - funstr=substring(funstr,jj,length(funstr)); - ); - ); - ); - funstr=tmp2+funstr; - funstr; -); - -MeasureDepth(list):=( - regional(tmp,Depth,Flg); - Flg=0; - Depth=0; - if(ispoint(list), // 15.01.22 - Depth=0; - Flg=1; - , - tmp=list_1; - ); - repeat(4, - if(Flg==0, - if(islist(tmp), - tmp=tmp_1; - Depth=Depth+1; - , - if(ispoint(tmp),Depth=Depth+1); - Flg=1; - ); - ); - ); - Depth; -); - -Flattenlist(pltlist):=( -//help:Flattenlist([[2,3],[[1,2],[5,6]]]); - regional(Out,nn,Dt,ii,tmp,flg); - Out=[]; - if(MeasureDepth(pltlist)==1, - Out=[pltlist]; - , - forall(1..length(pltlist),nn, - Dt=pltlist_nn; - if(MeasureDepth(Dt)<2, - Out=append(Out,Dt); - , - forall(1..length(Dt),ii, - tmp=Flattenlist(Dt_ii); - Out=concat(Out,tmp); - ); - ); - ); - ); - Out; -); - -Divoptions(options):=( -//help:Divoptions(options); - regional(Ltype,Noflg,Inflg,Outflg,eqL,realL,strL,opstr,opcindy,flg,tmp,tmp1); - Ltype="dr"; // 2015.01.13 - Noflg=0; - Inflg=0; - Outflg=0; - eqL=[]; - realL=[]; - strL=[]; - opstr=""; - opcindy=""; - forall(options, - flg=0; - if(flg==0, - if(isreal(#) % ispoint(#) % islist(#), - realL=append(realL,#); - opstr=opstr+","+text(#); - flg=1; - ); - ); - if(flg==0, - if(indexof(#,"=")>0, - eqL=append(eqL,#); - flg=1; - ); - ); - if(flg==0, - if(indexof(#,"no")+indexof(#,"No")>0, - if(indexof(#,"tex")>0,Noflg=1); - if(indexof(#,"disp")>0,Noflg=2); - if(indexof(#,"data")>0,Noflg=3); - flg=1; - ); - ); - if(flg==0, - if(indexof(#,"->")>0, - opcindy=opcindy+","+#; - flg=1; - ); - ); - if(flg==0, - if(indexof(#,"out")+indexof(#,"Out")>0, - if(indexof(#,"-")==0, - Outflg=1; - , - Outflg=2; - ); - flg=1; - ); - ); - if(flg==0, - if(indexof(#,"in")+indexof(#,"In")>0, - if(indexof(#,"-")==0, - Inflg=1; - , - Inflg=2; - ); - flg=1; - ); - ); - if(flg==0, - tmp=substring(#,0,2); - tmp1=indexof(tmp,"dr")+indexof(tmp,"Dr"); - tmp1=tmp1+indexof(tmp,"da")+indexof(tmp,"Da"); - tmp1=tmp1+indexof(tmp,"id")+indexof(tmp,"Id"); - tmp1=tmp1+indexof(tmp,"do")+indexof(tmp,"Do"); - tmp1=tmp1+indexof(tmp,"dp")+indexof(tmp,"Dp"); - if(tmp1>0, - Ltype=#; - flg=1; - ); - if(flg==0, - strL=append(strL,#); - opstr=opstr+","+Dq+#+Dq; - ); - ); - ); - if(indexof(opcindy,"color->")==0,// 16.10.07from - opcindy=opcindy+",color->[0,0,0]"; - ); - [Ltype,Noflg,Inflg,Outflg,eqL,realL,strL,opstr,opcindy]; -); - -Dotprod(vec1,vec2):=( -//help:Dotprod(vec1,vec2); - regional(v1,v2,tmp); - if(ispoint(vec1),v1=vec1.xy,v1=vec1); - if(ispoint(vec2),v2=vec2.xy,v2=vec2); - v1*v2; -); - -Crossprod(a,b):=( -//help:Crossprod(vec1,vec2); - regional(tmp1,tmp2,tmp3,Out); - if(length(a)==3, - tmp1=a_2*b_3-a_3*b_2; - tmp2=a_3*b_1-a_1*b_3; - tmp3=a_1*b_2-a_2*b_1; - Out=[tmp1,tmp2,tmp3]; - , - Out=a_1*b_2-a_2*b_1; - ); - Out; -); - -Ptstart(Fig):=( -//help:Ptstart("gr1"); - regional(tmp); - if(isstring(Fig),tmp=parse(Fig),tmp=Fig); // 16.01.21 - tmp_1; -); - -Ptend(Fig):=( -//help:Ptend("gr1"); - regional(tmp); - if(isstring(Fig),tmp=parse(Fig),tmp=Fig); - tmp_(length(tmp)); // 15.04.12 -); - -Numptcrv(Fig):=( -//help:Numptcrv("gr1"); - regional(tmp); - if(isstring(Fig),tmp=parse(Fig),tmp=Fig); // 15.12.23 - length(tmp); -); - -Ptcrv(Num,Fig):=( -//help:Ptcrv(10,"gr1"); - regional(tmp); - if(isstring(Fig),tmp=parse(Fig),tmp=Fig); - tmp_Num; -); - -Invert(Fig):=( -//help:Invert("gr1"); - regional(tmp); - if(isstring(Fig),tmp=parse(Fig),tmp=Fig); // 16.01.27 - reverse(tmp); -); -Invert(nm,Fig):=Invert(nm,Fig,["nodisp"]); // from 16.01.27 -Invert(nm,Fig,options):=( -//help:Invert("1","gr1"); - regional(name,tmp); - name="-inv"+nm; - tmp=Invert(Fig); - Listplot(name,tmp,options); -);// upto 16.01.27 - -Paramoncrv(pP,Gdata):=( - regional(Tmp,PtL); -// Eps=10^(-8); - if(isstring(Gdata),PtL=parse(Gdata),PtL=Gdata); - Tmp=Nearestpt(pP,PtL); - Tmp_2; -); - -ParamonCurve(pP,nN,plist):=( -//help:ParamonCurve(A,10,"gr1"); - regional(PtL,Out,Pa,Pb,vV,vW,sS); - if(isstring(plist),PtL=parse(plist),PtL=plist); - PtL=apply(PtL,LLcrd(#));//16.10.16 - if(nN==length(PtL), - Out=nN; - , - Pa=PtL_nN; - Pb=PtL_(nN+1); - vV=Pb-Pa; - vW=pP-Pa; - sS=vV*vW/|vV|^2; - sS=min([max([sS,0]),1]); - Out=nN+sS; - ); - Out; -); - -Pointoncrv(tT,PtL):=PointonCurve(tT,PtL); -PointonCurve(tT,Gdata):=( -//help:PointonCurve(20.5,"gr1"); - regional(Out,Eps,nN,sS,Pa,Pb,PtL); - if(isstring(Gdata),PtL=parse(Gdata),PtL=Gdata); - if(length(PtL)==1,PtL=PtL_1); - Eps=10^(-4); - nN=floor(tT+Eps); - sS=max([tT-nN,0]); - if(nN==length(PtL), - Out=PtL_nN; - , - Pa=PtL_nN; - Pb=PtL_(nN+1); - Out=(1-sS)*Pa+sS*Pb; - ); - Out; -); - -Koutenseg(pA,pB,pC,pD):=Koutenseg(pA,pB,pC,pD,[]); -Koutenseg(pA,pB,pC,pD,options):=( - regional(Eps0,Eps,Eps2,pV,Sv2,Out,pP,pQ,Flg,p1,p2,q1,q2, - em1,eM1,em2,eM2,rT,Tmp1,Tmp2); - Eps0=10^(-4); - pV=pB-pA; - Sv2=|pV|; - pP=pC-pA; pQ=pD-pA; - Eps=10^(-3); - Eps2=0.2; - Tmp1=0; - forall(options, - if(Tmp1==0, - Eps=#; - Tmp1=1; - , - Eps2=#; - ); - ); - Flg=0; - if(Sv2<10^(-3), - Out=["inf","inf"]; - Flg=1; - ); - if(Flg==0, - Eps=min([Eps2,Eps/Sv2]); - p1=pP*pV/Sv2^2; - p2=[pP_2,-pP_1]*pV/Sv2^2; - q1=pQ*pV/Sv2^2; - q2=[pQ_2,-pQ_1]*pV/Sv2^2; - em1=-Eps; eM1=1+Eps; - em2=-Eps; eM2=Eps; - if(max([p1,q1])<em1 % min([p1,q1])>eM1, - Out=["inf","inf"]; - Flg=1; - ); - if(max([p2,q2])<em2 % min([p2,q2])>eM2, - Out=["inf","inf"]; - Flg=1; - ); - ); - if(Flg==0 & p2*q2<0, - rT=p1-(q1-p1)/(q2-p2)*p2; - if(rT>em1 & rT<eM1, - if(rT>-Eps0 & rT<1+Eps0, - Tmp1=pA+rT*pV; - Tmp2=min([max([rT,0]),1]); - Out=[Tmp1,Tmp2,0]; - , - Tmp1=pA+rT*pV; - Tmp2=min([max([rT,0]),1]); - Out=[Tmp1,Tmp2,1]; - ); - Flg=1; - ); - if(Flg==0 & (p1<em1 % p1>eM1 % p2<em2 % p2>eM2), - if(q1<em1 % q1>eM1 % q2<em2 % q2>eM2, - Out=["inf","inf"]; - Flg=1; - ); - if(Flg==0, - rT=min([max([p1,0]),1]); - Tmp1=pA+rT*pV; - Out=[Tmp1,rT,1]; - Flg=1; - ); - ); - ); - if(Flg==0 & (p1 > -Eps0 & p1 < 1 + Eps0 & p2 > -Eps0 & p2 < Eps0), - rT= p1; - Tmp1=pA+rT*pV; - Out= [Tmp1, rT, 0]; - Flg=1; - ); - if(Flg==0 & (q1 > -Eps0 & q1 < 1 + Eps0 & q2 > -Eps0 & q2 < Eps0), - rT= q1; - Tmp1=pA+rT*pV; - Out=[Tmp1,rT,0]; - Flg=1; - ); - if(Flg==0 & (p1<em1 % p1>eM1 % p2<em2 % p2>eM2), - if(q1<em1 % q1>eM1 % q2<em2 % q2>eM2, - Out=["inf","inf"]; - Flg=1; - ); - if(Flg==0, - rT=min([max([q1,0]),1]); - Tmp1=pA+rT*pV; - Out=[Tmp1,rT,1]; - Flg=1; - ); - ); - if(Flg==0 & (q1<em1 % q1>eM1% q2<em2 % q2>eM2), - rT=min([max([p1,0]),1]); - Tmp1=pA+rT*pV; - Out=[Tmp1,rT,1]; - Flg=1; - ); - if(Flg==0, - if(abs(p2)<abs(q2), - rT=min([max([p1,0]),1]); - , - rT=min([max([q1,0]),1]); - ); - Tmp1=pA+rT*pV; - Out=[Tmp1,rT,1]; - ); - Out; -); - -IntersectcrvsPp(Gr1,Gr2):=IntersectcrvsPp(Gr1,Gr2,[]); -IntersectcrvsPp(Gr1,Gr2,options):=( -//help:IntersectcrvsPp("gr1","pa1"); - regional(Out,Eps,Eps2,Eps0,Flg,Data1,Data2, - Tmp1,Tmp2,Tmp3,Tmp,KL1,KL2,pA,pB,Ni,Nj, - pP,pQ,rT,Flg,eqL,realL,opstr,Dif); - Eps=10^(-4); - Eps2=0.1; - Dif=0.05; // 2015.05.31 - Flg=0; - Tmp1=Divoptions(options); // - eqL=Tmp1_5; - realL=Tmp1_6; - opstr=Tmp1_(length(Tmp1)); - forall(eqL, - if(substring(#,0,1)=="D", - Tmp1=indexof(#,"="); - Dif=parse(substring(#,Tmp1,length(#))); - ); - ); - Tmp1=length(realL); - if(Tmp1>0, - Eps=realL_1; - if(Tmp1>1, - Eps2=realL_2; - ); - ); - Flg=0; - if(isstring(Gr1),Data1=parse(Gr1),Data1=Gr1); - if(isstring(Gr2),Data2=parse(Gr2),Data2=Gr2); - if(MeasureDepth(Data1)==2,Data1=Data1_1); - if(MeasureDepth(Data2)==2,Data2=Data2_1); - Data1=apply(Data1,LLcrd(#)); - Data2=apply(Data2,LLcrd(#)); - if(length(Data1)==length(Data2), - Tmp1=Reverse(Data2); - Eps0=10^(-6); - Tmp2=0; - forall(1..length(Data1), - Tmp2=Tmp2+abs(Data1_#-Data2_#); - ); - Tmp3=0; - forall(1..length(Data1), - Tmp3=Tmp3+abs(Data1_#-Tmp1_#); - ); - if(Tmp2<Eps0 % Tmp3<Eps0, - Out=[]; - Flg=1; - ); - ); - if(Flg==0, - KL1=[]; - KL2=[]; - forall(1..(length(Data1)-1),Ni, - pA=Data1_Ni; - pB=Data1_(Ni+1); - forall(1..(length(Data2)-1), - pP=Data2_#; pQ=Data2_(#+1); - Tmp=Koutenseg(pA,pB,pP,pQ,[Eps,Eps2]); - if(Tmp!=["inf","inf"], - if(Tmp_3==0, - Tmp1=[Tmp_1,Tmp_2,Ni,#]; - KL1=concat(KL1,[Tmp1]); - , - Tmp2=[Tmp_1,Tmp_2,Ni,#]; - KL2=concat(KL2,[Tmp2]); - ); - ); - ); - ); - Out=[]; - if(length(KL1)>0, - Tmp=KL1_1; - pP=Tmp_1; - rT=Tmp_2; - Ni=Tmp_3; - Nj=Tmp_4; - Tmp=[pP,Ni+rT,Nj]; - Out=[Tmp]; - ); - forall(2..length(KL1),Ni, - Tmp=KL1_Ni; - pP=Tmp_1; - Tmp2=0; - Flg=0; - forall(1..length(Out),Nj, - if(Flg==0, - Tmp=Out_Nj; - if(|pP-Tmp_1|<Eps, - Tmp2=1; - Flg=1; - ); - ); - ); - if(Tmp2==0, - Tmp=KL1_Ni; - pP=Tmp_1; - rT=Tmp_2; - Tmp1=Tmp_3; - Tmp2=Tmp_4; - Tmp=[pP,Tmp1+rT,Tmp2]; - Out=concat(Out,[Tmp]); - ); - ); - forall(1..length(KL2),Ni, - Tmp=KL2_Ni; // 15.11.21 Usui - pP=Tmp_1; - Tmp2=0; - Flg=0; - forall(1..length(Out),Nj, - if(Flg==0, - Tmp=Out_Nj; - if(|pP-Tmp_1|<Eps, - Tmp2=1; - Flg=1; - ); - ); - ); - if(Tmp2==0, - Tmp=KL2_Ni; - rT=Tmp_2; - rT=min([max([rT,0]),1]); // 15.11.21 Usui - Tmp=[pP,Tmp_3+rT,Tmp_4]; - Out=concat(Out,[Tmp]); - ); - ); - ); - Tmp1=Out; // 15.04.06 from - Out=[]; - forall(Tmp1,Tmp2, - Tmp3=select(1..(length(Out)),|Out_#_1-Tmp2_1|<Dif);//16.11.27 - if(length(Tmp3)==0, - Out=append(Out,Tmp2); - , - forall(Tmp3,//16.11.27 - Out_#=(Out_#+Tmp2)/2; - ); - ); - ); // 15.04.06 upto - Out; -); - -Intersectcrvs(Gr1,Gr2):=Intersectcrvs(Gr1,Gr2,[]); -//help:Intersectcrvs("gr1","pa1"); -Intersectcrvs(Gr1,Gr2,options):=( - regional(tmp,tmp1,tmp2); - tmp1=IntersectcrvsPp(Gr1,Gr2,options); - apply(tmp1,#_1); -); - -NearestptcrvPhy(point,PL):=( - regional(tmp,pP,plist); - pP=Pcrd(point); - if(isstring(PL),plist=parse(PL),plist=PL); - if(MeasureDepth(plist)==2,plist=plist_1); - plist=apply(plist,#); // 14.12.18 - tmp=Nearestpt(pP,plist); - tmp=tmp_1; - [tmp_1/SCALEX,tmp_2/SCALEY]; -); - -Nearestptcrv(point,plist):=( -//help:Nearestptcrv(A,"gr1"); - regional(tmp); - tmp=Nearestpt(point,plist); - tmp_1; -); - -Nearestpt(point,PL2):=( - regional(PL1,PL,Ans,Flg,Eps,pA,Pm,Im,Sm,Nn,Ni, - a1,b1,a2,b2,v1,v2,x1,x2,Tmp,rT,pP,sS,Lm,Pm,Sm,Flg); -//help:Nearestpt("gr1","gr2"); - if(isstring(point),PL1=parse(point),PL1=point); - if(MeasureDepth(PL1)==2,PL1=PL1_1); - if(!islist(PL1_1), - PL1=[PL1]; - Flg=0; - , - Flg=1; - ); - if(isstring(PL2),PL=parse(PL2),PL=PL2); - if(MeasureDepth(PL)==2,PL=PL_1); - Eps=10^(-6); - Ans=[PL1_1,1,PL_1,1,|PL1_1-PL_1|]; - forall(1..length(PL1),Nn, // 16.05.04 - pA=PL1_Nn; - Pm=PL_1; - Im=1; - Sm=|Pm-pA|; - forall(1..(length(PL)-1),Ni, - a1=PL_Ni_1; a2=PL_Ni_2; - b1=PL_(Ni+1)_1; b2=PL_(Ni+1)_2; - v1=b1-a1; v2=b2-a2; - x1=pA_1; x2=pA_2; - Tmp=v2^2+v1^2; - if(abs(Tmp)>Eps, - rT=(-a2*v2-v1*a1+v1*x1+x2*v2)/Tmp; - if(rT<-Eps, - pP=[a1,a2]; - , - if(rT>1+Eps, - pP=[b1,b2]; - , - pP=[a1+rT*v1,a2+rT*v2]; - ); - ); - sS=|pP-pA|; - if(sS<Sm-Eps, - Tmp=ParamonCurve(pP,Ni,PL); - Pm=pP; Lm=Tmp; Sm=sS; - ); - ); - if(Sm<Ans_5, // 16.05.03from - Ans=[pA,Nn,Pm,Lm,Sm]; - ); - ); // 16.05.03upto - ); - if(Flg==0, - Ans=Ans_(3..5); - ); - Ans; -); - -Derivative(fun,var,value):=( -//help:Derivative("x^3","x",2); - regional(str,tmp); - str="d("; - str=str+replace(fun,var,"#")+","; - str=str+value+")"; - tmp=Pcrd([1,parse(str)]); // 14.11.08 - tmp_2; -); - -Integrate(pltdata,range):=Integrate(pltdata,range,[]); -Intergrate(Arg1,Arg2,Arg3):=( - regional(pltdata,range,options,fnstr,vartr); - if(islist(Arg2), - pltdata=Arg1; - range=Arg2; - options=Arg3; - Integrate(pltdata,range,options); - , - fnstr=Arg1; - vastr=Arg2; - range=Arg3; - Integrate(fnstr,vastr,range,[]); - ); -); - -Integrate(pltdata,range,options):=( -//help:Integrate("gr1",[1,3]); -//help:Integrate("gr1",[1,3],["Rule=t"]); - regional(tmp,tmp1,eqL,Rule,pdata,Sm,ptP,ptQ,list,va1,va2); - tmp=Divoptions(options); - eqL=tmp_5; - Rule="o"; - forall(eqL, - if(Toupper(substring(#,0,1))=="R", - tmp=indexof(#,"="); - Rule=substring(#,tmp,tmp+1); - ); - ); - if(Rule=="o", - Sm= IntegrateO(pltdata,range); - , - if(isstring(pltdata),pdata=parse(pltdata),pdata=pltdata); - if(MeasureDepth(pdata)==2,pdata=pdata_1); - va1=MeetCurve(pdata,range_1,0); - va2=MeetCurve(pdata,range_2,0); - list=select(pdata,(#_1>range_1 & #_1<range_2)); - list=apply(list,LLcrd(#)); // 15.09.14 - list=concat([va1],list); - list=concat(list,[va2]); - Sm=0; - forall(1..(length(list)-1), - ptP=list_#; // 15.09.14 - ptQ=list_(#+1); - Sm=Sm+(ptP_2+ptQ_2)*(ptQ_1-ptP_1)/2; - ); - Sm; - ); -); - -Integrate(fnstr,vastr,range,options):=( -//help:Integrate("sin(x)","x",[0,pi],["Num=100","Rule=s"]); - regional(tmp,tmp1,Sm,Lx,Rx,va1,va2,Num,Waysx,ex,dx,xn,yn,x0,x1,x2,y0,y1,y2); - Num=100; - Way="t"; - forall(options, - if(indexof(#,"=")>0, - if(indexof(#,"N=")>0, - Num=parse(substring(#,indexof(#,"="),length(#))); - ); - if(indexof(#,"Num=")>0, - Num=parse(substring(#,indexof(#,"="),length(#))); - ); - if(Toupper(substring(#,0,1))=="R", - tmp=indexof(#,"="); - Way=substring(#,tmp,tmp+1); - ); - ); - ); - Sm=0; - if(Way=="t", - forall(1..Num, - Lx=range_1+(range_2-range_1)*(#-1)/Num; - Rx=range_1+(range_2-range_1)*#/Num; - va1=parse(replace(fnstr,vastr,textformat(Lx,5))); - va2=parse(replace(fnstr,vastr,textformat(Rx,5))); - Sm=Sm+(va1+va2)*(Rx-Lx)/2; - ); - , - sx=range_1; - ex=range_2; - dx=(ex-sx)/Num; - xn=apply(0..Num,sx+#*dx); - yn=apply(xn,parse(replace(fnstr,vastr,textformat(#,5)))); - dx=dx/2; - repeat(Num,s, - x0=xn_s; - x1=(xn_s+xn_(s+1))/2; - x2=xn_(s+1); - y0=yn_s; - y1=parse(replace(fnstr,vastr,textformat(x1,5))); - y2=yn_(s+1); - Sm=Sm+dx*(y0+4*y1+y2)/3; - ); - ); - Sm; -); - -IntegrateO(p0org,p1org,p2org,p3org):=( - regional(p0,p1,p2,p3,pQ,pR,cc,p01,p02, - p11,p12,p21,p22,p31,p32, tmp); - if(ispoint(p0org),p0=p0org.xy,p0=p0org); // 16.03.10 - if(ispoint(p1org),p1=p1org.xy,p1=p1org); // 16.03.16 - if(ispoint(p2org),p2=p2org.xy,p2=p2org); - if(ispoint(p3org),p3=p3org.xy,p3=p3org); - tmp=1+sqrt((1+Dotprod(p2-p0,p3-p1)/|p2-p0|/|p3-p1|)/2); - cc=4*|p2-p1|/3/(|p2-p0|+|p3-p1|)/tmp; - pQ=p1+cc*(p2-p0); - pR=p2+cc*(p1-p3); - p01=p1_1; p02=p1_2; - p31=p2_1; p32=p2_2; - p11=pQ_1; p12=pQ_2; - p21=pR_1; p22=pR_2; - tmp=-6*p12*p01+3*p12*p21+3*p12*p31+6*p02*p11- - 10*p02*p01+3*p02*p21+p02*p31-3*p22*p11- - 3*p22*p01+6*p22*p31-3*p32*p11-p32*p01- - 6*p32*p21+10*p32*p31; - tmp=tmp/20; -); -IntegrateO(pltdata,rangeorg):=( -//help:IntegrateO("gr1",[0,2]); - regional(tmp,tmp1,tmp2,pdata,va1,va2,list,Bzk,Bzc,range,pmflg, - Sm,p0,p1,p2,p3,pQ,pR,cc,p01,p02,p11,p12,p21,p22,p31,p32); - if(isstring(pltdata),pdata=parse(pltdata),pdata=pltdata); - if(MeasureDepth(pdata)==2,pdata=pdata_1); - range=rangeorg; - pmflg=1; - if(range_2<range_1, - range=reverse(range); - pmflg=-1; - ); - va1=MeetCurve(pdata,range_1,0); - va2=MeetCurve(pdata,range_2,0); - list=select(pdata,(#_1>range_1 & #_1<range_2)); - if((length(list)>0) & (list_1_1>list_(length(list))_1), - list=reverse(list); -// pmflg=pmflg*(-1); - ); - list=apply(list,LLcrd(#)); - list=concat([va1],list); - list=concat(list,[va2]); - Sm=0; - forall(1..(length(list)-1), - p1=list_#; - p2=list_(#+1); - if(#==1 % #==length(list)-1, - tmp1=(p1_2+p2_2)*(p2_1-p1_1)/2; - Sm=Sm+tmp1; - , - p0=list_(#-1); - p3=list_(#+2); - tmp=1+sqrt((1+Dotprod(p2-p0,p3-p1)/|p2-p0|/|p3-p1|)/2); - cc=4*|p2-p1|/3/(|p2-p0|+|p3-p1|)/tmp; - pQ=p1+cc*(p2-p0); - pR=p2+cc*(p1-p3); - p01=p1_1; p02=p1_2; - p31=p2_1; p32=p2_2; - p11=pQ_1; p12=pQ_2; - p21=pR_1; p22=pR_2; - tmp1=-6*p12*p01+3*p12*p21+3*p12*p31+6*p02*p11- - 10*p02*p01+3*p02*p21+p02*p31-3*p22*p11- - 3*p22*p01+6*p22*p31-3*p32*p11-p32*p01- - 6*p32*p21+10*p32*p31; - tmp1=tmp1/20; - Sm=Sm+tmp1; - ); - ); - if(pmflg==-1, - Sm=-Sm; - ); - Sm; -); - -Findarea(pdstr):=( -//help:Findarea("sgABCA"); - regional(pd,p1,p2,s,tmp); - if(isstring(pdstr),pd=parse(pdstr),pd=pdstr); - s=0; - forall(1..(length(pd)-1), - p1=Lcrd(pd_#); - p2=Lcrd(pd_(#+1)); - tmp=(p1_2+p2_2)*(p2_1-p1_1)/2; - s=s+tmp; - ); - if(s<0,s=-s); - s; -); - -Findarea(pdstr):=( // 15.11.27 -//help:Findarea("cr1"); - regional(pd,p0,p1,p2,p3,s,tmp); - if(isstring(pdstr),pd=parse(pdstr),pd=pdstr); - s=0; - forall(1..(length(pd)-1), - p1=pd_#; - p2=pd_(#+1); - if(#==1,p0=pd_(length(pd)-1),p0=pd_(#-1)); - if(#==length(pd)-1,p3=pd_2,p3=pd_(#+2)); - tmp=IntegrateO(p0,p1,p2,p3); - s=s+tmp; - ); - if(s<0,s=-s); - s; -); - -Findlength(pdstr):=( -//help:Findlength("gr1"); - regional(pd,p1,p2,s,tmp); - if(isstring(pdstr),pd=parse(pdstr),pd=pdstr); - s=0; - forall(1..(length(pd)-1), - p1=Lcrd(pd_#); - p2=Lcrd(pd_(#+1)); - tmp=|p2-p1|; - s=s+tmp; - ); - s; -); - -Inversefun(fnstr,rngstr,value):=( - regional(tmp,varstr,range,x1,x2,x3,va1,va2); - tmp=indexof(rngstr,"="); - varstr=substring(rngstr,0,tmp-1); - range=parse(substring(rngstr,tmp,length(rngstr))); - x1=range_1; x2=range_2; - repeat(15, - x3=(x1+x2)/2; - va1=parse(replace(fnstr,varstr,textformat(x1,5))); - va2=parse(replace(fnstr,varstr,textformat(x3,5))); - if((va1>value & va2>value) % (va1<value & va2<value), - x1=x3; - , - x2=x3; - ); - ); - va1=parse(replace(fnstr,varstr,textformat(x1,5)))-value; - va2=parse(replace(fnstr,varstr,textformat(x2,5)))-value; - if(x1==range_1 % x2==range_2, - println("not found in ("+textformat(range_1,5) - +","+textformat(range_2,5)+")"); - ); - if(abs(va1)<=abs(va2),x1,x2); -); - -Lcrd(pt):=( - regional(tmp); - if(ispoint(pt), - tmp=[pt.x/SCALEX,pt.y/SCALEY]; - , - tmp=pt; - ); - tmp; -); - -Pcrd(pt):=( - regional(tmp); - if(ispoint(pt), - tmp=re(pt.xy); // 15.07.24 - , - tmp=[pt_1*SCALEX,pt_2*SCALEY]; - ); - tmp; -); - -LLcrd(pt):=( - regional(tmp); - if(ispoint(pt), - tmp=pt.xy - , - tmp=pt; - ); - tmp=[tmp_1/SCALEX,tmp_2/SCALEY]; - tmp; -); - -Doscaling(pltdata):=( - regional(Level,Out,gL,gr,tmp); - if(ispoint(pltdata) % isreal(pltdata_1), - gL=[[pltdata]]; - Level=0; - , - if(ispoint(pltdata_1) % isreal(pltdata_1_1), - gL=[pltdata]; - Level=1; - , - gL=pltdata; - Level=2; - ); - ); - Out=[]; - forall(gL,gr, - tmp=apply(gr,Lcrd(#)); - tmp=apply(tmp,LLcrd(#)); - Out=concat(Out,[tmp]); - ); - if(Level==0, - Out=Out_1_1; - ); - if(Level==1, - Out=Out_1; - ); - Out; -); - -Unscaling(pltdata):=( - regional(Level,Out,gL,gr,tmp); - if(ispoint(pltdata) % isreal(pltdata_1), - gL=[[pltdata]]; - Level=0; - , - if(ispoint(pltdata_1) % isreal(pltdata_1_1), - gL=[pltdata]; - Level=1; - , - gL=pltdata; - Level=2; - ); - ); - Out=[]; - forall(gL,gr, - tmp=apply(gr,Lcrd(#)); - tmp=apply(tmp,LLcrd(#)); - Out=concat(Out,[tmp]); - ); - if(Level==0, - Out=Out_1_1; - ); - if(Level==1, - Out=Out_1; - ); - Out; -); - -Definecolor(name,data):=( -//help:Definecolor("mycolor",[1,1,1,0]); - regional(type,tmp); - if(length(data)>3,type="cmyk",type="rgb"); - tmp=text(data); - tmp=substring(tmp,1,length(tmp)-1); - tmp="\definecolor{"+name+"}{"+type+"}{"+tmp+"}"; - Texcom(tmp); -); - -Setcolor(Par):=( -//help:Setcolor([1,0,0,1]); -//help:Setcolor([1,1,0]); - if(islist(Par), - if(length(Par)==3, - Setcolorrgb(Par); // 2015.04.28 -// KCOLOR=Par; - ); - if(length(Par)==4, - Setcolor(Par,[]); - ); - , - Setcolor(Par,[]); - ); -); - -Setcolor(colorname,options):=( -//help:Setcolor("greenyellow",0.3); - regional(tmp); - if(isstring(colorname), - tmp="Setcolor("+Dq+colorname+Dq; - if(length(options)>0, - tmp=tmp+","+text(options_1); - ); - Com2nd(tmp+")"); - ); - if(islist(colorname), - tmp=text(colorname); - tmp=substring(tmp,1,length(tmp)-1); - tmp="Texcom("+Dq+"\color[cmyk]{"+tmp+"}"+Dq+")"; - Com2nd(tmp); - ); -); - -Setcolorrgb(colorlist):=( -// help:Setcolorrgb([0.5,0.3,0.4]); - regional(tmp); - tmp=text(colorlist); - tmp=substring(tmp,1,length(tmp)-1); - tmp="Texcom("+Dq+"\color[rgb]{"+tmp+"}"+Dq+")"; - Com2nd(tmp); -); - -ColorRgb2Cmyk(clr):=( -// help:ColorRgb([0.2,0.5,0.1]); - regional(clrnew,tmp,black); - tmp=apply(clr,1-#); - black=min(tmp); - tmp=apply(clr,(1-#-black)/(1-black)); - clrnew=append(tmp,black); - clrnew; -); - -ColorCmyk2Rgb(clr):=( -// help:ColorRgb([0.2,0.5,0.1,0.2]); - regional(clrnew,tmp,black); - black=clr_4; - tmp=apply(clr,1-min(1,#*(1-black)+black)); - clrnew=tmp_(1..3); - clrnew; -); - -Colorrgbhsv(rgb):=( - regional(varR,varG,varB,varMin,varMax,delMax,hh,ss,vv,delR,delG,delB); - varR = rgb_1; - varG = rgb_2; - varB = rgb_3; - varMin = min( [varR, varG, varB] ); - varMax = max( [varR, varG, varB] ); - delMax = varMax - varMin ; - vv = varMax; - if ( delMax == 0 , - hh = 0 ; - ss = 0 ; - , - ss = delMax / varMax; - delR = ( ( ( varMax - varR ) / 6 ) + ( delMax / 2 ) ) / delMax; - delG = ( ( ( varMax - varG ) / 6 ) + ( delMax / 2 ) ) / delMax; - delB = ( ( ( varMax - varB ) / 6 ) + ( delMax / 2 ) ) / delMax; - if( varR == varMax , - hh = delB - delG; - , - if ( varG == varMax, - hh = ( 1 / 3 ) + delR - delB; - , - if ( varB == varMax , - hh = ( 2 / 3 ) + delG - delR; - ); - ); - ); - if ( hh < 0 ,hh = hh+1); - if ( hh > 1 ,hh = hh-1); - ); - [hh*360,ss,vv]; -); - -Colorhsvrgb(sL):=( - regional(tmp,tmp1,tmp2,tmp3,hi,ff,dL); - tmp=[sL_1/60,sL_2,sL_3]; - hi=mod(floor(tmp_1),6); - ff=tmp_1-floor(tmp_1); - tmp2=tmp_3*[1-tmp_2,1-tmp_2*ff,1-tmp_2*(1-ff)]; - tmp2=append(tmp2,tmp_3); - if(hi==0,dL=tmp2_[4,3,1]); - if(hi==1,dL=tmp2_[2,4,1]); - if(hi==2,dL=tmp2_[1,4,3]); - if(hi==3,dL=tmp2_[1,2,4]); - if(hi==4,dL=tmp2_[3,1,4]); - if(hi==5,dL=tmp2_[4,1,2]); - dL; -); - -Colorrgbhsl(rgb):=( - regional(rr,gg,bb,mn,mx,delta,deltaR,deltaG,deltaB,hh,ss,ll); - rr = rgb_1 ; - gg = rgb_2 ; - bb = rgb_3 ; - mn = min([rr, gg, bb]); - mx = max([rr, gg, bb]); - delta = mx - mn; - ll = (mx + mn) / 2; - if (delta == 0, - hh=0; - ss=0; - , - if (ll < 0.5, - ss = delta/ (mx + mn); - , - ss = delta / (2 - mx - mn); - ); - deltaR = (((mx - rr) / 6) + (delta / 2)) / delta; - deltaG = (((mx - gg) / 6) + (delta / 2)) / delta; - deltaB = (((mx - bb) / 6) + (delta / 2)) / delta; - if (rr == mx, - hh = deltaB - deltaG; - , - if (gg == mx, - hh = (1 / 3) + deltaR - deltaB; - , - if (bb == mx, - hh = (2 / 3) + deltaG - deltaR; - ); - ); - ); - if ( hh < 0, hh = hh+1); - if ( hh > 1, hh = hh-1); - ); - [hh*360,ss,ll]; -); - -Colorhslrgb(hsl):=( - regional(hh,ss,ll,rr,gg,bb,var1,var2); - hh=hsl_1/360; - ss=hsl_2; - ll=hsl_3; - if ( ss == 0.0, - rr = ll ; - gg = ll ; - bb = ll ; - , - if ( ll < 0.5 , - var2 = ll * ( 1.0 + ss ); - , - var2 = ( ll + ss ) - ( ss * ll ); - ); - var1 = 2.0 * ll - var2; - rr = hue2rgb( var1, var2, hh + ( 1.0 / 3.0 ) ); - gg = hue2rgb( var1, var2, hh ); - bb = hue2rgb( var1, var2, hh - ( 1.0 / 3.0 ) ); - ); - [rr,gg,bb]; -); - -hue2rgb(vv1,vv2,vh):=( - regional(out); - if ( vh < 0.0 ,vh =vh+1); - if ( vh > 1.0 ,vh =vh-1); - if ( 6.0*vh < 1.0 , - out = vv1 + ( vv2 - vv1 ) * 6.0 * vh ; - , - if( 2.0*vh < 1.0 , - out = vv2; - , - if ( 3.0*vh < 2.0 , - out = vv1 + ( vv2 - vv1 ) * ( ( 2.0 / 3.0 ) - vh ) * 6.0 ; - , - out= vv1 ; - ); - ); - ); - out; -); - -Colorrgbhwb(sL):=( - regional(dl1,dl2,dl3); - dl1 = Colorrgbhsl(sL)_1;//Colorcode("rgb","hsl",sL)_1; - dl2 = min(sL); - dl3 = 1 - max(sL); - dL= [dl1, dl2 , dl3 ]; -); - -Colorhwbrgb(sLorg):=( - regional(sL,tmp,tmp1,tmp2,tmp3,ratio,ff,ii,vv,nn,dL,flg); - sL=sLorg; - sL=[sL_1/360,sL_2,sL_3]; - ratio = sL_2 + sL_3; - // sL_2 + sL_3 cant be > 1 - if (ratio > 1., - sL_2 =sL_2 / ratio; - sL_3 = sL_3 / ratio; - ); - ii = floor(6 * sL_1); - vv = 1 - sL_3; - ff = 6 * sL_1 - ii; - if(mod(ii,2)==1,ff = 1 - ff); - nn = sL_2 + ff * (vv - sL_2); // linear interpolation - tmp=[[vv,nn,sL_2],[nn,vv,sL_2],[sL_2,vv,nn], - [sL_2,nn,vv],[nn,sL_2,vv],[vv,sL_2,nn],[vv,nn,sL_2]]; - flg=0; - forall(0..6, - if(flg==0 & ii == # , - dL=tmp_(#+1); - flg=1; - ); - ); - dL; -); - -Colorhslhsv(sL):=( - regional(dl1,dl2,dl3,dL); - dl1=sL_1; - if(sL_3 == 0, - // no need to do calc on black - // also avoids divide by 0 error - dL= [0, 0, 0]; - , - sL_3 = sL_3 * 2; - if(sL_3 <= 1,sL_2 = sL_2 * sL_3,sL_2 = sL_2 * (2 - sL_3)); - dl3 = (sL_3 + sL_2) / 2; - dl2 = (2 * sL_2) / (sL_3 + sL_2); - dL = [dl1, dl2, dl3]; - ); - dL; -); - -Colorcode(src,dest,sL):=( -//help:Colorcode("rgb","cmyk",[1,0.5,0]); - regional(tmp,tmp1,tmp2,tmp3,mn,mx,delta,black,dL,flg); - regional(dl1,dl2,dl3); - if(src=="rgb" & dest=="hsv", dL=Colorrgbhsv(sL)); - if(src=="hsv" & dest=="rgb", dL=Colorhsvrgb(sL)); - if(src=="rgb" & dest=="hsl", dL=Colorrgbhsl(sL)); - if(src=="hsl" & dest=="rgb", dL=Colorhslrgb(sL)); - if(src=="rgb" & dest=="hwb", dL=Colorrgbhwb(sL)); - if(src=="hwb" & dest=="rgb", dL=Colorhwbrgb(sL)); - if(src=="hsl" & dest=="hsv", dL=Colorhslhsv(sL)); - if(src=="hsv" & dest=="hsl", - dl1 = sL_1; - dl3 = (2 - sL_2) * sL_3; - dl2 = sL_2 * sL_3; - if(dl3 <= 1,dl2 = dl2/dl3,dl2=dl2/(2 - dl3)); - dl3 =d l3/ 2; - dL = [dl1, dl2 , dl3 ]; - ); - - if(src=="rgb" & dest=="cmyk", - tmp=apply(sL,1-#); - black=min(tmp); - tmp=apply(sL,(1-#-black)/(1-black)); - dL=append(tmp,black); - ); - if(src=="cmyk" & dest=="rgb", - black=sL_4; - tmp=apply(sL,1-min(1,#*(1-black)+black)); - dL=tmp_(1..3); - ); - if(src=="hsv" & dest=="cmyk", - tmp=Colorcode("hsv","rgb",sL); - dL=Colorcode("rgb","cmyk",tmp); - ); - if(src=="cmyk" & dest=="hsv", - tmp=Colorcode("cmyk","rgb",sL); - dL=Colorcode("rgb","hsv",tmp); - ); - - if(src=="hsv" & dest=="hwb", - tmp = Colorcode("hsv","rgb",sL); - dL = Colorcode("rgb","hwb",tmp); - ); - if(src=="hwb" & dest=="hsv", - tmp = Colorcode("hwb","rgb",sL); - dL = Colorcode("rgb","hsv",tmp); - ); - if(src=="hsl" & dest=="hwb", - tmp = Colorcode("hsl","rgb",sL); - dL = Colorcode("rgb","hwb",tmp); - ); - if(src=="hwb" & dest=="hsl", - tmp = Colorcode("hwb","rgb",sL); - dL = Colorcode("rgb","hsl",tmp); - ); - if(src=="hsl" & dest=="cmyk", - tmp = Colorcode("hsl","rgb",sL); - dL = Colorcode("rgb","cmyk",tmp); - ); - if(src=="hwb" & dest=="cmyk", - tmp = Colorcode("hwb","rgb",sL); - dL = Colorcode("rgb","cmyk",tmp); - ); - if(src=="cmyk" & dest=="hsl", - tmp = Colorcode("cmyk","rgb",sL); - dL = Colorcode("rgb","hsl",tmp); - ); - if(src=="cmyk" & dest=="hwb", - tmp = Colorcode("cmyk","rgb",sL); - dL = Colorcode("rgb","hwb",tmp); - ); - if(src=="hsb" & dest=="rgb",dL=Colorcode("hsv","rgb",sL)); - if(src=="rgb" & dest=="hsb",dL=Colorcode("rgb","hsv",sL)); - - if(src=="hsb" & dest=="hsl",dL=Colorcode("hsv","hsl",sL)); - if(src=="hsl" & dest=="hsb",dL=Colorcode("hsl","hsv",sL)); - - if(src=="hsb" & dest=="hwb",dL=Colorcode("hsv","hwb",sL)); - if(src=="hwb" & dest=="hsb",dL=Colorcode("hwb","hsv",sL)); - - if(src=="hsb" & dest=="cmyk",dL=Colorcode("hsv","cmyk",sL)); - if(src=="cmyk" & dest=="hsb",dL=Colorcode("cmyk","hsv",sL)); - - dL; -); - -Addcolor(cmdorg,list):=( -//help:Addcolor("Plotdata('1','x^2','x',[])",[1,1,0]); - regional(rgb,cmyk,cmd,tmp,tmp1,tmp2,tmp3,tmp4); - cmd=replace(cmdorg,"'",Dq); - if(length(list)==3, - rgb=list; - cmyk=Colorcode("rgb","cmyk",list); - , - cmyk=list; - rgb=Colorcode("cmyk","rgb",list); - ); - tmp1="color->"+text(rgb); - tmp2="Setcolor("+text(cmyk)+");"; - tmp3=substring(cmd,0,length(cmd)-2); - tmp=substring(tmp3,length(tmp3)-1,length(tmp3)); - if(tmp!="[", - tmp3=tmp3+","; - ); - tmp3=tmp3+Dq+tmp1+Dq+"])"; - parse(tmp2); - parse(tmp3); - Setcolor("black"); -); - -Colorinfile(filename,clrf,clrt):=( - regional(tmp,tmp1,tmp2,head,cstrL,chstrL,head,body); - if(length(clrf_1)==3, - head="[rgb]{"; - , - head="[cmyk]{"; - ); - tmp=apply(clrf,text(#)); - cstrL=apply(tmp,head+substring(#,1,length(#)-1)+"}"); - if(length(clrt_1)==3, - head="[rgb]{"; - , - head="[cmyk]{"; - ); - tmp=apply(clrt,text(#)); - chstrL=apply(tmp,head+substring(#,1,length(#)-1)+"}"); - tmp1=load(filename); - tmp=tokenize(tmp1,"{\unitlength"); - head=tokenize(tmp_1,"%%%"); - head=head_(2..length(head)); - head=apply(head,"%%%"+#); - tmp2=tmp_2; - forall(1..5, - tmp2=replace(tmp2,cstrL_#,chstrL_#); - ); - body=tokenize(tmp2,"%"); - body_1="{\unitlength"+body_1; - body=apply(body,#+"%"); - body=body_(1..(length(body)-1)); - tmp=replace(filename,".tex","new.tex"); - SCEOUT=openfile(tmp); - forall(head, - println(SCEOUT,#); - ); - forall(1..length(body), - tmp=body_#; - if(#<length(body), - println(SCEOUT,tmp); - , - print(SCEOUT,tmp) - ); - ); - closefile(SCEOUT); -); - -GetLinestyle(str,name):=( - regional(noflg,tmp,tmp1,tmp2,Dop,Ltype,subflg); - Ltype=-1; - Dop=""; - tmp1=indexof(str,","); - if(tmp1>0, - Dop=","+substring(str,tmp1,length(str)); - ); - noflg=parse(substring(str,0,1)); - if(substring(name,0,3)=="sub",subflg=1,subflg=0); // 16.02.29 - tmp1=substring(str,1,3); - if(tmp1=="dr" % tmp1=="Dr", - Ltype=0; - if(noflg==0 & subflg==0, // 16.02.29 - Drwline(name+Dop); - ); - ); - if(tmp1=="da" % tmp1=="Da", - Ltype=1; - if(noflg==0 & subflg==0, // 16.02.29 - Dashline(name+Dop); - ); - ); - if(tmp1=="id" % tmp1=="Id", - Ltype=2; // 15.11.09 - if(noflg==0 & subflg==0, // 16.02.29 - Invdashline(name+Dop); - ); - ); - if(tmp1=="do" % tmp1=="Do", - Ltype=3; - if(noflg==0 & subflg==0, // 16.02.29 - Dottedline(name+Dop); - ); - ); - if(tmp1=="dp" % tmp1=="Dp", - Ltype=0; - tmp1=parse(name); - tmp2=""; - forall(tmp1, - tmp2=tmp2+textformat(#_1,5)+","; - ); - tmp2=substring(tmp2,0,length(tmp2)-1); - if(noflg==0, - Drwpt(tmp2+Dop); - ); - ); - if(tmp1=="no" % tmp1=="No", - Ltype=10; - ); - Ltype; -); - -Chunderscore(str):=( - regional(flg,tmp,tmp1,tmp2,tmp3); - if(indexof(str,"]")>0, - tmp1=replace(str,"]",",]"); - , - tmp1=str+","; - ); - flg=0; - tmp2=[]; - tmp3=0; - forall(1..length(tmp1), - if(flg==0, - tmp=substring(tmp1,tmp3,length(tmp1)); - tmp=indexof(tmp,"_"); - if(tmp==0, - flg=1; - , - tmp3=tmp3+tmp; - tmp=substring(tmp1,tmp3,length(tmp1)); - tmp=indexof(tmp,",")-1; - tmp=substring(tmp1,tmp3,tmp3+tmp); - tmp2=append(tmp2,tmp); - ); - ); - ); - forall(tmp2, - tmp1=replace(tmp1,"_"+#,"("+#+")"); - ); - if(indexof(str,"]")>0, - tmp1=replace(tmp1,",]",")"); - tmp1=replace(tmp1,"[","list("); - , - tmp1=substring(tmp1,0,length(tmp1)-1); - ); - tmp1; -); - -//AddGraph(pltdata):=AddGraph("-"+pltdata,pltdata,[]); -AddGraph(nm,pltdata):=AddGraph(nm,pltdata,[]); -// if(isstring(Arg2), -// AddGraph(Arg1,Arg2,[]); -// , -// if(MeasureDepth(Arg2)>0, -// Addgraph(Arg1,Arg2,[]); -// , -// Addgraph("-"+Arg1,Arg1,Arg2); -// ); -// ); -//); -AddGraph(nm,pltdata,options):=( -//help:AddGraph("1","imp1"); // 16.04.04 -//help:Addgraph("1",["[pt1]","gr1"],["nodisp"]); - regional(name,Ltype,Noflg,opcindy,pdata,fname,flg, - tmp,tmp1,tmp2,tmp3); - if(substring(nm,0,1)=="-", - name=substring(nm,1,length(nm)); - , - name="ad"+nm; - ); - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_9; - if(isstring(pltdata), - pdata=parse(pltdata) - , - if(!islist(pltdata),pdata=[pltdata],pdata=pltdata); - pdata=apply(pdata,parse(#)); - ); // 15.01.22 - pdata=Flattenlist(pdata); - tmp1=[]; - forall(pdata,tmp2, - tmp=apply(tmp2,Pcrd(#)); - tmp1=append(tmp1,tmp); - ); - if(length(tmp1)==1,tmp1=tmp1_1); - pdata=tmp1; - if(Noflg<3, - println("generate addgraph "+name); - tmp=name+"="+textformat(pdata,5); - parse(tmp); - if(isstring(pltdata), // 16.04.04 from - if(indexof(pltdata,"]")>0, - tmp1="list(Listplot("+substring(pltdata,1,length(pltdata)); - tmp1=replace(tmp1,"]",",]"); - , - tmp1="Listplot("+substring(pltdata,0,length(pltdata))+",]"; - ); - flg=0; - tmp2=[]; - tmp3=0; - forall(1..length(tmp1), - if(flg==0, - tmp=indexof(substring(tmp1,tmp3,length(tmp1)),"_"); - if(tmp==0, - flg=1; - , - tmp3=tmp3+tmp; - tmp=indexof(substring(tmp1,tmp3,length(tmp1)),",")-1; - tmp=substring(tmp1,tmp3,tmp3+tmp); - tmp2=append(tmp2,tmp); - ); - ); - ); - forall(tmp2, - tmp1=replace(tmp1,"_"+#,"("+#+")"); - ); - tmp1=replace(tmp1,",]",")"); - tmp1=replace(tmp1,",","),Listplot("); - if(indexof(pltdata,"[")>0, - tmp1=tmp1+")"; - ); - GLIST=append(GLIST,name+"="+tmp1); - , - if(MeasureDepth(pdata)==1, - tmp1=name+"=Listplot("+textformat(pdata,5)+")"; - , - tmp1="list("; - forall(1..length(pdata), - tmp=name+"p"+textformat(#,5)+"="; - if(length(pdata_#)>1, // 15.01.22 - tmp=tmp+"Listplot("+textformat(pdata_#,5)+")"; - , - tmp=tmp+"Pointdata("+textformat(pdata_#_1,5)+")"; - ); - GLIST=append(GLIST,tmp); - tmp1=tmp1+name+"p"+textformat(#,5)+","; - ); - tmp1=name+"="+substring(tmp1,0,length(tmp1)-1)+")"; - ); - GLIST=append(GLIST,tmp1); - ); - ); // 16.04.04 upto - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); -); - -Joincrvs(nm,plotstrL):=Joincrvs(nm,plotstrL,[]); -Joincrvs(nm,plotstrL,options):=( -//help:Joincrvs("1",["sgAB","sgDCB"]); - regional(plotlist,PtL,Eps,QdL,Flg,Ni,Qd,pP,pS,pQ,pR,rMN, - opcindy,tmp,tmp1,tmp2,str,name,Ltype,Noflg); - name="join"+nm; - plotlist=[]; - forall(plotstrL,str, - if(isstring(str), - tmp=parse(str); - tmp=apply(tmp,LLcrd(#)); - , - tmp=str; - ); - plotlist=append(plotlist,tmp); - ); - Eps=10^(-4); - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - tmp1=tmp_6; - if(length(tmp1)>0,Eps=tmp1_1); - QdL=[]; - forall(plotlist,Qd, - if(ispoint(Qd_1) % !islist(Qd_1_1), - QdL=concat(QdL,[Qd]); - , - forall(Qd, - QdL=concat(QdL,[#]); - ); - ); - ); - Flg=0; - if(length(QdL)==0, - PtL=[]; - Flg=1; - ); - if(Flg==0, - PtL=QdL_1; - forall(2..length(QdL),Ni, - Qd=QdL_Ni; - if(Numptcrv(Qd)>1, - pP=Ptend(PtL); - pS=Ptstart(PtL); - pQ=Ptstart(Qd); - pR=Ptend(Qd); - rMN=min([|pP-pQ|,|pP-pR|,|pS-pQ|,|pS-pR|]); - if(rMN==|pP-pR|, - Qd=reverse(Qd); - , - if(rMN==|pS-pQ|, - PtL=reverse(PtL); - , - if(rMN==|pS-pR|, - PtL=reverse(PtL); - Qd=reverse(Qd); - ); - ); - ); - ); - if(rMN>Eps, - PtL=concat(PtL,Qd); - , - PtL=concat(PtL,Qd_(2..length(Qd))); - ); - ); - ); - if(Noflg<3, - println("generate joincurve "+name); - tmp1=apply(PtL,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp1=""; - forall(plotstrL, - tmp1=tmp1+#+","; - ); - tmp1=substring(tmp1,0,length(tmp1)-1); - GLIST=append(GLIST,name+"=Joincrvs("+tmp1+")"); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - PtL; -); - -Partcrv(nm,pA,pB,PkLstr):=Partcrv(nm,pA,pB,PkLstr,[]); -Partcrv(nm,pA,pB,PkLstr,options):=( -//help:Partcrv("1",A,B,"sgABC"); -//help:Partcrv("1",1.3,2.5,"sgABC"); - regional(PkL,Ans,Eps,Npt,Out1,Out2,tmp,tmp1,Flg,nS,nE,PPL,pP, - opcindy,Ta,Tb,name,Ltype,Noflg,DepthFlg); - name="part"+nm; - if(isstring(PkLstr),PkL=parse(PkLstr),PkL=PkLstr); - DepthFlg=0; - if(MeasureDepth(PkL)==2, - PkL=PkL_1; - DepthFlg=1; - ); - PkL=apply(PkL,LLcrd(#)); - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - Eps=10^(-3); - Flg=0; - if(isreal(pA), - if(pA>pB+Eps, - Npt=Numptcrv(PkL); - Out1=Partcrv("",pA,Npt,PkLstr,["nodata"]); - Out2=Partcrv("",1,pB,PkLstr,["nodata"]); - tmp=Ptstart(PkL)-Ptend(PkL); - if(|tmp|<Eps, - Ans=Joincrvs("",[Out1,Out2],["nodata"]); - , - Ans=[apply(Out1,Pcrd(#)),apply(Out2,Pcrd(#))]; - ); - Flg=1; - ); - if(Flg==0, - nS=ceil(pA); - nE=floor(pB); - PPL=[]; - if(pA<nS-Eps, - pP=(nS-pA)*PkL_(nS-1)+(1-nS+pA)*PkL_nS; - PPL=[pP]; - ); - PPL=concat(PPL,PkL_(nS..nE)); - if(pB>nE+Eps, - pP=(1-pB+nE)*PkL_nE+(pB-nE)*PkL_(nE+1); - PPL=concat(PPL,[pP]); - ); - Ans=PPL; - Flg=1; - ); - ); - if(Flg==0, - tmp=Nearestpt(LLcrd(Pcrd(pA)),PkL); - Ta=tmp_2; - tmp=Nearestpt(LLcrd(Pcrd(pB)),PkL); // 15.09.12 - Tb=tmp_2; - Ans=Partcrv("",Ta,Tb,PkL,["nodata"] ); - Ans=apply(Ans,Pcrd(#)); - ); - if(Noflg<3, - println("generate partcrv "+name); - tmp1=apply(Ans,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); -// GLIST=append(GLIST, // 16.04.03 - if(DepthFlg==0, - tmp=PkLstr; - , - tmp=PkLstr+"(1)"; - ); - tmp1=name+"=Partcrv("+textformat(Lcrd(pA),5) - +","+textformat(Lcrd(pB),5)+","+tmp+")"; // 16.04.03 - GLIST=append(GLIST,tmp1); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Ans; -); - -Opcrvs(num,Fig):=Opcrvs(num,Fig,["nodisp"]); -Opcrvs(num,Fig,options):=( - //help:Subgraph(2,"grfs"); - regional(name,tmp,tmp1); - name="-"+Fig+text(num); - tmp=Fig+"_"+text(num); - tmp1=parse(tmp); - Listplot(name,tmp1,options); -); - - -Pointdata(nm,list):=Pointdata(nm,list,[]); -Pointdata(nm,list,options):=( -//help:Pointdata("1",[2,4],["Size=5"]); -//help:Pointdata("2",[[2,3],[4,1]]); - regional(name,nameL,ptlist,opstr,opcindy, - eqL,size,thick,tmp,tmp1,tmp2,tmp3,Ltype,Noflg); - name="pt"+nm; - nameL=name+"L"; - println("generate pointdata "+name); - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - opstr=tmp_(length(tmp)-1); - size=""; - eqL=tmp_5; - if(length(eqL)>0, - forall(eqL, - tmp=substring(#,0,1); - if(tmp=="s" % tmp=="S", - tmp=indexof(#,"="); - size=substring(#,tmp,length(#)); - ); - ); - ); - tmp=MeasureDepth(list); - if(tmp>0, // 2015.02.21 - if(tmp==1,ptlist=list,ptlist=list_1); - tmp=apply(ptlist,[textformat(Pcrd(#),5)]); - tmp1=text(tmp); - tmp2=substring(tmp1,1,length(tmp1)-1); - tmp3=tmp1; - , - ptlist=list; - tmp1=textformat(Pcrd(ptlist),5); - tmp2=tmp1; - tmp3="["+tmp1+"]"; - ); - tmp=name+"="+tmp1; - parse(tmp); - tmp=nameL+"="+tmp3; - parse(tmp); - if(Noflg<3, - GLIST=append(GLIST,name+"=Pointdata("+tmp2+")"); - ); - if(Noflg<2, - tmp=[nameL,0,opcindy]; - GCLIST=append(GCLIST,tmp); - if(Noflg==0, - if(length(size)>0, - Com2nd("Setpt("+size+")"); - ); - thick=PenThick/PenThickInit; // 16.04.09 from - if(length(size)>0,tmp1=parse(size),tmp1=1); - tmp1=max(tmp1,1)/8; - Setpen(tmp1); // 16.04.09 upto - Com2nd("Drwpt(list("+name+")"+opstr+")"); - Setpen(thick); // 16.04.09 - if(length(size)>0, - Com2nd("Setpt("+textformat(TenSize/TenSizeInit,1)+")"); - ); - ); - ); - ptlist; -); - -Listplot(nm,list,options):=( -//help:Listplot([A,B]); -// help:Listplot(["A","B"]); -//help:Listplot("1",[[2,1],[3,3]]); -//help:Listplot(options2=["Msg=yes"]); - regional(name,tmp,tmp1,ptlist,Ltype,opcindy,Noflg,eqL,Msg); - if(substring(nm,0,1)=="-", // 16.01.27 from - name=substring(nm,1,length(nm)); - , - name="sg"+nm; - ); // upto - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - eqL=tmp_5; - opcindy=tmp_(length(tmp)); - Msg=1; // 15.09.17 - forall(eqL, - tmp=substring(#,0,1); - if(Toupper(tmp)=="M", - tmp=indexof(#,"="); - tmp1=substring(#,tmp,tmp+1); // 16.06.28 - if(Toupper(tmp1)=="N", // 16.06.28 - Msg=0; - ); - ); - ); - if(Noflg<3, - if(Msg==1, - println("generate Listplot "+name); - ); - if(isstring(list_1),tmp=apply(list,parse(#)),tmp=list); // 15.03.24 - ptlist=apply(tmp,Pcrd(#)); - tmp=name+"="+textformat(ptlist,5); - parse(tmp); - GLIST=append(GLIST,name+"=Listplot("+textformat(list,5)+")"); // 15.12.23 - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - tmp1=apply(list,Lcrd(#)); - tmp1; -); -Listplot(Arg1,Arg2):=( - regional(name,list,options,str); - if(isstring(Arg1), - name=Arg1; - list=Arg2; - Listplot(name,list,[]); - , - list=Arg1; - options=Arg2; - name=""; - forall(list, // 16.10.07from - name=name+#.name; - );// 16.10.07upto - Listplot(name,list,options); - ); -); -Listplot(list):=Listplot(list,[]); - -Lineplot(nm,list,options):=( -//help:Lineplot([A,B]); -//help:Lineplot("1",[[2,1],[3,3]]); - regional(name,Out,tmp,tmp1,opstr,opcindy,Mag,Semi, - Vec,pA,pB,Ltype,Noflg); - name="ln"+nm; - Mag=100; - Semi=""; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - opstr=tmp_(length(tmp)-1); - tmp1=tmp_6; - if(length(tmp1)>0,Mag=tmp1_1); - tmp1=tmp_7; - if(length(tmp1)>0,Semi=tmp1_1); - pA=Lcrd(list_1); pB=Lcrd(list_2); - Vec= Mag/dist(pA,pB)*(pB-pA); - if(length(Semi)==0, - Out=[pA-Vec,pA+Vec]; - , - if(Semi=="+", - Out=[pA,pA+Vec]; - , - Out=[pA-Vec,pA]; - ); - ); - if(Noflg<3, - println("generate Lineplot "+name); - tmp1=apply(Out,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - GLIST=append(GLIST,name+"=Lineplot("+textformat(list,5)+opstr+")"); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Out; -); -Lineplot(Arg1,Arg2):=( - regional(name,list,options,str); - if(isstring(Arg1), - name=Arg1; - list=Arg2; - Lineplot(name,list,[]); - , - list=Arg1; - options=Arg2; - name=""; - forall(list, // 16.10.07from - name=name+#.name; - );// 16.10.07upto - Lineplot(name,list,options); - ); -); -Lineplot(list):=Lineplot(list,[]); - -Plotdata(name1,func,variable):=Plotdata(name1,func,variable,[]); -Plotdata(name1,func,variable,options):=( -//help:Plotdata("1","sin(x)","x",["Num=100"]); -//help:Plotdata("2","x^2","x=[-1,1]"); -//help:Plotdata("3","Fout(x)","x",["out"]); - regional(Fn,Va,tmp,tmp1,tmp2,eqL,name,Vname,x1,x2,dx, - PdL,QdL,Num,Ec,Dc,Fun,Exfun,x,Ke,Eps,Pa, - Ltype,Noflg,Inflg,Outflg,opstr,opcindy); - name="gr"+name1; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - Inflg=tmp_3; - Outflg=tmp_4; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - eqL=tmp_5; - Num=50; - Ec=[]; - Exfun=""; - Dc=1000; - forall(eqL, - tmp=indexof(#,"="); - tmp1=substring(#,tmp,length(#)); - opstr=opstr+",'"+#+"'"; - if(substring(#,0,1)=="N", - Num=parse(tmp1); - ); - if(substring(#,0,1)=="E", - if(substring(tmp1,0,1)=="[", - Ec=parse(tmp1); - , - Exfun=tmp1; - ); - ); - if(substring(#,0,1)=="D", - Dc=parse(tmp1); - ); - ); - if(Inflg==0 & Outflg==0, - Eps=10^(-3); - tmp=replace(func,LFmark,""); - tmp=tokenize(variable,"="); - Vname=tmp_1; - if(length(tmp)>1, - tmp=tmp_2; - tmp=parse(tmp); - x1=tmp_1; - x2=tmp_2; - , - x1=XMIN; - x2=XMAX; - ); - // dx=(x2-x2)/Num; - Ec=append(sort(Ec),10000); - Fun=Assign(func,Vname, "xx"); - Exfun=Assign(Exfun,Vname, "xx"); - PdL=[]; - Ke=1; - forall(0..Num, - xx=x1+#*(x2-x1)/Num; // differs from Scilab ( / Num-1) - if(length(Exfun)>0, - tmp=parse(Exfun); - if(abs(tmp)<Eps, - if(length(Pdt)>0, - PdL=concat(PdL,["inf"]); - ); - ); - , - Pa=[]; - if(xx-Ec_Ke<-Eps, - Pa=[xx,parse(Fun)]; - ); - if(abs(xx-Ec_Ke)<=Eps, - if(length(PdL)>0, - if(PdL_(length(PdL))_1!="inf", - Pa=["inf"]; - ); - ); - ); - if(xx-Ec_Ke>Eps, - Pa=[xx,parse(Fun)]; - Ke=Ke+1; - ); - if(length(Pa)>0, - if(Pa_1=="inf", - PdL=concat(PdL,[Pa]); - , - if(length(PdL)==0, - PdL=[Pa]; - , - tmp=PdL_(length(PdL)); - if(tmp_1=="inf", - PdL=concat(PdL,[Pa]); - , - if(dist(tmp,Pa)<Dc, - PdL=concat(PdL,[Pa]); - , - PdL=concat(PdL,[["inf"],Pa]); - ); - ); - ); - ); - ); - ); - ); - tmp1=[]; - tmp2=select(1..length(PdL),PdL_#==["inf"]); - tmp=1; - forall(tmp2, - if(#>tmp, - tmp1=concat(tmp1,[PdL_(tmp..(#-1))]) - ); - tmp=#+1; - ); - if(tmp<length(PdL), - tmp1=concat(tmp1,[PdL_(tmp..length(PdL))]); - ); - PdL=tmp1; - if(length(PdL)==1, - PdL=PdL_1; - ); - if(Noflg<3, - println("generate Plotdata "+name); - if(MeasureDepth(PdL)==1, - tmp1=apply(PdL,Pcrd(#)); - , - tmp1=[]; - forall(PdL,tmp2, - tmp1=append(tmp1,apply(tmp2,Pcrd(#))); - ); - ); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp1=replace(func,LFmark,""); - tmp2=replace(variable,LFmark,""); - tmp=name+"=Plotdata('"+tmp1+"','"+tmp2+"'"+opstr+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - PdL; - , - // Inflg or Outflg >0 15.05.15 - if(Noflg<3, - if(Outflg==1, - println("Output Plotdata "+name); - tmp=name+"=Plotdata('"+func+"','"+variable+"'"+opstr+")"; - GLIST=append(GLIST,tmp); - SCIWRLIST=append(SCIWRLIST,name); - if(Inflg==0,Inflg=1); // 15.05.17 - ); - if(Inflg==1, - println("Input Plotdata "+name); - if(length(SCIRELIST)==0, - ReadOutData(Fnameout); - ); - tmp=parse(name); - if(islist(tmp), - Extractdata(name,["nodisp"]); // 12.19 - ); - tmp="// "+name+"=Plotdata('"+func+"','"+variable+"'"+opstr+")"; - Com1st(tmp); - SCIRELIST=append(SCIRELIST,name); - ); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - if(Inflg==1, - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - ); - ); -); - -Paramplot(name1,funstr,variable):=Paramplot(name1,funstr,variable,[]); -Paramplot(name1,funstr,variable,options):=( -//help:Paramplot("1","[2*cos(t),sin(t)]","t=[0,2*pi]"); - regional(name,Out,tmp,tmp1,tmp2,vname,func,str,Rng,Num, - Ec,Exfun,Dc,eqL,Fntmp,Vatmp,t1,t2,dt,tt,pa,ke, - Ltype,Noflg,Inflg,Outflg,opstr,opcindy); - name="gp"+name1; - Eps=10^(-4); - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - Inflg=tmp_3; - Outflg=tmp_4; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - eqL=tmp_5; - Num=50; - Ec=[]; - Exfun=""; - Dc=1000; - forall(eqL, - tmp=indexof(#,"="); - tmp1=substring(#,tmp,length(#)); - opstr=opstr+",'"+#+"'"; - if(substring(#,0,1)=="N", - Num=parse(tmp1); - ); - if(substring(#,0,1)=="E", - if(substring(tmp1,0,1)=="[", - Ec=parse(tmp1); - , - Exfun=tmp1; - ); - ); - if(substring(#,0,1)=="D", - Dc=parse(tmp1); - ); - ); - if(Inflg==0 & Outflg==0, - tmp=indexof(variable,"="); - vname=substring(variable,0,tmp-1); - str=substring(variable,tmp,length(variable)); - Rng=parse(str); - t1=Rng_1; t2=Rng_2; - dt=(t2-t1)/Num;// differs from Scilab ( / Num-1) - func=Assign(funstr,vname,"tt"); - Out=[]; - Ec=append(sort(Ec),10000); - ke=1; - forall(0..Num, - pt=[]; - tt=Rng_1+#*dt; - if(tt-Ec_ke<-Eps, - pa=parse(func); - ); - if(abs(tt-Ec_ke)<=Eps, - if(length(Out)>0, - if(Out_(length(Out))_1!="inf", - pa=["inf"]; - ); - ); - ); - if(tt-Ec_ke>Eps, - pa=parse(func); - ke=ke+1; - ); - if(length(pa)>0, - if(pa_1=="inf", - Out=append(Out,pa); - , - if(length(Out)==0, - Out=[pa]; - , - tmp=Out_(length(Out)); - if(tmp_1=="inf", - Out=append(Out,pa); - , - if(|tmp-pa|<Dc, - Out=append(Out,pa); - , - Out=concat(Out,[["inf"],pa]); - ); - ); - ); - ); - ); - ); - tmp1=[]; - tmp2=select(1..length(Out),Out_#==["inf"]); - tmp=1; - forall(tmp2, - if(#>tmp, - tmp1=concat(tmp1,[Out_(tmp..(#-1))]) - ); - tmp=#+1; - ); - if(tmp<length(Out), - tmp1=concat(tmp1,[Out_(tmp..length(Out))]); - ); - Out=tmp1; - if(length(Out)==1, - Out=Out_1; - ); - if(Noflg<3, - println("generate Paramplot "+name); - if(MeasureDepth(Out)==1, - tmp1=apply(Out,Pcrd(#)); - , - tmp1=[]; - forall(Out,tmp2, - tmp1=append(tmp1,apply(tmp2,Pcrd(#))); - ); - ); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp1=replace(funstr,LFmark,""); // 15.11.13 - tmp2=replace(variable,LFmark,""); - tmp=name+"=Paramplot('"+tmp1+"','"+tmp2+"'"+opstr+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Out; - , - // Inflg or Outflg >0 15.05.15 - if(Noflg<3, - if(Outflg==1, - println("Output Paramplot "+name); - tmp=name+"=Paramplot('"+funstr+"','"+variable+"'"+opstr+")"; - GLIST=append(GLIST,tmp); - SCIWRLIST=append(SCIWRLIST,name); - if(Inflg==0,Inflg=1); // 15.05.17 - ); - if(Inflg==1, - println("Input Paramplotdata "+name); - if(length(SCIRELIST)==0, - ReadOutData(Fnameout); - ); - tmp=parse(name); - if(islist(tmp), - Extractdata(name,["nodisp"]); // 12.19 - ); - tmp="// "+name+"=Paramplot('"+func+"','"+variable+"'"+opstr+")"; - Com1st(tmp); - SCIRELIST=append(SCIRELIST,name); - ); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - if(Inflg==1, - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - ); - ); -); - -Circledata(cenrad):=Circledata(cenrad,[]); -Circledata(para1,para2):=( -//help:Circledata([A,B],["Rng=[0,pi/2]"]); -//help:Circledata([A,B,C]); - regional(name,cenrad,options,str,n); - if(isstring(para1), - name=para1; - cenrad=para2; - options=[]; - , - cenrad=para1; - options=para2; - name="";// 16.10.07from - forall(cenrad, - name=name+#.name; - );// 16.10.07upto - ); - Circledata(name,cenrad,options); -); -Circledata(nm,cenrad,options):=( - regional(name,Out,Ctr,Ptcir,ra,Num,Rg,opstr,opcindy, - tmp,tmp1,tmp1,Th,Ltype,Noflg,eqL,pA,pB,pC,d1,d2,Eps); - name="cr"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - eqL=tmp_5; - Num=50; - Rg=[0,2*pi]; - forall(eqL, - tmp=indexof(#,"="); - tmp1=substring(#,tmp,length(#)); - opstr=opstr+",'"+#+"'"; - if(substring(#,0,1)=="N", - Num=parse(tmp1); - ); - if(substring(#,0,1)=="R", - Rg=parse(tmp1); - ); - ); - if(length(cenrad)==2, - Ctr=Lcrd(cenrad_1); - Ptcir=Lcrd(cenrad_2); - ra=dist(Ctr,Ptcir); - , - Eps=10^(-1); - pA=Lcrd(cenrad_1); - pB=Lcrd(cenrad_2); - pC=Lcrd(cenrad_3); - tmp=pB-pA; - tmp1=(tmp_2,-tmp_1); - tmp=pC-pB; - tmp2=(tmp_2,-tmp_1); - d1=det([tmp1,tmp2]); - d2=det([pC-pA,tmp2]); - if(abs(d1)<Eps & abs(d2)>10*Eps, - println("points are in a line"); - ra=0; - , - Ctr=1/2*(pA+pB)+1/2*d2/d1*tmp1; - ra=|pA-Ctr|; - tmp=name+"center="+Ctr; - parse(tmp); - Defvar(name+"center",Ctr); - ); - ); - if(ra>0, - Out=[]; - forall(0..Num, - Th=Rg_1+#*(Rg_2-Rg_1)/Num; - Out=append(Out,Ctr+ra*[cos(Th),sin(Th)]); - ); - , - Out=Lineplot("1",[pA,pB],["nodata"]); - ); - if(Noflg<3, - println("generate Circledata "+name); - tmp1=apply(Out,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - if(length(cenrad)==2, - tmp=name+"=Circledata("+cenrad+opstr+")"; - , - if(ra>0, - tmp=name+"=Circledata(["+Ctr+","+cenrad_1+"]"+opstr+")"; - , - tmp=name+"=Lineplot("+cenrad_1+","+cenrad_2+")"; - ); - ); - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Out; -); - -Framedata():=( - regional(pA,pB); - pA=LLcrd((SW+NE)/2); // 15.09.17 - pB=LLcrd(NE); - Framedata("win",[pA,pB]); -); -Framedata(list):=Framedata(list,[]); -Framedata(Arg1,Arg2):=( - regional(name,list,options,str); - if(isstring(Arg1), - name=Arg1; - list=Arg2; - Framedata(name,list,[]); - , - list=Arg1; - options=Arg2; - name="";// 16.10.07from - forall(list, - name=name+#.name; - );// 16.10.07upto - Framedata(name,list,options); - ); -); - -Framedata(nm,list,options):=( -//help:Framedata(); -//help:Framedata([A,B]); -//help:Framedata("1",[A,B]); -//help:Framedata("1",[C,dx,dy]); - regional(name,Out,tmp,tmp1,pB,x1,x2,y1,y2,dx,dy, - opcindy,Ltype,Noflg,cent,dx,dy); - name="fr"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - if(length(list)==2, // 15.05.12 - pA=Lcrd(list_1); pB=Lcrd(list_2); - dx=abs(pB_1-pA_1); dy=abs(pB_2-pA_2); - , - pA=Lcrd(list_1); - dx=list_2; dy=list_3; - ); - x1=pA_1-dx; x2=pA_1+dx; - y1=pA_2-dy; y2=pA_2+dy; - Out=[[x1,y1],[x2,y1],[x2,y2],[x1,y2],[x1,y1]]; - if(Noflg<3, - println("generate Framedata "+name); - tmp1=apply(Out,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - GLIST=append(GLIST,name+"=Framedata("+pA+","+dx+","+dy+")"); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Out; -); -Framedata(nm,cent,dx,dy):=Framedata(nm,cent,dx,dy,[]); -Framedata(nm,cent,dx,dy,options):=( - regional(name,Out,tmp,tmp1,x1,y1,x2,y2,Ltype,opcindy,Noflg); - name="fr"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - x1=cent.x-dx; x2=cent.x+dx; - y1=cent.y-dy; y2=cent.y+dy; - Out=[[x1,y1],[x2,y1],[x2,y2],[x1,y2],[x1,y1]]; - if(Noflg<3, - println("generate Framedata "+name); - tmp1=apply(Out,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - GLIST=append(GLIST,name+"=Framedata("+cent.xy+","+dx+","+dy+")"); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Out; -); - -Framedata2(nm,list):=Framedata2(nm,list,[]); -Framedata2(nm,list,options):=( -//help:Framedata2("1",[A,B]); - regional(tmp,tmp1,pC,pB); - pC=(Lcrd(list_1)+Lcrd(list_2))/2; - pB=Lcrd(list_2); - Framedata(nm,[pC,pB],options); -); - -Ovaldata(nm,Pdata):=Ovaldata(nm,Pdata,[]); -Ovaldata(nm,Pdata,options):=( -//help:Ovaldata("1",[A,B]); -//help:Ovaldata(optios=[size]); - regional(name,Graph,Ctr,Dx,Dy,Rc,Out,Point,Graph, - opstr,opcindy,tmp,tmp1,tmp2,tmp3,Ltype,Noflg); - name="ov"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - opstr=tmp_(length(tmp)-1); - Rc=0.2; - tmp1=tmp_6; - if(length(tmp1)>0,Rc=tmp1_1*Rc); -// if(length(tmp1)>0,Rc=tmp1_1); //15.11.15 - Ctr=Lcrd(Pdata_1); - if(ispoint(Pdata_2) % islist(Pdata_2), - tmp1=Lcrd(Pdata_2); - Dx=abs(tmp1_1-Ctr_1); - Dy=abs(tmp1_2-Ctr_2); - , - Dx=Pdata_2; - Dy=Pdata_3; - ); - Point=Ctr+[Dx-Rc,Dy-Rc]; - tmp1=Circledata("1",[Point,Point+[Rc,0]], - ["Rng=[0,pi/2]","Num=10","nodata"]); - tmp2=Listplot("1",[Ctr+[Dx-Rc,Dy],Ctr+[0,Dy]], - ["nodata"]); - tmp3=Listplot("2",[Ctr+[Dx,0],Ctr+[Dx,Dy-Rc]], - ["nodata"]); - Graph=Joincrvs("1",[tmp3,tmp1,tmp2],["nodata"]); - tmp1=Reflectdata("1",[Graph],[Ctr,Ctr+[0,1]],["nodata"]); - Graph=Joincrvs("1",[Graph,tmp1],["nodata"]); - tmp2=Reflectdata("2",[Graph],[Ctr,Ctr+[1,0]], - ["nodata"]); - Graph=Joincrvs("2",[Graph,tmp2],["nodata"]); - if(Noflg<3, - println("generate Ovaldata "+name); - tmp1=apply(Graph,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - GLIST=append(GLIST, - name+"=Ovaldata("+Ctr+","+Dx+","+Dy+opstr+")");//16.01.30 - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - tmp1=apply(Graph,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp=textformat(Ctr,5)+","+textformat(Dx,5)+","+textformat(Dy,5); - GLIST=append(GLIST, - name+"=Ovaldata("+tmp+opstr+")"); - ); - Graph; -); - -Segmark(nm,ptlist):=Segmark(nm,ptlist,[]); -Segmark(nm,ptlist,options):=Drawsegmark(nm,ptlist,options); -Drawsegmark(nm,ptlist):=Drawsegmark(nm,ptlist,[]); -Drawsegmark(nm,ptlist,options):=( -//help:Segmark("1",[A,B]); -//help:Segmark(options=["Type=1","Width=1","Size=1"]); - regional(name,pA,pB,wid,mid,size,tp,dir,nor,eqL, - tmp,tmp1,tmp2); - name="mrk"+nm; - pA=ptlist_1; - pB=ptlist_2; - size=0.15; - wid=0.05; - tp=1; - tmp1=Divoptions(options); - eqL=tmp1_5; - forall(eqL, - tmp=indexof(#,"="); - tmp1=substring(#,tmp,length(#)); - tmp1=parse(tmp1); - tmp=substring(#,0,1); - if(tmp=="S" % tmp=="s", - size=size*tmp1; - ); - if(tmp=="W" % tmp=="w", - wid=wid*tmp1; - ); - if(tmp=="T" % tmp=="t", - tp=tmp1; - ); - ); - mid=(pA+pB)/2; - dir=(pB-pA)/|pB-pA|; - nor=[-dir_2,dir_1]; -// nor=nor/|nor|; - if(tp==1, - tmp1=mid+size*nor; - tmp2=mid-size*nor; - Listplot(name,[tmp1,tmp2]); - ); - if(tp==2, - tmp1=mid+wid*dir+size*nor; - tmp2=mid+wid*dir-size*nor; - Listplot(name+"r",[tmp1,tmp2]); - tmp1=mid-wid*dir+size*nor; - tmp2=mid-wid*dir-size*nor; - Listplot(name+"l",[tmp1,tmp2]); - ); - if(tp==3, - tmp1=mid; - tmp2=mid+size*dir; - Circledata(name,[tmp1,tmp2]); - ); - if(tp==4, - tmp=mid+size*2/sqrt(3)*nor; - tmp1=mid+size*dir-size/sqrt(3)*nor; - tmp2=mid-size*dir-size/sqrt(3)*nor; - Listplot(name,[tmp,tmp1,tmp2,tmp]); - ); -); - -Parabolaplot(nm,ptlist):=Parabolaplot(nm,ptlist,"[-5,5]",[]); -Parabolaplot(nm,ptlist,Arg):=( - regional(rng,options); - if(isstring(Arg), - rng=Arg; - options=[]; - , - rng="[-5,5]"; - options=Arg; - ); - Parabolaplot(nm,ptlist,rng,options); -); -Parabolaplot(nm,ptlist,rng,options):=( -//help:Parabolaplot("1",[A,B,C]): -//help:Parabolaplot("1",[A,B,C],"[-5,5]"); - regional(pA,pB,pC,angle,tmp,tmp1,tmp2); - tmp1=Lcrd(ptlist_1); - tmp2=Lcrd(ptlist_3); - pB=Lcrd(ptlist_2); - tmp=(tmp2-pB)/|tmp2-pB|; - if(tmp_2>=0, - angle=arccos(tmp_1); - , - if(tmp_1>=0, - angle=arcsin(tmp_2); - , - angle=-arccos(tmp_1); - ); - ); - pA=Rotatepoint(tmp1,-angle,pB); - pC=Rotatepoint(tmp2,-angle,pB); - tmp1=1/(2*(pA_2-pB_2)); - tmp2=1/2*(pA_2+pB_2); - tmp="("+format(tmp1,5)+")*(x-("+format(pA_1,5)+"))^2"; - tmp=tmp+"+("+format(tmp2,5)+")"; - tmp1=parse(rng); - tmp1=[pA_1-(tmp1_2-tmp1_1)/2,pA_1+(tmp1_2-tmp1_1)/2]; - tmp2="x="+textformat(tmp1,5); - Plotdata(nm+"para",tmp,tmp2,append(options,"nodisp")); - Rotatedata(nm+"para","gr"+nm+"para",angle,append(options,pB)); -); - -Ellipseplot(nm,ptlist):=Ellipseplot(nm,ptlist,"[0,2*pi]",[]); -Ellipseplot(nm,ptlist,Arg):=( - regional(rng,options); - if(isstring(Arg), - rng=Arg; - options=[]; - , - rng="[0,2*pi]"; - options=Arg; - ); - Ellipseplot(nm,ptlist,rng,options); -); -Ellipseplot(nm,ptlist,rng,options):=( -//help:Ellipseplot("1",[A,B,3]); -//help:Ellipseplot("1",[A,B,C],"[0,pi]",[options]); - regional(pA,pB,d,angle,f,a,b,pM,tmp,tmp1,tmp2); - pA=Lcrd(ptlist_1); - tmp1=Lcrd(ptlist_2); - if(ispoint(ptlist_3), - tmp2=Lcrd(ptlist_3); - d=|tmp2-pA|+|tmp2-tmp1|; - , - d=ptlist_3; - ); - tmp=(tmp1-pA)/|tmp1-pA|; - if(tmp_2>=0, - angle=arccos(tmp_1); - , - if(tmp_1>=0, - angle=arcsin(tmp_2); - , - angle=-arccos(tmp_1); - ); - ); - pB=Rotatepoint(tmp1,-angle,pA); - f=|pB_1-pA_1|/2; - a=d/2; - b=sqrt(d^2/4-f^2); - pM=(pA+pB)/2; - tmp="["+format(pM_1,5)+","+format(pM_2,5)+"]"; - tmp=tmp+"+["+format(a,5)+"*cos(t),"+format(b,5)+"*sin(t)]"; - Paramplot(nm+"elp",tmp,"t="+rng,append(options,"nodisp")); - Rotatedata(nm+"elp","gp"+nm+"elp",angle,append(options,pA)); -); - -Hyperbolaplot(nm,ptlist):=Hyperbolaplot(nm,ptlist,"[-5/2,5/2]",[]); -Hyperbolaplot(nm,ptlist,Arg):=( - regional(rng,options); - if(isstring(Arg), - rng=Arg; - options=[]; - , - rng="[-5/2,5/2]"; - options=Arg; - ); - Hyperbolaplot(nm,ptlist,rng,options); -); -Hyperbolaplot(nm,ptlist,rng,optionsorg):=( -//help:Hyperbolaplot("1",[A,B,C],["Num=200"]): -//help:Hyperbolaplot("1",[A,B,C],"[-5,5]",["Asy=do"]); - regional(pA,pB,d,angle,f,a,b,pM,eqL,options,opasy,tmp,tmp1,tmp2); - tmp=Divoptions(optionsorg); - eqL=tmp_5; - options=optionsorg; - opasy=[]; - forall(eqL, - if(Toupper(substring(#,0,1))=="A", - tmp=indexof(#,"="); - opasy=[substring(#,tmp,length(#))]; - options=remove(options,[#]); - ); - ); - pA=Lcrd(ptlist_1); - tmp1=Lcrd(ptlist_2); - if(ispoint(ptlist_3), - tmp2=Lcrd(ptlist_3); - d=abs(|tmp2-pA|-|tmp2-tmp1|); - , - d=ptlist_3; - ); - tmp=(tmp1-pA)/|tmp1-pA|; - if(tmp_2>=0, - angle=arccos(tmp_1); - , - if(tmp_1>=0, - angle=arcsin(tmp_2); - , - angle=-arccos(tmp_1); - ); - ); - pB=Rotatepoint(tmp1,-angle,pA); - f=|pB_1-pA_1|/2; - a=d/2; - b=sqrt(f^2-d^2/4); - pM=(pA+pB)/2; - tmp="["+format(pM_1,5)+"+"+format(a,5)+"*(exp(t)+exp(-t))/2,"; - tmp=tmp+format(pM_2,5)+"+"+format(b,5)+"*(exp(t)-exp(-t))/2]"; - Paramplot(nm+"hyp1",tmp,"t="+rng,append(options,"nodisp")); - tmp="["+format(pM_1,5)+"-"+format(a,5)+"*(exp(t)+exp(-t))/2,"; - tmp=tmp+format(pM_2,5)+"+"+format(b,5)+"*(exp(t)-exp(-t))/2]"; - Paramplot(nm+"hyp2",tmp,"t="+rng,append(options,"nodisp")); - tmp=["gp"+nm+"hyp1","gp"+nm+"hyp2"]; - Rotatedata(nm+"hyp",tmp,angle,append(options,pA)); - if(length(opasy)>0, - Lineplot(nm+"asy1",[pM+[a,b],pM+[-a,-b]],["nodisp"]); - Lineplot(nm+"asy2",[pM+[-a,b],pM+[a,-b]],["nodisp"]); - tmp=["ln"+nm+"asy1","ln"+nm+"asy2"]; - Rotatedata(nm+"asy",tmp,angle,append(opasy,pA)); - ); -); - -Polygonplot(nm,ptlist,number):=Polygonplot(nm,ptlist,number,[]); -Polygonplot(nm,ptlist,number,options):=( -//help:Polygonplot("1",[A,B],12); - regional(rr,pA,pB,ptL,angle,tmp,tmp1,tmp2); - pA=Lcrd(ptlist_1); - pB=Lcrd(ptlist_2); - rr=|pB-pA|; - tmp=(pB-pA)/rr; - if(tmp_2>=0, - angle=arccos(tmp_1); - , - if(tmp_1>=0, - angle=arcsin(tmp_2); - , - angle=-arccos(tmp_1); - ); - ); - ptL=[]; - forall(0..number, - tmp=angle+#*2*pi/number; - tmp1=pA+rr*[cos(tmp),sin(tmp)]; - if(#>0 & #<number, - Putpoint((ptlist_2).name+text(#),tmp1);//16.10.07 - //Pointdata(nm,ptL); - ); - tmp2=tmp1; - ptL=append(ptL,tmp1); - ); - Listplot(nm+"ply",ptL,options); -); - -Putintersect(nm,pdata1,pdata2):=( -//help:Putintersect("Q","gr1","gr2"); - regional(pd1,pd2,tmp); - if(isstring(pdata1),pd1=parse(pdata1),pd1=pdata1); - if(isstring(pdata2),pd2=parse(pdata2),pd2=pdata2); - tmp=Intersectcrvs(pd1,pd2); - if(length(tmp)==1, - Putpoint(nm,tmp_1); - , - if(length(tmp)==0, - err("No intersect point"); - , - err("Multiple intersect points"); - println(tmp); - err("Choose point number"); - ); - ); -); -Putintersect(nm,pdata1,pdata2,ptno):=( - regional(pd1,pd2,tmp); - if(isstring(pdata1),pd1=parse(pdata1),pd1=pdata1); - if(isstring(pdata2),pd2=parse(pdata2),pd2=pdata2); - tmp=Intersectcrvs(pd1,pd2); - if(length(tmp)>0, - Putpoint(nm,tmp_ptno); - , - err("No intersect point"); - ); -); - -Arrowheaddata(point,direction):=Arrowheaddata(point,direction,[]); -Arrowheaddata(point,direction,options):=( -//help:Arrowheaddata(A,B); - regional(list,Ookisa,Hiraki,Futosa,Houkou,Str,Flg,tmp,Ev,Nv,pA,pB, - pP,rF,gG,Flg,Nj,Eps,tmp1,scx,scy); - Eps=10^(-3); - pP=point; - Ookisa=0.2*YaSize; - Hiraki=YaAngle; - Futosa=0; - Str=YaStyle; - tmp=Divoptions(options); - tmp1=tmp_6; - if(length(tmp1)>0,Ookisa=Ookisa*tmp1_1); - if(length(tmp1)>1, - tmp=tmp1_2; - if(tmp<5, - Hiraki=Hiraki*tmp; - , - Hiraki=tmp; - ); - ); - Flg=0; - Hiraki=Hiraki*pi/180; - if(isstring(direction),Houkou=parse(direction),Houkou=direction); - if(MeasureDepth(Houkou)==2,Houkou=Houkou_1); - if(islist(Houkou_1), -// pP=Lcrd(pP); -// pP=Doscaling(pP); -// Houkou=Dosscaling(Houkou); - pP=Pcrd(pP); - scy=SCALEY; - SCALEY=1; - tmp=Nearestpt(pP,Houkou); - pA=tmp_1; - rF=floor(tmp_2); - if(rF==1, - if(|Ptend(Houkou)-Ptstart(Houkou)|<Eps, - rF=Numptcrv(Houkou); - ); - ); - gG=apply(0..10,pP+Ookisa*cos(Hiraki)*[cos(2*pi/10*#),sin(2*pi/10*#)]); - Flg=0; - forall(1..rF,Nj, - if(Flg==0, - pB=Ptcrv(rF+1-Nj,Houkou); - tmp=IntersectcrvsPp([pA,pB],gG); - if(length(tmp)>0, - Houkou=pP-tmp_1_1; - Flg=1; - ); - pA=pB; - ); - ); - SCALEY=scy; - if(Flg==0, - println("Arrowhead may be too large (no intersect)"); - Flg=2; - ); - if(Flg==1, - Houkou=Unscaling(Houkou); - pP=Unscaling(pP); - ); - ); - if(Flg<2, -// pP=Doscaling(pP); -// Houkou=Doscaling(Houkou); - pP=Pcrd(pP); - if(!ispoint(point), - Houkou=Pcrd(Houkou); - ); -// if(MeasureDepth(Houkou)==0,Houkou=Pcrd(Houkou)); - Ev=-1/|Houkou|*Houkou; - Ev=Lcrd(Ev); - Nv=[-Ev_2, Ev_1]; - if(indexof(Str,"c")>0, - pP=pP-0.5*Ookisa*cos(Hiraki)*Ev; - ); - if(indexof(Str,"b")>0, - pP=pP-Ookisa*cos(Hiraki)*Ev; - ); - pA=pP+Ookisa*cos(Hiraki)*Ev+Ookisa*sin(Hiraki)*Nv; - pB=pP+Ookisa*cos(Hiraki)*Ev-Ookisa*sin(Hiraki)*Nv; - list=[pA,pP,pB]; - list=apply(list,LLcrd(#)); -// Out=Unscaling(Out); - list; - ); -); - -Arrowhead(point,Houkou):=Arrowhead(point,Houkou,[]); -Arrowhead(point,Houkou,options):=( -//help:Arrowhead(B,B-A,[1.5,30]); -//help:Arrowhead(A,"gr1"); - // global ArrowheadNumber - regional(name,Ltype,Noflg,reL,opstr,opcindy,ptstr,hostr,tmp,tmp1,list); - name="arh"+text(ArrowheadNumber); - ArrowheadNumber=ArrowheadNumber+1; - ptstr=textformat(point,5); - if(isstring(Houkou), // 15.01.11 - tmp=parse(Houkou); - if(MeasureDepth(tmp)<2, - hostr=Houkou; - , - hostr=Houkou+"(1)"; - ); - , - if(ispoint(point), - hostr=textformat(LLcrd(Houkou),5); - , - hostr=textformat(Houkou,5); - ); - ); - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - reL=tmp_6; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - list=Arrowheaddata(point,Houkou,options); - if(Noflg<3, -// println("generate Arrowhead "+name); - tmp1=apply(list,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); -// GLIST=append(GLIST,name+"=Listplot("+list+")"); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(1)+Ltype,name); - , -// if(Noflg==1,Ltype=0); - Ltype=0; - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - if(Noflg==0, - if(length(reL)<3, // 16.04.09 from - forall(1..(2-length(reL)), - opstr=opstr+",1"; - ); - tmp=PenThick/PenThickInit; - opstr=opstr+","+text(tmp); - ); // 16.04.09 upto - Com2nd("Arrowhead("+ptstr+","+hostr+opstr+")"); - ); -); - -Arrowdata(ptlist):=Arrowdata(ptlist,[]); -Arrowdata(Arg1,Arg2):=( - regional(tmp,nm,ptlist,flg,pA,pB,options); - flg=0; - if(isstring(Arg1), - nm=Arg1; - ptlist=Arg2; - Arrowdata(nm,ptlist,[]); - flg=1; - ); - if(flg==0, - tmp=MeasureDepth(Arg1); - if(tmp==0, - pA=Arg1; - pB=Arg2; - Arrowdata(pA,pB,[]); - , - ptlist=Arg1; - options=Arg2; - nm=text(ArrowlineNumber); - ArrowlineNumber=ArrowlineNumber+1; - Arrowdata(nm,ptlist,options); - ); - ); -); -Arrowdata(Arg1,Arg2,options):=( -//help:Arrowdata([A,B],[2,10]); - regional(Retflg,nm,ptlist,name,opstr,opcindy,realL,strL,size, - flg,Ltype,Noflg,lineflg,tmp,tmp1,tmp2,pA,pB,segpos); - Retflg=0; - Noflg=0; - Ltype=0; - if(!isstring(Arg1), - pA=Arg1; - pB=Arg2; - Arrowdata(pA,pB,options,"old"); - Retflg=1; - ptlist=[pA,pB]; - ); - if(Retflg==0, - nm=Arg1; - ptlist=Arg2; - name="ar"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - realL=tmp_6; - strL=tmp_7; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - size=1; // 15.06.11 - if(length(realL)>0, - size=realL_1; - ); - tmp2=select(strL,indexof(#,"l")>0); // 16.04.09 - if(length(tmp2)>0,lineflg=1,lineflg=0); // 16.04.09 - segpos=1; - tmp1=tmp_5; - if(length(tmp1)>2, - segpos=tmp1_3; - ); - if(Noflg<3, -// println("generate Arrowdata "+name); - tmp1=apply(ptlist,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp1=Pcrd(ptlist_1);//16.10.20 - tmp2=Pcrd(ptlist_2);//16.10.20 - if(lineflg==0, // 16.04.09 from - tmp=tmp2-0.2*size/2*(tmp2-tmp1)/|tmp2-tmp1|; // 15.06.11 - , - tmp=tmp2; - ); // 16.04.09 upto - tmp=[LLcrd(tmp1),LLcrd(tmp)];//16.10.20 - GLIST=append(GLIST,name+"=Listplot("+textformat(tmp,5)+")"); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - tmp=textformat(ptlist,5); - tmp=substring(tmp,1,length(tmp)-1); - tmp1=indexof(tmp,"],["); - if(tmp1>0, - pA=substring(tmp,0,tmp1); - pB=substring(tmp,tmp1+1,length(tmp)); - , - tmp1=indexof(tmp,","); - pA=substring(tmp,0,tmp1-1); - pB=substring(tmp,tmp1,length(tmp)); - ); - tmp1="Lcrd("+pA+")+" - +textformat(segpos,5)+"*(Lcrd("+pB+")-"+"Lcrd("+pA+"))"; - tmp1=parse(tmp1); - tmp2="Lcrd("+pB+")-Lcrd("+pA+")"; - tmp2=parse(tmp2); - Arrowhead(tmp1,tmp2,options); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - ); - ptlist; -); -Arrowdata(pA,pB,options,str):=( - regional(ptA,ptB,opstr,Astr,Bstr,name,tmp,opcindy); - Astr=textformat(pA,5); - Bstr=textformat(pB,5); - name="ar"+pA.name+pB.name; - println("generate Arrow "+name); - opstr=""; - opcindy=""; - forall(options, - if(isstring(#), - if(indexof(#,"->")>0, - opcindy=opcindy+","+#; - , - tmp="'"+#+"'"; - ); - , - tmp=text(#); - ); - opstr=opstr+","+tmp; - ); - ptA=Lcrd(pA); - ptB=Lcrd(pB); - Arrowheaddata(ptB,ptB-ptA,options); - tmp="connect("+textformat([ptA,ptB],5) - +",linecolor->"+text(KCOLOR)+opcindy+");"; - parse(tmp); // 14.11.17 - Com2nd("Arrowline("+Astr+","+Bstr+opstr+")"); // 14.10.04 -); - -Anglemark(plist):=Anglemark(plist,[]); -Anglemark(Arg1,Arg2):=( // 2015.04.28 from - regional(nm,plist,options,tmp); - if(isstring(Arg1), - nm=Arg1; - plist=Arg2; - Anglemark(nm,plist,[]); - , - plist=Arg1; - options=Arg2; - tmp=textformat(plist,5); - tmp=replace(tmp,",",""); - nm=substring(tmp,1,length(tmp)-1); - Anglemark(nm,plist,options); - ); -); // upto -Anglemark(nm,plist,options):=( -//help:Anglemark([A,B,C],["E=\theta",2]); -//help:Anglemark("1",[A,B,C],["E=1.2,\theta",2]); -//help:Anglemark(options=["E/L=(sep,)letter",size]); - regional(name,Out,pB,pA,pC,Ctr,ra,sab,sac,ratio,opstr,Bname,Bpos, - Brat,tmp,tmp1,tmp2,Num,opcindy,Ltype,eqL,realL,Rg,Th,Noflg); - name="ag"+nm; - ra=0.5; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - eqL=tmp_5; - realL=tmp_6; - Bname=""; - Brat=1.5; - Num=20; - if(length(realL)>0, - ra=realL_1*ra; - opstr=opstr+","+text(realL_1); - ); - forall(eqL, - if(substring(#,0,1)=="L",Bname="Letter("); - if(substring(#,0,1)=="E",Bname="Expr("); - Bpos="md"+name; - Bname=Bname+Bpos+","+Dq+"c"+Dq+","+Dq;//16.10.29 - tmp=substring(#,indexof(#,"="),length(#)); - tmp1=indexof(tmp,","); - Bname=Bname+substring(tmp,tmp1,length(tmp))+Dq+")"; - if(tmp1>0, - Brat=parse(substring(tmp,0,tmp1-1)); - ); - ); - pB=Lcrd(plist_1); pA=Lcrd(plist_2); pC=Lcrd(plist_3); - Ctr=Lcrd(pA); - sab=pB-pA; - sac=pC-pA; - Rg=[arctan2(sab)+0,arctan2(sac)+0]; - if(Rg_2<Rg_1,Rg_2=Rg_2+2*pi); - Out=[]; - forall(0..Num, - Th=Rg_1+#*(Rg_2-Rg_1)/Num; - Out=append(Out,Ctr+ra*[cos(Th),sin(Th)]); - ); - if(length(Bname)>0, - Th=(Rg_1+Rg_2)/2; - tmp1=Ctr+Brat*ra*[cos(Th),sin(Th)]; - tmp="Defvar("+Dq+Bpos+"="; - tmp=tmp+textformat(tmp1,5)+Dq+");"; - parse(tmp); - parse(Bname); - ); - if(Noflg<3, - println("generate anglemark "+name); - tmp1=apply(Out,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp=textformat(plist,5); - tmp1=substring(tmp,1,length(tmp)-1); - tmp=name+"=Anglemark("+tmp1+opstr+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Out; -); - -Paramark(plist):=Paramark(plist,[]); -Paramark(plist,options):=( -//help:Paramark([A,B,C],["E=\theta"]); - regional(name,Out,pB,pA,pC,ra,sab,sac,ratio,opstr,Bname,Bpos, - Brat,tmp,tmp1,tmp2,Ltype,Noflg,eqL,realL,opcindy); - tmp=textformat(plist,5); - tmp=replace(tmp,",",""); - tmp=substring(tmp,1,length(tmp)-1); - name="pm"+tmp; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - eqL=tmp_5; - realL=tmp_6; - ra=0.5; - Bname=""; - Brat=1.2; - if(length(realL)>0, - tmp=realL_1; - ra=tmp*ra; - opstr=opstr+","+text(tmp); - ); - forall(eqL, - if(substring(#,0,1)=="L",Bname="Letter("); - if(substring(#,0,1)=="E",Bname="Expr("); - Bpos="md"+name; - Bname=Bname+Dq+Bpos+Dq+","+Dq+"c"+Dq+","+Dq; - tmp=substring(#,indexof(#,"="),length(#)); - tmp1=indexof(tmp,","); - Bname=Bname+substring(tmp,tmp1,length(tmp))+Dq+")"; - if(tmp1>0, - Brat=parse(substring(tmp,0,tmp1-1)); - ); - ); - pB=Lcrd(plist_1); pA=Lcrd(plist_2); pC=Lcrd(plist_3); - Ctr=Lcrd(pA); - Out=[]; - Out=append(Out,pA+ra*(pB-pA)/|pB-pA|); - Out=append(Out,pA+ra*(pB-pA)/|pB-pA|+ra*(pC-pA)/|pC-pA|); - Out=append(Out,pA+ra*(pC-pA)/|pC-pA|); - if(length(Bname)>0, - tmp1=pA+Brat*ra*(pB-pA)/|pB-pA|+Brat*ra*(pC-pA)/|pC-pA|; - tmp="Defvar("+Dq+Bpos+"="+textformat(tmp1,5)+Dq+");"; - parse(tmp); - parse(Bname); - ); - if(Noflg<3, - println("generate paramark "+name); - tmp1=apply(Out,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp1=substring(textformat(plist,5),1,length(textformat(plist,5))-1); - tmp=name+"=Paramark("+tmp1+opstr+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - Out; -); - -MakeBowdata(pA,pB,Hgt):=( - regional(angle,pB2,pH2,pC2,pC,tmp,Th1,Th2,ra,dMA); - angle=arctan2(pB-pA)+0; - pB2=Rotatepoint(pB,-angle,pA); - tmp=Lcrd(pA); - pH2=[(tmp_1+pB2_1)/2,tmp_2-Hgt]; - dMA=|tmp-pB2|/2; - ra=(dMA^2+Hgt^2)/(2*Hgt); - pC2=[pH2_1,pB2_2+(ra-Hgt)]; - pC=Rotatepoint(pC2,angle,pA); - Th1=arctan2(pA-pC2)+angle; - Th2=arctan2(pB2-pC2)+angle; - [pC,ra,Th1,Th2]; -); - -Bowdata(nm,plist,options):=( -//help:Bowdata([C,A],[2,1.2,"Expr=10","da"]); -//help:Bowdata([A,B],["Expr=t0n3,a"]); -//help:Bowdata([A,B],["Exprrot=t0n2r,a"]); - regional(name,Out,pB,pA,pC,ra,tmp,tmp1,tmp2,Ltype,eqL,realL, - Bname,Bpos,Th,Cut,Num,Hgt,opstr,opcindy,Ydata,pC, - Th1,Th2,Noflg,Bops,Bmov,Tmov,Nmov,rev); - name="bw"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - eqL=tmp_5; - realL=tmp_6; - pA=Lcrd(plist_1); pB=Lcrd(plist_2); - Hgt=1/2*|pB-pA|*0.2; - Cut=0; - Num=24; - Bname=""; - Tmov=0;//16.11.01from - Nmov=0; - Bmov=""; - rev=0;//16.11.01upto - if(length(realL)>0, - Hgt=realL_1*Hgt; // 15.04.12 - if(length(realL)>1,Cut=realL_2); - ); - forall(eqL, - tmp=substring(#,0,1); - if(tmp=="L" % tmp=="l", - if(indexof(#,"rot")>0, - Bname="Letterrot("; - , - Bname="Letter("; - ); - ); - if(tmp=="E" % tmp=="e", - if(indexof(#,"rot")>0, - Bname="Exprrot("; - , - Bname="Expr("; - ); - ); - tmp=indexof(#,"="); - Bops=substring(#,tmp,length(#)); // 16.11.01 - ); - Ydata=MakeBowdata(pA,pB,Hgt); - pC=Ydata_1; - ra=Ydata_2; - Th=(Ydata_3+Ydata_4)*0.5; - BOWMIDDLE=[pC_1+ra*cos(Th),pC_2+ra*sin(Th)]; - Bpos="md"+name; // 16.10.31from(moved) - tmp="Defvar("+Dq+Bpos+"="+textformat(BOWMIDDLE,5)+Dq+");"; - parse(tmp);// 16.10.31upto(moved) - if(length(Bname)>0, //16.11.01from - tmp=indexof(Bops,","); - if(tmp>0, - tmp1=substring(Bops,0,tmp-1); - if(length(tmp1)>=4 & substring(tmp1,0,1)=="t" & indexof(tmp1,"n")>0, - Bmov=tmp1; - Bops=substring(Bops,tmp,length(Bops)); - ); - ); - if(length(Bmov)>0, - tmp=indexof(Bmov,"t"); - if(tmp>0, - tmp1=indexof(Bmov,"n"); - Tmov=parse(substring(Bmov,tmp,tmp1-1)); - tmp=indexof(Bmov,"r"); - if(tmp>0, - Nmov=parse(substring(Bmov,tmp1,tmp-1)); - rev=1; - , - Nmov=parse(substring(Bmov,tmp1,length(Bmov))); - ); - ); - ); - Bname=Bname+Bpos;//16.11.01 - if(abs(Tmov)+abs(Nmov)>0, - tmp=Pcrd(pA)-Pcrd(pB); - tmp1=1/norm(tmp)*tmp; - tmp2=[-tmp1_2,tmp1_1]; - tmp=MARKLEN*(Tmov*tmp1+Nmov*tmp2); - tmp=LLcrd(tmp); - Bname=Bname+"+"+text(tmp); - ); - Bname=Bname+","; - if(indexof(Bname,"rot")>0, - if(rev==1,tmp=pB-pA,tmp=pA-pB); - Bname=Bname+textformat(tmp,5)+","; - , - Bname=Bname+Dq+"c"+Dq+","; - ); - Bname=Bname+Dq+Bops+Dq+")"; - parse(Bname); - );//16.11.01upto - if(Cut==0, - Th1=Ydata_3; - Th2=Ydata_4; - Out=[]; - forall(0..Num, - tmp=Th1+#*(Th2-Th1)/Num; - Out=append(Out,pC+ra*[cos(tmp),sin(tmp)]); - ); - , - Th1=Ydata_3; - Th2=Th-Cut/(2*ra); - tmp1=[]; - forall(0..Num/2, - tmp=Th1+#*(Th2-Th1)/(Num/2); - tmp1=append(tmp1,pC+ra*[cos(tmp),sin(tmp)]); - ); - Th1=Th+Cut/(2*ra); - Th2=Ydata_4; - tmp2=[]; - forall(0..Num/2, - tmp=Th1+#*(Th2-Th1)/(Num/2); - tmp2=append(tmp2,pC+ra*[cos(tmp),sin(tmp)]); - ); - Out=[tmp1,tmp2]; - ); - if(Noflg<3, - println("generate bowdata "+name+" and "+Bpos);//16.10.31 - if(MeasureDepth(Out)==1,Out=[Out]); - tmp1=[]; - forall(Out,tmp2, - tmp=apply(tmp2,Pcrd(#)); - tmp1=append(tmp1,tmp); - ); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp1=substring(textformat(plist,5),1,length(textformat(plist,5))-1); - tmp=name+"=Bowdata("+tmp1+opstr+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); -); - -Deqplot(nm,deq,rng,initf):=Deqplot(nm,deq,rng,Lcrd(initf)_1,initf,[]); -Deqplot(nm,deq,rng,Arg1,Arg2):=( - regional(initt,initf,options); - if(isreal(Arg1) & length(Arg1)==1, - initt=Arg1; - initf=Arg2; - options=[]; - , - initf=Lcrd(Arg1); - initt=initf_1; - options=Arg2; - ); - Deqplot(nm,deq,rng,initt,initf,options); -); -Deqplot(nm,deq,rng,initt,initf,options):=( - regional(name,Noflg,Ltype,eqL,opstr,opcindy,pdL,var2,deq2,rng2,initt2,initf2, - tmp,tmp1,tmp2,tmp3,tmp4); - tmp=tokenize(deq,"="); - tmp1=tmp_1; - tmp2=tmp_2; - tmp3=tokenize(tmp1,"`"); - if(length(tmp3)==2, - if(indexof(tmp1,"[")>0, - Deqplot(nm,deq,rng,initt,initf,options,[2,3]); - , - if(indexof(rng,"=")>0,rng2=rng,rng2=rng+"=[XMIN,XMAX]"); - tmp=tokenize(rng2,"="); - deq2="["+tmp_1+","+replace(tmp1,"`","]")+"`=[1,"+tmp2+"]"; - rng2="t="+tmp_2; - if(isreal(initf) & length(initf)==1, - initf2=[initt,initf]; - initt2=initt; - , - initf2=Lcrd(initf)); - initt2=initf2_1; - Deqplot(nm,deq2,rng2,initt2,initf2,options,[2,3]); - ); - , - name="de"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - eqL=tmp_5; - opcindy=tmp_9; - opstr=""; - forall(eqL, - if(Toupper(substring(#,0,1))=="N", - tmp=indexof(#,"="); - tmp1="N="+substring(#,tmp,length(#)); - opstr=opstr+",'"+tmp1+"'"; - ); - ); - if(Noflg<1, - if(indexof(rng,"=")>0,rng2=rng,rng2=rng+"=[XMIN,XMAX]"); - var2="d"+tmp3_1; - deq2="["+tmp3_1+","+var2+"]`=["; - tmp=replace(tmp2,tmp3_1+"`",var2); - deq2=deq2+var2+","+tmp+"]"; - Deqplot(nm,deq2,rng2,initt,initf,append(options,"nodisp"),[1,2]); - parse(tmp); - tmp=name+"=Deqplot(Assign("+Dq+deq+Dq+"),'"+rng+"',"; - tmp=tmp+initt+","+initf+opstr+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - parse("de"+nm); - ); - ); -); -Deqplot(nm,deq,rng,initt,initf,options,Sel):=( -//help:Deqplot("2","y`=y*(1-y)","x",0, 0.5,["Num=100"]); -//help:Deqplot("1","y``=-y","x",0, [1,0]); -//help:Deqplot("3","[x,y]`=[x*(1-y),0.3*y*(x-1)]","t=[0,20]",[1,0.5]); - regional(Ltype,Noflg,Inflg,Outflg,strL,opstr,opcindy,Num, - outstr,name,func,xf,yf,pdL,Eps,Inf,t1,t2,tt,Vname,dt,funP,funN,flg, - kl1,kl2,kl3,kl4,x0,y0,x1,y1,tmp,tmp1,tmp2); - name="de"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - Inflg=tmp_3; - Outflg=tmp_4; - eqL=tmp_5; - strL=tmp_7; -// opstr=tmp_(length(tmp)-1); - opstr=""; - opcindy=tmp_(length(tmp)); - outstr=""; - forall(strL, - tmp=Toupper(substring(#,0,1)); - if(tmp=="S", - outstr="Sci"; - ); - ); - Num=50; - forall(eqL, - tmp=indexof(#,"="); - tmp2=substring(#,0,1); - tmp2=Toupper(tmp2); - tmp1=substring(#,tmp,length(#)); - opstr=opstr+",'"+tmp2+"="+tmp1+"'"; - if(Toupper(substring(#,0,1))=="N", - Num=parse(tmp1); - ); - ); - if(outstr=="Sci", - if(Inflg==0 & Outflg==0,Outflg=1;Inflg=1); - ); - if(Noflg<3, - if(outstr=="Sci", - if(Outflg==1, - println("Output Deqplot "+name); - SCIWRLIST=append(SCIWRLIST,name); - ); - if(Inflg==1, - println("Input Deqplot "+name); - if(length(SCIRELIST)==0, - ReadOutData(Fnameout); - ); - tmp=parse(name); - if(islist(tmp), - Extractdata(name,["nodisp"]); // 12.19 - ); - SCIRELIST=append(SCIRELIST,name); - ); - , - Eps=10^(-3); - Inf=10^3; - tmp=tokenize(deq,"="); - tmp1=tmp_1; - func=tmp_2; - tmp=indexof(tmp1,","); - xf=substring(tmp1,1,tmp-1); - yf=substring(tmp1,tmp,length(tmp1)); - tmp=indexof(yf,"]"); - yf=substring(yf,0,tmp-1); - tmp=tokenize(rng,"="); - Vname=tmp_1; - tmp=parse(tmp_2); - t1=tmp_1; - t2=tmp_2; - tmp="funP("+Vname+","+xf+","+yf+"):="+func+";"; - parse(tmp); - tmp=tokenize(func,","); - tmp1="-("+substring(tmp_1,1,length(tmp_1))+")"; - tmp2="-("+substring(tmp_2,0,length(tmp_2)-1)+")"; - tmp="funN("+Vname+","+xf+","+yf+"):=["+tmp1+","+tmp2+"];"; - parse(tmp); - dt=(t2-t1)/Num; - tt=initt; - tmp=Lcrd(initf); - x0=tmp_1; - y0=tmp_2; - pdL=[[tt,x0,y0]]; - flg=0; - forall(1..floor((t2-initt)/dt), - if(flg==0, - kl1=dt*funP(tt,x0,y0); - kl2=dt*funP(tt+dt/2,x0+kl1_1/2,y0+kl1_2/2); - kl3=dt*funP(tt+dt/2,x0+kl2_1/2,y0+kl2_2/2); - kl4=dt*funP(tt+dt,x0+kl3_1,y0+kl3_2);//16.10.14 - tmp1=[x0,y0]+(kl1+2*kl2+2*kl3+kl4)/6; - x0=tmp1_1; - y0=tmp1_2; - tt=initt+#*dt; - pdL=append(pdL,[tt,x0,y0]); - if(|tmp1|>Inf,flg=1); - ); - ); - tt=initt; - tmp=Lcrd(initf); - x0=tmp_1; - y0=tmp_2; - flg=0; - forall(1..floor((initt-t1)/dt), - if(flg==0, - kl1=dt*funN(tt,x0,y0); - kl2=dt*funN(tt+dt/2,x0+kl1_1/2,y0+kl1_2/2); - kl3=dt*funN(tt+dt/2,x0+kl2_1/2,y0+kl2_2/2); - kl4=dt*funN(tt+dt/2,x0+kl3_1/2,y0+kl3_2/2); - tmp1=[x0,y0]+(kl1+2*kl2+2*kl3+kl4)/6; - x0=tmp1_1; - y0=tmp1_2; - tt=initt-#*dt; - pdL=prepend([tt,x0,y0],pdL); - if(|tmp1|>Inf,flg=1); - ); - ); - println("Generate Deqplot "+name); - pdL=apply(pdL,#_Sel); - tmp1=apply(pdL,Pcrd(#)); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - ); - if(Noflg<1, - tmp=name+"=Deqplot(Assign("+Dq+deq+Dq+"),'"+rng+"',"; - tmp=tmp+initt+","+initf+opstr+")"; - GLIST=append(GLIST,tmp); - ); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - if(outstr=="Sci", - if(Inflg==1, - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - , - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - pdL; - ); - ); -); - -Enclosing(nm,plist):=EnclosingS(nm,plist); -Enclosing(nm,plist,options):=EnclosingS(nm,plist,options); -EnclosingS(nm,plist):=EnclosingS(nm,plist,[]); -EnclosingS(nm,plist,options):=( -//help:Enclosing("1",["sc2","crAB","sc2","Invert(sc1)"],[pt,"dr"]); - regional(name,AnsL,Start,Eps,EEps,S,Flg,Fdata,Gdata,KL,pt,qt, - t1,t2,t3,ii,nn,tmp,tmp1,tmp2,Ltype,Noflg,realL,eqL,opstr,opcindy); - name="en"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - eqL=tmp_5; - realL=tmp_6; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - Eps=10^(-3); - EEps=0.1; - Start=[]; - Flg=0; - forall(realL, - if(isList(#) % ispoint(#), - Start=Lcrd(#); // 15.09.12 - , - Flg=Flg+1; - if(Flg==1,Eps=#); - if(Flg==2,EEps=#); - ); - ); -// tmp1=concat([Eps,EEps],eqL); // 15.04.06 - Fdata=plist_1; - Gdata=plist_(length(plist)); - KL=IntersectcrvsPp(Fdata,Gdata); - if(length(KL)==1, - pt=KL_1_1; - t1=KL_1_2; - ); - if(length(KL)==0, - if(Numptcrv(Fdata)>Numptcrv(Gdata), - tmp=Nearestpt(Fdata,Gdata); - pt=tmp_1; - t1=tmp_2; - , - tmp=Nearestpt(Gdata,Fdata); - pt=tmp_3; - t1=tmp_4; - ); - ); - if(length(KL)>1, - if(Start==[], - err("No Start Point"); - , - pt=KL_1_1; - t1=KL_1_2; - tmp=|pt-Start|; - forall(2..length(KL),ii, // 15.04.20 - tmp1=KL_ii_1; - tmp2=|tmp1-Start|; // 15.04.20 - if(tmp2<tmp, - pt=tmp1; - t1=KL_ii_2; - tmp=tmp2; - ); - ); - ); - ); -// pt=Pcrd(pt); // 15.09.12 - Start=pt; - AnsL=[]; - forall(1..length(plist),nn, - Fdata=plist_nn; - if(nn>1, pt=qt); - if(nn==length(plist), - qt=Start; - , - Flg=0; - Gdata=plist_(nn+1); -// tmp1=concat([Eps,EEps],eqL); // 15.04.06 - KL=IntersectcrvsPp(Gdata,Fdata); - if(length(KL)==1, - tmp=KL_1; - qt=KL_1_1; - t3=KL_1_2; - Flg=10; - ); - if(length(KL)==0,Flg=1); - if(length(KL)>1, - tmp1=KL_1_1; - tmp2=KL_2_1; - tmp=|tmp1-tmp2|; - if(tmp<Eps*10, Flg=1); - ); - if(Flg==1, - if(Numptcrv(Fdata)>Numptcrv(Gdata), - tmp=Nearestpt(Fdata,Gdata); - qt=tmp_1; - t3=tmp_4; - Flg=10; - , - tmp=Nearestpt(Gdata,Fdata); - qt=tmp_3; - t3=tmp_2; - Flg=10; - ); - ); - if(Flg<10, - t2=10^6; //%inf; - forall(1..length(KL),ii, - tmp1=KL_ii_1; - tmp=KL_ii_3; - tmp2=ParamonCurve(tmp1,tmp,Fdata); - tmp3=KL_ii_2; - if(tmp2>t1+Eps & tmp2<t2+Eps, - qt=tmp1; - t2=tmp2; - t3=tmp3; - ); - ); - ); - ); - tmp=Partcrv("",pt,qt,Fdata,["nodata"]); - t1=t3; - if(nn==1, - AnsL=tmp; - , - AnsL=concat(AnsL,tmp_(2..length(tmp))); - ); - ); - AnsL=apply(AnsL,Pcrd(#)); // 15.09.12 - AnsL_(length(AnsL))=AnsL_1;//16.10.20 - if(Noflg<3, - println("generate Enclosing "+name); - tmp=name+"="+textformat(AnsL,5); - parse(tmp); -// tmp=name+"=Enclosing(";//16.10.20from -// tmp1="list("; -// forall(plist, -// tmp1=tmp1+#+","; -// ); -// tmp=tmp+substring(tmp1,0,length(tmp1)-1)+")"+opstr+")"; - tmp=apply(AnsL,LLcrd(#)); - tmp=name+"=Listplot("+textformat(tmp,5)+")";//16.10.20upto - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - tmp=apply(AnsL,LLcrd(#));//16.10.20 - tmp; -); - -Shade(plist):=Shade(plist,[]); -Shade(plist,options):=( -//help:Shade(["gr2","sg1"],[0.5]); -//help:Shade([pointlist],[0.5]); - regional(tmp,tmp1,tmp2,opstr,opcindy,Str,G2,flg); - if(isstring(plist_1), // 16.01.24 - println("output Shade of "+plist); - , - println("output Shade of lists"); - ); - tmp=Divoptions(options); - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - flg=0; - forall(plist, - if(flg==0, - if(isstring(#),tmp=parse(#),tmp=#); // from 16.01.24 - if(!islist(tmp),flg=1); upto - ); - ); - if(flg==1, -// err("some data not defined yet"); - , - G2=Joincrvs("1",plist,["nodata"]); - G2=apply(G2,Pcrd(#)); - tmp1="fillpoly("+textformat(G2,5)+opcindy+");"; - parse(tmp1); - ); - Str="Shade("; - tmp1="list("; - forall(plist, - if(isstring(#), // from 16.01.24 - if(length(#)>1, - tmp1=tmp1+#+","; - , - tmp1=tmp1+Dq+#+Dq+","; - ); - , - tmp1=tmp1+"Listplot("+textformat(#,5)+"),"; - ); // upto 16.01.24 - ); - Str=Str+substring(tmp1,0,length(tmp1)-1)+")"+opstr+")"; - Com2nd(Str); -); - - -//help:start(); - -Rotatepoint(point,Theta,ctr):=( -//help:Rotatepoint(A,2*pi/3,B); - regional(X1,X2,Y1,Y2,Cx,Cy,tmp); - tmp=Lcrd(point); - X1=tmp_1; Y1=tmp_2; - tmp=Lcrd(ctr); - Cx=tmp_1; Cy=tmp_2; - X2=Cx+(X1-Cx)*cos(Theta)-(Y1-Cy)*sin(Theta); - Y2=Cy+(X1-Cx)*sin(Theta)+(Y1-Cy)*cos(Theta); - [X2,Y2]; -); - -Translatepoint(point,mov):=( -//help:Translatepoint(A,[2,3]); - regional(X1,X2,Y1,Y2,Cx,Cy,tmp); - tmp=Lcrd(point); - X1=tmp_1; Y1=tmp_2; - tmp=Lcrd(mov); - Cx=tmp_1; Cy=tmp_2; - X2=X1+Cx; - Y2=Y1+Cy; - [X2,Y2]; -); - -Scalepoint(point,ratio,center):=( -//help:Scalepoint(A,[3,2],[0,0]); - regional(X1,X2,Y1,Y2,Cx,Cy,tmp); - tmp=Lcrd(point); - X1=tmp_1; Y1=tmp_2; - tmp=Lcrd(center); - Cx=tmp_1; Cy=tmp_2; - X2=Cx+ratio_1*(X1-Cx); - Y2=Cy+ratio_2*(Y1-Cy); - [X2,Y2]; -); - -Reflectpoint(point,symL):=( -//help:Reflectpoint(A,B); -//help:Reflectpoint(A,[[2,3]]); -//help:Reflectpoint(A,[C,E]);\\ - regional(X1,X2,Y1,Y2,Us,Vs,Pt1,Pt2,Cx,Cy,tmp); - tmp=Lcrd(point); - X1=tmp_1; Y1=tmp_2; - Pt1=Lcrd(symL_1); - if(length(symL)==1, - Pt2=Pt1; - , - Pt2=Lcrd(symL_2); - ); - Us=Pt2_1-Pt1_1; - Vs=Pt2_2-Pt1_2; - if(Pt1==Pt2, - X2=2*Pt1_1-X1; - Y2=2*Pt1_2-Y1; - , - X2=(Us^2-Vs^2)/(Us^2+Vs^2)*X1+2*Us*Vs/(Us^2+Vs^2)*Y1 - -2*Vs*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); - Y2=2*Us*Vs/(Us^2+Vs^2)*X1-(Us^2-Vs^2)/(Us^2+Vs^2)*Y1 - +2*Us*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); - ); - [X2,Y2]; -); - -Rotatedata(nm,plist,Theta):=Rotatedata(nm,plist,Theta,[]); -Rotatedata(nm,plist,angle,options):=( -//help:Rotatedata("1","crAB",pi/3,[[1,5],"dr,2"]); - regional(tmp,tmp1,tmp2,pdata,Theta,Pt,Cx,Cy,PdLL,PdL, - opcindy,Nj,Njj,Kj,Mj,X1,Y1,X2,Y2,Ltype,Noflg,name); - name="rt"+nm; - Pt=[0,0]; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - tmp1=tmp_6; - if(length(tmp1)>0,Pt=Lcrd(tmp1_1)); - pdata=plist; - if(isstring(pdata),pdata=[pdata]); - if(!isstring(pdata_1) & MeasureDepth(pdata)==1, - pdata=[pdata]; - ); - if(isstring(angle),Theta=parse(angle),Theta=angle); - Cx=Pt_1; Cy=Pt_2; - PdL=[]; - forall(pdata,Njj, - if(isstring(Njj),Kj=parse(Njj),Kj=Njj); - if(MeasureDepth(Kj)==1,Kj=[Kj]); - tmp2=[]; - forall(Kj,Nj, - tmp1=[]; - forall(Nj, - tmp=LLcrd(#); - X1=tmp_1; - Y1=tmp_2; - X2=Cx+(X1-Cx)*cos(Theta)-(Y1-Cy)*sin(Theta); - Y2=Cy+(X1-Cx)*sin(Theta)+(Y1-Cy)*cos(Theta); - tmp1=concat(tmp1,[[X2,Y2]]); - ); - tmp2=concat(tmp2,[tmp1]); - ); - PdL=concat(PdL,tmp2); - ); - if(Noflg<3, - println("generate Rotatedata "+name); - tmp1=[]; - forall(PdL,tmp2, - tmp=apply(tmp2,Pcrd(#)); - tmp1=append(tmp1,tmp); - ); - if(length(tmp1)==1,tmp1=tmp1_1); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); -// tmp1=textformat(plist,5); - tmp1=text(plist); // 15.10.15 - tmp1=replace(tmp1,"[","list("); - tmp1=replace(tmp1,"]",")"); - tmp=name+"=Rotatedata("+tmp1+"," - +textformat(angle,5)+","+textformat(Pt,5)+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - PdL; -); - -translatedata(nm,plist,mov):=translatedata(nm,plist,mov,[]); -translatedata(nm,plist,mov,options):=( -//help:translatedata("1",["gr1"],[1,2]); - regional(tmp,tmp1,tmp2,pdata,Cx,Cy,PdL,Nj,Njj,Kj, - opcindy,X2,Y2,Ltype,Noflg,name); - name="tr"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - pdata=plist; - if(isstring(pdata),pdata=[pdata]); - if(!isstring(pdata_1) & MeasureDepth(pdata)==1, - pdata=[pdata]; - ); - tmp=Lcrd(mov); - Cx=tmp_1; Cy=tmp_2; - PdL=[]; - forall(pdata,Njj, - if(isstring(Njj),Kj=parse(Njj),Kj=Njj); - if(MeasureDepth(Kj)==1,Kj=[Kj]); - tmp2=[]; - forall(Kj,Nj, - tmp1=[]; - forall(Nj, - tmp=LLcrd(#); - X2=tmp_1+Cx; - Y2=tmp_2+Cy; - tmp1=concat(tmp1,[[X2,Y2]]); - ); - tmp2=concat(tmp2,[tmp1]); - ); - PdL=concat(PdL,tmp2); - ); - if(Noflg<3, - println("generate translatedata "+name); - tmp1=[]; - forall(PdL,tmp2, - tmp=apply(tmp2,Pcrd(#)); - tmp1=append(tmp1,tmp); - ); - if(length(tmp1)==1,tmp1=tmp1_1); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); -// tmp1=textformat(plist,5); - tmp1=text(plist); // 15.10.15 - tmp1=replace(tmp1,"[","list("); - tmp1=replace(tmp1,"]",")"); - tmp=name+"=translatedata("+tmp1+","+textformat(mov,5)+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - PdL; -); - -Scaledata(nm,plist,ratioV):=( - regional(tmp); - tmp=Lcrd(ratioV); - Scaledata(nm,plist,tmp_1,tmp_2,[]); -); -Scaledata(nm,plist,Arg1,Arg2):=( -//help:Scaledata("1","crAB",3,2,[[0,0]]); - regional(tmp,options); - if(islist(Arg2), - tmp=Lcrd(Arg1); - options=Arg2; - Scaledata(nm,plist,tmp_1,tmp_2,options); - , - Scaledata(nm,plist,Arg1,Arg2,[]); - ); -); -Scaledata(nm,plist,rx,ry,options):=( - regional(tmp,tmp1,tmp2,pdata,Theta,Pt,Cx,Cy,PdL, - opcindy,Nj,Njj,Kj,X2,Y2,Ltype,Noflg,name); - name="sc"+nm; - Pt=[0,0]; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - tmp1=tmp_6; - if(length(tmp1)>0, - Pt=Lcrd(tmp1_1); - ); - pdata=plist; - if(isstring(pdata),pdata=[pdata]); - if(!isstring(pdata_1) & MeasureDepth(pdata)==1, - pdata=[pdata]; - ); - Cx=Pt_1; Cy=Pt_2; - PdL=[]; - forall(pdata,Njj, - if(isstring(Njj),Kj=parse(Njj),Kj=Njj); - if(MeasureDepth(Kj)==1,Kj=[Kj]); - tmp2=[]; - forall(Kj,Nj, - tmp1=[]; - forall(Nj, - tmp=LLcrd(#); - X2=Cx+rx*(tmp_1-Cx); - Y2=Cy+ry*(tmp_2-Cy); - tmp1=concat(tmp1,[[X2,Y2]]); - ); - tmp2=concat(tmp2,[tmp1]); - ); - PdL=concat(PdL,tmp2); - ); - if(Noflg<3, - println("generate Scaledata "+name); - tmp1=[]; - forall(PdL,tmp2, - tmp=apply(tmp2,Pcrd(#)); - tmp1=append(tmp1,tmp); - ); - if(length(tmp1)==1,tmp1=tmp1_1); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); - tmp1=text(plist); // 15.10.15 - tmp1=replace(tmp1,"[","list("); - tmp1=replace(tmp1,"]",")"); - tmp=name+"=Scaledata("+tmp1+"," - +textformat(rx,5)+","+textformat(ry,5)+","+textformat(Pt,5)+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - PdL; -); - -Reflectdata(nm,plist,symL):=Reflectdata(nm,plist,symL,[]); -Reflectdata(nm,plist,symL,options):=( -//help:Reflectdata("1","crAB",[C]); - regional(tmp,tmp1,tmp2,pdata,Us,Vs,Pt1,Pt2,Cx,Cy,PdL, - opcindy,Nj,Njj,Kj,X1,Y1,X2,Y2,Ltype,Noflg,name); - name="re"+nm; - Pt=[0,0]; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opcindy=tmp_(length(tmp)); - pdata=plist; - if(isstring(pdata),pdata=[pdata]); - if(!isstring(pdata_1) & MeasureDepth(pdata)==1, - pdata=[pdata]; - ); - Pt1=Lcrd(symL_1); - if(length(symL)==1, - Pt2=Pt1; - , - Pt2=Lcrd(symL_2); - ); - Us=Pt2_1-Pt1_1; - Vs=Pt2_2-Pt1_2; - PdL=[]; - forall(pdata,Njj, - if(isstring(Njj),Kj=parse(Njj),Kj=Njj); - if(MeasureDepth(Kj)==1,Kj=[Kj]); - tmp2=[]; - forall(Kj,Nj, - tmp1=[]; - forall(Nj, - tmp=LLcrd(#); - X1=tmp_1; - Y1=tmp_2; - if(Pt1==Pt2, - X2=2*Pt1_1-X1; - Y2=2*Pt1_2-Y1; - , - X2=(Us^2-Vs^2)/(Us^2+Vs^2)*X1+2*Us*Vs/(Us^2+Vs^2)*Y1 - -2*Vs*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); - Y2=2*Us*Vs/(Us^2+Vs^2)*X1-(Us^2-Vs^2)/(Us^2+Vs^2)*Y1 - +2*Us*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); - ); - tmp1=concat(tmp1,[[X2,Y2]]); - ); - tmp2=concat(tmp2,[tmp1]); - ); - PdL=concat(PdL,tmp2); - ); - if(Noflg<3, - println("generate Reflectdata "+name); - tmp1=[]; - forall(PdL,tmp2, - tmp=apply(tmp2,Pcrd(#)); - tmp1=append(tmp1,tmp); - ); - if(length(tmp1)==1,tmp1=tmp1_1); - tmp=name+"="+textformat(tmp1,5); - parse(tmp); -// tmp1=textformat(plist,5); - tmp1=text(plist); // 15.10.15 - tmp1=replace(tmp1,"[","list("); - tmp1=replace(tmp1,"]",")"); - tmp=name+"=Reflectdata("+tmp1+","+textformat(symL,5)+")"; - GLIST=append(GLIST,tmp); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - PdL; -); - -Mksegments():=Mksegments([]); -Mksegments(options):=( -//help:Mksegments(); - regional(segstr,p,q,r,tmp1,tmp2,tmp3); - forall(allsegments(),seg, - str=text(inspect(seg,"definition")); - tmp1=indexof(str,"("); - tmp2=indexof(str,";"); - tmp3=indexof(str,")"); - p=substring(str,tmp1,tmp2-1); - q=substring(str,tmp2,tmp3-1); - Listplot([parse(p),parse(q)]); - ); -); - -Mkcircles():=Mkcircles([]); -Mkcircles(options):=( -//help:Mkcircles(): - regional(seg,cir,str,p,q,r,tmp1,tmp2,tmp3,tmp4); - forall(allcircles(),cir, - str=text(inspect(cir,"definition")); - tmp1=indexof(str,"("); - tmp2=indexof(str,";"); - tmp3=indexof(str,")"); - tmp4=indexof(str,";",tmp2+1); - if(tmp4==0, - p=substring(str,tmp1,tmp2-1); - q=substring(str,tmp2,tmp3-1); - Circledata([parse(p),parse(q)]); - , - p=substring(str,tmp1,tmp2-1); - q=substring(str,tmp2,tmp4-1); - r=substring(str,tmp4,tmp3-1); - Circledata([parse(p),parse(q),parse(r)]); - ); - ); -); - -Makesciarg(arglist):=( - regional(str,tmpstr); - str=""; - forall(arglist, - if(isstring(#), - tmpstr=Dq+#+Dq; - , - tmpstr=textformat(#,5); - ); - str=str+tmpstr+","; - ); - str=substring(str,0,length(str)-1); - str; -); - -Setax(arglist):=( -//help:Setax(["l","x","e","y","n","O","sw"]); -//help:Setax([7,"nw"]); - regional(tmp); - tmp=Makesciarg(arglist); - Com1st("Setax("+tmp+")"); -); - -Htickmark(arglist):=( -//help:Htickmark([1,"1",2,"sw","2"]); - regional(tmp); - tmp=""; - tmp=Makesciarg(arglist); - Com2nd("Htickmark("+tmp+")"); -); - -Vtickmark(arglist):=( -//help:Vtickmark([1,"1",2,"sw","2"]); - regional(tmp); - tmp=Makesciarg(arglist); - Com2nd("Vtickmark("+tmp+")"); -); - -Drwxy():=( -//help:Drwxy(); - Com2nd("Drwxy()"); - Addax(0); // 16.01.21 -); - -Drwpt(pstr):=Drawpoint(pstr); -Drwpt(ptlist,nn):=( // 16.03.05 from -//help:Drwpt(A); -//help:Drwpt("[1,1],0"); -//help:Drwpt(A,0); -//help:Drwpt([1,2],0); - Drawpoint(ptlist,nn); -); -Drawpoint(pstr):=( - if(isstring(pstr), - println("Drwpt : "+pstr); - Com2nd("Drwpt("+pstr+")"); - , - Drawpoint(pstr,1); - ); -); -Drawpoint(ptlistorg,nn):=( - regional(ptlist,thick,tmp,tmp1); - println("Drwpt : "+text(ptlistorg)); - if(islist(ptlistorg), - if(MeasureDepth(ptlistorg)==1, - ptlist=ptlistorg - , - ptlist=[ptlistorg] - ); - , - ptlist=[ptlistorg] - ); - thick=PenThick/PenThickInit;// 16.04.09 from - tmp1=max(TenSize/TenSizeInit,1)/8; - Setpen(tmp1); // 16.04.09 upto - forall(ptlist, - tmp=textformat(#,5)+","+text(nn); - Com2nd("Drwpt("+tmp+")"); // 16.04.09 - ); - Setpen(thick); // 16.04.09 -);// 16.03.05 upto - -Addax(param):=( -//help:Addax(0); - ADDAXES=text(param); -); - -Expr(Pt,Dr,St):=Expr([Pt,Dr,St]); -Expr(list):=Expr(list,[]); -Expr(listorg,options):=( //16.10.09 -//help:Expr([A,"e","f(x)=x^2"]); - regional(list,str,tmp,tmp1,tmp2); - list=listorg; - forall(1..round(length(list)/3), - str=list_(3*#); - if(!isstring(str),str=format(str,5)); - str="$"+str+"$"; - list_(3*#)=str; - ); - Letter(list,options); -); - -Letter(Pt,Dr,St):=Letter([Pt,Dr,St]); -Letter(list):=Letter(list,[]); -Letter(list,options):=( -//help:Letter([C,"c","Graph of f(x)"]); - regional(Nj,Pos,Dir,Str,Off,Dmv,Xmv,Ymv,Noflg,opcindy, - opL,aln,sz,clr,bld,ita,tmp,tmp1,tmp2); - tmp=Divoptions(options); - Noflg=tmp_2; - opL=select(options,indexof(#,"->")>0); //16.10.09from - tmp=select(opL,indexof(#,"color")); - size=12; - clr=[0,0,0]; - bld=false; - ita=false; - aln="left"; - forall(opL, - tmp=indexof(#,"->"); - tmp1=removespace(substring(#,0,tmp-1)); - tmp2=substring(#,tmp+1,length(#)); - if(tmp1=="size",sz=parse(tmp2)); - if(tmp1=="color",clr=parse(tmp2)); - if(tmp1=="bold",bld=parse(tmp2)); - if(tmp1=="ita",ita=parse(tmp2)); - );//16.10.09upto - Off=-4; - Dmv=8; - Nj=1; - while(Nj+2<=length(list), -// Pos=textformat(list_Nj,5); - Pos=list_Nj; - Dir=list_(Nj+1); - tmp=indexof(Dir,"s")+indexof(Dir,"n");//16.10.19from - if(tmp>0, - tmp=indexof(Dir,"w")+indexof(Dir,"e"); - if(tmp==0, - Dir="c"+Dir;//16.10.08 - ); - );//16.10.19upto - Str=list_(Nj+2); - if(!isstring(Str),Str=format(Str,5)); // 16.09.30,10.09 - tmp=replace(Str,".xy",""); - tmp=replace(tmp,".x","(1)"); - Str=replace(tmp,".y","(2)"); - if(indexof(Str,"`")>0, -// tmp=Dq+",Assign('"+Str+"','`',Prime()))"; - tmp=Dq+",Assign('"+Str+"'))"; // 15.02.22 - , - tmp=Dq+","+Dq+Str+Dq+")"; - ); - if(Noflg==0, - Com2nd("Letter("+Lcrd(Pos)+","+Dq+Dir+tmp);//16.10.10 - ); - if(Noflg<2, - Xmv=0;//16.10.13 - Ymv=-4; - if(indexof(Dir,"n")>0, - Ymv=Dmv/2; - ); - if(indexof(Dir,"s")>0, - Ymv=-Dmv*3/2;//16.10.13 - ); - if(indexof(Dir,"e")>0, - Xmv=Dmv/2; - Off=0; - aln="left"; - ); - if(indexof(Dir,"w")>0, - Xmv=-Dmv/2; - Off=0; // 16.09.30from - aln="right"; - ); - if(indexof(Dir,"c")>0, - Xmv=0;//16.10.13 - Off=0; - if(Ymv==0,Ymv=-4);//16.10.08 - aln="mid"; // 16.09.30upto - ); - drawtext(Pcrd(Pos),Str,offset->[Off+Xmv,Off+Ymv], - size->sz,color->clr,align->aln,bold->bld,italics->ita);//16.10.09 - ); - Nj=Nj+3; - ); -); - -Letterrot(pt,dir,str):=Letterrot(pt,dir,0,0,str); -Letterrot(pt,dir,movstr,str):=( -//help:Letterrot(C,B-A,"AB"): -//help:Letterrot(C,B-A,0,5,"AB"): -//help:Letterrot(C,B-A,"t0n5","AB"): - regional(tmov,nmov,tmp,tmp1,tmp2); - tmp1=indexof(movstr,"t"); - tmp2=indexof(movstr,"n"); - if(tmp1>0, - if(tmp2>0,tmp=tmp2-1,tmp=length(movstr)); - tmov=parse(substring(movstr,tmp1,tmp)); - , - tmov=0; - ); - if(tmp2>0, - nmov=parse(substring(movstr,tmp2,length(movstr))); - , - nmov=0; - ); - Letterrot(pt,dir,tmov,nmov,str); -); -Letterrot(pt,dir,tmov,nmov,str):=( - Letter([pt,"c",str],["notex"]); - Com2nd("Letterrot("+pt+","+dir+","+tmov+","+nmov+",'"+str+"')"); -); - -Exprrot(pt,dir,str):=Exprrot(pt,dir,0,0,str); -Exprrot(pt,dir,movstr,str):=( -//help:Exprrot(C,B-A,"d"): -//help:Exprrot(C,B-A,0,5,"d"): -//help:Exprrot(C,B-A,"t0n5","d"): - regional(tmov,nmov,tmp,tmp1,tmp2); - tmp1=indexof(movstr,"t"); - tmp2=indexof(movstr,"n"); - if(tmp1>0, - if(tmp2>0,tmp=tmp2-1,tmp=length(movstr)); - tmov=parse(substring(movstr,tmp1,tmp)); - , - tmov=0; - ); - if(tmp2>0, - nmov=parse(substring(movstr,tmp2,length(movstr))); - , - nmov=0; - ); - Exprrot(pt,dir,tmov,nmov,str); -); -Exprrot(pt,dir,tmov,nmov,str):=( - Expr([pt,"c",str],["notex"]); - Com2nd("Exprrot("+pt+","+dir+","+tmov+","+nmov+",'"+str+"')"); -); - -Slider(ptstr,p1,p2):=( //17.04.11 -//help:Slider("A-C-B",[-3,0],[3,0]); - regional(pA,pB,pC,seg,sname,Alpha,tmp,tmp1); - tmp=indexall(ptstr,"-"); - pA=substring(ptstr,0,tmp_1-1); - pC=substring(ptstr,tmp_1,tmp_2-1); - pB=substring(ptstr,tmp_2,length(ptstr)); - seg=pA+pB; - Alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - sname=""; - forall(1..(length(seg)), - tmp=substring(seg,#-1,#); - tmp1=indexof(Alpha,tmp); - if(tmp1>0, - sname=sname+unicode(text(tmp1+96),base->10); - , - sname=sname+tmp; - ); - ); - Putpoint(pA,p1); - Putpoint(pB,p2); - Listplot([parse(pA),parse(pB)],["notex","color->[0,0.4,0.4]","size->2"]); -// create([sname],"Segment",[parse(pA),parse(pB)]); -// tmp2=Listplot("",[p1,p2],["nodata"]); - Putonseg(pC,parse("sg"+pA+pB)); -// create([pC],"PointOn",[parse(sname),0.5]); -); - -Putpoint(name,Pt):=Putpoint(name,Pt,Pt); -Putpoint(name,Ptinit,Pt):=( -//help:Putpoint("A",[1,2],[1,A.y]); - regional(ptstr); - ptstr=apply(allpoints(),#.name); - if(!contains(ptstr,name), - createpoint(name,Pcrd([Ptinit_1,Ptinit_2])); - , - ptstr=name+".xy="+textformat(Pcrd(Pt),5); - parse(ptstr); - ); -); - -Bezierpt(t,ptlist,ctrlist):=( - regional(flg3,p0,p1,p2,p3,p4,p5,p6,p7,p8,p9); - p0=ptlist_1; - p3=ptlist_2; - p1=ctrlist_1; - if(length(ctrlist)==1, - p2=p3; - flg3=0; - , - p2=ctrlist_2; - flg3=1; - ); - if(length(p0)<3, // 15.02.08 - p0=Lcrd(p0); - p3=Lcrd(p3); - p1=Lcrd(p1); - p2=Lcrd(p2); - ); - p4=(1-t)*p0+t*p1; - p5=(1-t)*p1+t*p2; - p6=(1-t)*p2+t*p3; - p7=(1-t)*p4+t*p5; - p8=(1-t)*p5+t*p6; - p9=(1-t)*p7+t*p8; - if(flg3==0,p7,p9); -); - -Bezier(ptctrlist):=BezierCurve(ptctrlist_3,ptctrlist_1,ptctrlist_2,[]); -Bezier(ptctrlist,options):=BezierCurve(ptctrlist_3,ptctrlist_1,ptctrlist_2,options); -Bezier(nm,ptlist,ctrlist):=BezierCurve(nm,ptlist,ctrlist,[]); -Bezier(nm,ptlist,ctrlist,options):=BezierCurve(nm,ptlist,ctrlist,options); -BezierCurve(nm,ptlist,ctrlist):=BezierCurve(nm,ptlist,ctrlist,[]); -BezierCurve(nm,ptlistorg,ctrlistorg,options):=( -//help:Bezier("1",[A,D],[B,C]); -//help:Bezier(options=["Num=10"]); - regional(name,Ltype,Noflg,opstr,opcindy,Num, - ptlist,ctrlist,tmp,tmp1,tmp2,ii,st,out,list); - name="bz"+nm; - tmp=Divoptions(options); - Ltype=tmp_1; - Noflg=tmp_2; - opstr=tmp_(length(tmp)-1); - opcindy=tmp_(length(tmp)); - Num=10; - tmp1=tmp_5; - forall(tmp1, // 14.12.31 - if(substring(#,0,1)=="N", - tmp2=indexof(#,"="); - Num=parse(substring(#,tmp2,length(#))); - opstr=opstr+","+Dq+#+Dq; - ); - ); - ptlist=apply(ptlistorg,Lcrd(#)); // 16.08.16 - ctrlist=[]; // 14.12.31 - if(length(ctrlistorg)==length(ptlist)-1, - forall(ctrlistorg,tmp1, - if(MeasureDepth(tmp1)==0,tmp=[tmp1],tmp=tmp1); - tmp=apply(tmp,Lcrd(#)); // 16.08.16 - ctrlist=append(ctrlist,tmp); - ); - , - forall(1..(length(ptlist)-1),ii, - tmp=ctrlistorg_((2*ii-1)..(2*ii)); - tmp=apply(tmp,Lcrd(#)); // 16.08.16 - ctrlist=append(ctrlist,tmp); - ); - ); - if(!islist(Num), - Num=apply(ctrlist,Num); - ); - list=[]; - forall(1..(length(ptlist)-1),ii, - tmp1=ptlist_(ii..(ii+1)); - tmp2=ctrlist_ii; - if(ii==1,st=0,st=1); - forall(st..Num_ii, - tmp=Bezierpt(#/Num_ii,tmp1,tmp2); - list=append(list,tmp); - ); - ); - if(Noflg<3, - println("generate Bezier "+name); - out=apply(list,Pcrd(#)); - tmp=name+"="+textformat(out,5); - parse(tmp); - tmp1=textformat(ptlist,5); - tmp1="list("+substring(tmp1,1,length(tmp1)-1)+")"; - tmp2=textformat(ctrlist,5); - tmp2="list("+substring(tmp2,1,length(tmp2)-1)+")"; - GLIST=append(GLIST,name+"=Bezier("+tmp1+","+tmp2+opstr+")"); - ); - if(Noflg<2, - if(isstring(Ltype), - Ltype=GetLinestyle(text(Noflg)+Ltype,name); - , - if(Noflg==1,Ltype=0); - ); - GCLIST=append(GCLIST,[name,Ltype,opcindy]); - ); - list; -); - -Readcsvsla(fname):=Readplotdigdata(fname,[]); -Readcsvsla(fname,options):=Readplotdigdata(fname,options); -Readplotdigdata(fname):=Readplotdigdata(fname,[]); -Readplotdigdata(fname,options):=( - regional(fsc,mv,cmdall,dataL,nd,npt,ptdata,ii,tmp,tmp1,tmp2,tmp3); - tmp=Divoptions(options); - tmp1=tmp_6; - sc=1;//10; - mv=[0,0];//[5,5]; - forall(tmp1, - if(!islist(#),sc=#,mv=#); - ); - if(indexof(fname,".")>0, - tmp=load(fname); - , - tmp=load(fname+".txt"); - ); - cmdall=tokenize(tmp,"//"); - dataL=[]; - forall(2..length(cmdall),ii, - tmp1=parse("["+cmdall_ii+"]"); - dataL=append(dataL,tmp1); - ); - if(length(dataL_(length(dataL)))<2, - dataL=dataL_(1..(length(dataL)-1)); - ); - nd=length(dataL_1)/2; - npt=length(dataL); - ptdata=[]; - forall(1..nd,ii, - tmp3=[]; - forall(1..npt, - tmp1=dataL_#_(2*ii-1); - tmp2=dataL_#_(2*ii); - if(isreal(tmp1), - tmp3=append(tmp3,[tmp1,tmp2]); - ); - ); - ptdata=append(ptdata,tmp3); - ); - tmp1=[]; - forall(ptdata, - tmp=#/sc; - tmp=translatedata("1",[tmp],-mv,["nodata"]); - tmp1=append(tmp1,tmp); - ); - ptdata=tmp1; - ptdata; -); - -Putbezierdata(name,ptL):=Putbezierdata(name,ptL,[]); -Putbezierdata(name,ptL,options):=( - regional(psize,Deg,tmp,tmp1,tmp2,p1,p2,pts,ctrs); - tmp=Divoptions(options); - psize=3; - Deg=3; - tmp1=tmp_5; - forall(tmp1, - if(substring(#,0,1)=="D", - tmp=indexof(#,"="); - Deg=parse(substring(#,tmp,length(#))); - ); - if(substring(#,0,1)=="S", - tmp=indexof(#,"="); - psize=parse(substring(#,tmp,length(#))); - ); - ); - pts=[]; - ctrs=[]; - forall(1..length(ptL), - p2=ptL_#; // 16.08.16 - if(ispoint(p2), - tmp1=text(p2); - , - tmp1=name+text(#); - Putpoint(tmp1,p2,Lcrd(parse(tmp1))); // 16.08.16 - ); - inspect(parse(tmp1),"ptsize",psize); - pts=append(pts,parse(tmp1)); - inspect(parse(tmp1),"color",4); - if(#>1, - p1=Lcrd(ptL_(#-1)); // 16.08.16 - p2=Lcrd(ptL_#); // 16.08.16 - if(Deg==3, - tmp=(2*p1+p2)/3; - tmp1=name+"p"+text(#-1); - Putpoint(tmp1,tmp,Lcrd(parse(tmp1))); // 16.08.16 - inspect(parse(tmp1),"labeled",false); //15.01.22 - Letter([parse(tmp1),"ne",tmp1],["notex"]); //15.01.22 - inspect(parse(tmp1),"ptsize",psize); - inspect(parse(tmp1),"color",3); - tmp=(p1+2*p2)/3; - tmp2=name+"q"+text(#-1); - Putpoint(tmp2,tmp,Lcrd(parse(tmp2))); // 16.08.16 - inspect(parse(tmp2),"labeled",false); //15.01.22 - Letter([parse(tmp2),"ne",tmp2],["notex"]); //15.01.22 - inspect(parse(tmp2),"ptsize",psize); - inspect(parse(tmp2),"color",3); - ctrs=append(ctrs,[parse(tmp1),parse(tmp2)]); - , - tmp=(p1+p2)/2; - tmp1=name+"p"+text(#-1); - Putpoint(tmp1,tmp,Lcrd(parse(tmp1))); // 16.08.16 - inspect(parse(tmp1),"labeled",false); //15.01.22 - Letter([parse(tmp1),"ne",tmp1],["notex"]); //15.01.22 - inspect(parse(tmp1),"ptsize",psize); - inspect(parse(tmp1),"color",3); - ctrs=append(ctrs,[parse(tmp1)]); - ); - ); - ); - [pts,ctrs,name]; -); - -Bezierstart(n):=( // 2016.02.26 - BezierNumber=n; -); - -Mkbezierptcrv(ptdata):=Mkbezierptcrv(ptdata,[]); -Mkbezierptcrv(ptdata,options):=( - //help:Mkbezierptcrv([A,B,C,D]); - //help:Mkbezierptcrv([[A,B],[C,D]]); - //help:Mkbezierptcrv(options=["Num=10"]); - // global BezierNumber - regional(ptlist,Out,tmp,tmp1,tmp2); - if(isstring(ptdata), - ptlist=Readcsvsla(ptdata,options); - , - ptlist=ptdata; - ); - if(MeasureDepth(ptlist)==1,ptlist=[ptlist]); - Out=[]; - forall(1..length(ptlist), - tmp=floor((BezierNumber-1)/26);// 15.02.23 - if(tmp==0,tmp="",tmp=text(tmp)); - tmp2=mod(BezierNumber,26); - if(tmp2==0,tmp2=26); - tmp1=unicode(text(96+tmp2),base->10)+tmp;// 15.03.11 - tmp2=Putbezierdata(tmp1,ptlist_#,options); - Bezier(tmp2,options); - BezierNumber=BezierNumber+1; - Out=append(Out,tmp2_(1..2)); - ); - Out; -); - -Mkbeziercrv(nm,ptctrL):=Mkbeziercrv(nm,ptctrL,[]); -Mkbeziercrv(nm,ptctrL,options):=( - //help:Mkbeziercrv("1",[[A,B,C,D],[[P,Q],[R,S],T]]); - regional(ptctrLL,name,ptlist,ctrlist,tmp,tmp1,tmp2); - if(MeasureDepth(ptctrL)==2,ptctrLL=[ptctrL],ptctrLL=ptctrL); - forall(1..length(ptctrLL), - name=nm+text(#); - ptlist=ptctrLL_#_1; - ctrlist=ptctrLL_#_2; - Bezier(name,ptlist,ctrlist,options); - ); -); - -Writebezier():=Writebezier(Fhead,"all"); -Writebezier(head):=Writebezier(head,"all"); -Writebezier(head,seL):=( -//help:Writebezier(file); -//help:Writebezier(file,"acd"); - regional(bz,dt,name,tmp,tmp1,tmp2); - bz=select(GLIST,indexof(#,"=Bezier")>0); - tmp1=[]; // 16.04.22from - if(seL!="all", - forall(1..length(seL), - tmp=substring(seL,#-1,#); - tmp=select(bz,indexof(#,"bz"+tmp)>0); - tmp1=concat(tmp1,tmp); - ); - bz=tmp1;// 16.04.22upto - ); - dt=[head+"n",[[length(bz),0]]]; - forall(1..length(bz), - tmp=indexof(bz_#,"="); - name=substring(bz_#,0,tmp-1); - tmp=indexof(bz_#,","+Dq); - if(tmp>0, - tmp1=substring(bz_#,0,tmp-1)+")"; - , - tmp1=bz_#; - ); - tmp1=replace(tmp1,"Bezier(","["); - tmp1=replace(tmp1,"list(","["); - tmp1=replace(tmp1,")","]"); - tmp1=replace(tmp1,",",".xy,"); - tmp1=replace(tmp1,"]",".xy]"); - tmp1=replace(tmp1,".xy,[",",["); - tmp1=replace(tmp1,"].xy","]"); - tmp1=replace(tmp1,name,head+text(#)); - parse(tmp1); - tmp=parse(head+text(#)+"_1"); - dt=concat(dt,[head+text(#)+"k",tmp]); - tmp=parse(head+text(#)+"_2"); - dt=concat(dt,[head+text(#)+"c",tmp]); - ); - WriteOutData(head+".txt",dt); - dt; -); - -Readbezier(file):=Readbezier(file,[]); -Readbezier(file,optionorg):=( -//help:Readbezier("xsr"); -//help:Readbezier(options=["Num=10","nogeo"]); - regional(nn,options,stL,geo,nc,alpha,out,tmp,tmp1,tmp2,tmp3); - options=optionorg; - tmp=Divoptions(options); - stL=tmp_7; - geo=0; - forall(stL, - tmp=Toupper(substring(#,0,1)); - if(tmp=="G",geo=1); - options=remove(options,[#]); - ); - ReadOutData(file); - tmp=file+"n_1_1"; - nn=parse(tmp); - out=[]; - forall(1..nn,nc, - tmp=file+text(nc); - tmp1=parse(tmp+"k"); - tmp2=parse(tmp+"c"); - if(MeasureDepth(tmp2)==1,tmp2=[tmp2]); // 16.04.22from - if(geo==1, - alpha="abcdefghijklmnopqrstuvwxyz"; - forall(1..length(tmp1), - tmp="k"+BezierNumber+"n"+text(nc)+substring(alpha,#-1,#); - Putpoint(tmp,tmp1_#,parse(tmp+".xy")); - inspect(parse(tmp),"labeled",false); - inspect(parse(tmp),"ptsize",3); - tmp1_#=parse(tmp+".xy"); - ); - forall(1..length(tmp2), - tmp="c"+BezierNumber+"n"+text(nc)+substring(alpha,#-1,#)+"1"; - Putpoint(tmp,tmp2_#_1,parse(tmp+".xy")); - inspect(parse(tmp),"labeled",false); - inspect(parse(tmp),"color",4); - inspect(parse(tmp),"ptsize",3); - tmp2_#_1=parse(tmp+".xy"); - tmp="c"+BezierNumber+"no"+text(nc)+substring(alpha,#-1,#)+"2"; - Putpoint(tmp,tmp2_#_2,parse(tmp+".xy")); - inspect(parse(tmp),"labeled",false); - inspect(parse(tmp),"color",4); - inspect(parse(tmp),"ptsize",3); - tmp2_#_2=parse(tmp+".xy"); - ); - BezierNumber=BezierNumber+1; - ); - Bezier(file+text(nc),tmp1,tmp2,options);// 16.04.22upto - out=append(out,"bz"+tmp); - ); - out; -); - -Ospline(nm,ptlist):=Ospline(nm,ptlist,[]); -Ospline(nm,ptlist,options):=( -//help:Ospline("1",ptlist,[options]); - regional(tmp,tmp1,tmp2,list,ptL,ctrL,name,closed,flg, - p0,p1,p2,p3,pQ,pR,cc,p01,p02,p11,p12,p21,p22,p31,p32); - name="o"+nm; - if(isstring(ptlist),list=parse(ptlist),list=ptlist); - if(|list_1-list_(length(list))|<10^(-6),closed=1,closed=0); -// list=apply(list,LLcrd(#)); - ctrL=[]; - forall(1..(length(list)-1), - flg=0; - p1=Lcrd(list_#); // 16.08.16 - p2=Lcrd(list_(#+1)); // 16.08.16 - if(#==1 % #==length(list)-1, - flg=1; - if(closed==0, - pQ=(p1+2*p2)/3; // 15.09.21 // 16.08.16 - pR=(2*p1+p2)/3; // 16.08.16 - ctrL=append(ctrL,[pQ,pR]); - flg=2; - , - if(#==1, - p0=Lcrd(list_(length(list)-1)); // 16.08.16 - p3=Lcrd(list_(#+2)); // 16.08.16 - , - p0=Lcrd(list_(#-1)); // 16.08.16 - p3=Lcrd(list_2); // 16.08.16 - ); - ); - ); - if(flg<=1, - if(flg==0, - p0=Lcrd(list_(#-1)); // 16.08.16 - p3=Lcrd(list_(#+2)); // 16.08.16 - ); - tmp=1+sqrt((1+Dotprod(p2-p0,p3-p1)/|p2-p0|/|p3-p1|)/2); - cc=4*|p2-p1|/3/(|p2-p0|+|p3-p1|)/tmp; - pQ=p1+cc*(p2-p0); // 15.09.21 // 16.08.16 - pR=p2+cc*(p1-p3); // 16.08.16 - ctrL=append(ctrL,[pQ,pR]); - ); - ); -// list=apply(list,LLcrd(#)); // 16.08.16 -// ctrL=apply(ctrL,LLcrd(#)); - if(closed==0, // 15.09.21 - p1=ctrL_2_1; - p2=Lcrd(list_2); // 16.08.16 - pQ=p2+(p2-p1); - ctrL_1=[pQ]; - tmp=length(ctrL); - tmp1=ctrL_(tmp-1); - p1=ctrL_(tmp-1)_2; - p2=Lcrd(list_(tmp)); // 16.08.16 - pQ=p2+(p2-p1); - ctrL_tmp=[pQ]; - ); - Bezier("o"+nm,list,ctrL,options); -); - -CRspline(nm,ptL):=CRspline(nm,ptL,[]); -CRspline(nm,ptL,options):=( - // Catmull-Rom spline -//help:CRspline("1",[A,B,C,A]); - regional(name,ptlist,ctrpts,eqL,opcindy,c,v,tmp,tmp1,tmp2,ctrlist,cflg); - name="crsp"+nm; - if(MeasureDepth(ptL)==1,tmp=[ptL],tmp=ptL); - ptlist=tmp_1; - if(length(tmp)==1, - cflg=1; - , - cflg=0; - ctrpts=tmp_2; - ); - c=1/6; - tmp=Divoptions(options); - eqL=tmp_5; - opcindy=tmp_(length(tmp)); // 15.03.05 - forall(eqL, - if(substring(#,0,1)=="R", - tmp2=indexof(#,"="); - c=parse(substring(#,tmp2,length(#))); - ); - ); - ptlist=apply(ptlist,Lcrd(#)); // 16.08.16 - ctrlist=[]; - forall(1..(length(ptlist)-1), - if(#==1, - if(cflg==0, - tmp1=ctrpts_1; - , - v=ptlist_2-ptlist_(length(ptlist)-1); - tmp1=ptlist_#+c*v; - ); - , - v=ptlist_(#+1)-ptlist_(#-1); - tmp1=ptlist_#+c*v; - ); - if(#==length(ptlist)-1, - if(cflg==0, - tmp2=ctrpts_2; - , - v=ptlist_2-ptlist_#; - tmp2=ptlist_(#+1)-c*v; - ); - , - v=ptlist_(#+2)-ptlist_#; - tmp2=ptlist_(#+1)-c*v; - ); - tmp=select(options,indexof(text(#),"->")>0); - tmp=append(tmp,"notex"); //15.03.05 - Pointdata(name+text(#),[tmp1,tmp2],tmp); - ctrlist=append(ctrlist,[tmp1,tmp2]); - ); - Bezier(nm,ptlist,ctrlist,options); -); - -Beziersmooth(nm,ptL):=Bzspline(nm,ptL,[]); -//help:Beziersmooth("1",[A,B,C,A]); -Beziersmooth(nm,ptL,options):=Bzspline(nm,ptL,options); -Bzspline(nm,ptL):=Bzspline(nm,ptL,[]); -Bzspline(nm,ptLorg,options):=( - // smooth bezier - regional(name,Eps,ptL,pt,pt1,pt2,pt3,npt,lstr, - tmp,tmp1,tmp2,cflg,ctrlist); - name="bzsp"+nm; - Eps=10^(-3); - ptL=apply(ptLorg,Lcrd(#)); // 16.08.16 - if(|ptL_1-ptL_(length(ptL))|<Eps,cflg=1,cflg=0); - forall(2..length(ptL), - pt=ptL_#; - pt1=ptL_(#-1); - tmp1="C"+text(#-1)+"q"; - Putpoint(tmp1,(pt1+4*pt)/5,Lcrd(parse(tmp1))); // 16.08.16 - ); - forall(2..(length(ptL)-1), - if(#<length(ptL) % cflg==1, - lstr="c"+text(#); - pt=ptLorg_#; // 16.08.16 - pt1=parse("C"+text(#-1)+"q"); - create([lstr],"Join",[pt1,pt]); - tmp2="C"+text(#)+"p"; - tmp=Append((2*pt.xy-pt1.xy),1); - create([tmp2],"PointOnLine",[parse(lstr),tmp]); - ); - ); - if(cflg==0, - pt=ptL_1; - pt1=ptL_2; - tmp1="C1p"; - Putpoint(tmp1,(4*pt+pt1)/5,Lcrd(parse(tmp1))); // 16.08.16 - ); - if(cflg==1, - lstr="c1"; - pt=ptLorg_1; // 16.08.16 - pt1=parse("C"+text(length(ptL)-1)+"q"); - create([lstr],"Join",[pt1,pt]); - tmp1="C1p"; - tmp=Append((2*pt.xy-pt1.xy),1); - create([tmp1],"PointOnLine",[parse(lstr),tmp]); - ); - ctrlist=[]; - forall(1..(length(ptL)-1), - if(#>1 % cflg==1, - tmp1="c"+text(#); - inspect(parse(tmp1),"alpha",0.3); - ); - tmp1="C"+text(#)+"p"; - tmp2="C"+text(#)+"q"; - inspect(parse(tmp1),"ptsize",3); - inspect(parse(tmp1),"color",3); - inspect(parse(tmp2),"ptsize",3); - inspect(parse(tmp2),"color",3); - tmp=[parse(tmp1),parse(tmp2)]; - ctrlist=append(ctrlist,tmp); - ); - Bezier(nm,ptL,ctrlist,options); - [ptL,ctrlist]; -); - -Beziersym(nm,ptL):=Bzsspline(nm,ptL,[]); -Beziersym(nm,ptL,options):=Bzsspline(nm,ptL,options); -Bzsspline(nm,ptL):=Bzsspline(nm,ptL,[]); -Bzsspline(nm,ptLorg,options):=( - // smooth bezier with symmetric control points - regional(name,Eps,ptL,pt,pt1,pt2,pt3,npt,lstr, - tmp,tmp1,tmp2,cflg,ctrlist); - name="bzssp"+nm; - Eps=10^(-3); - ptL=apply(ptLorg,Lcrd(#)); // 16.08.16 - if(|ptL_1-ptL_(length(ptL))|<Eps,cflg=1,cflg=0); - forall(2..length(ptL), - pt=ptL_#; - pt1=ptL_(#-1); - tmp1="C"+text(#-1)+"q"; - Putpoint(tmp1,(pt1+4*pt)/5,Lcrd(parse(tmp1))); - ); - forall(2..(length(ptL)-1), - if(#<length(ptL) % cflg==1, - pt=ptL_#; - pt1=parse("C"+text(#-1)+"q"); - tmp2="C"+text(#)+"p=2*pt-pt1"; - parse(tmp2); - ); - ); - if(cflg==0, - pt=ptL_1; - pt1=ptL_2; - Putpoint("C1p",(4*pt+pt1)/5,Lcrd(C1p)); // 16.08.16 - inspect(C1p,"ptsize",3); - inspect(C1p,"color",3); - ); - if(cflg==1, - pt=ptL_1; - pt1=Lcrd(parse("C"+text(length(ptL)-1)+"q")); // 16.08.16 - tmp1="Putpoint("+Dq+"C1p"+Dq+",2*pt-pt1)"; // 16.08.16 - parse(tmp1); - ); - ctrlist=[]; - forall(1..(length(ptL)-1), - tmp1="C"+text(#)+"p"; - tmp2="C"+text(#)+"q"; - inspect(parse(tmp2),"ptsize",3); - inspect(parse(tmp2),"color",3); - tmp=[parse(tmp1),parse(tmp2)]; - ctrlist=append(ctrlist,tmp); - ); - Bezier(nm,ptL,ctrlist,options); - [ptL,ctrlist]; -); - -Listbspline2bz(listorg):=( - regional(Eps,list,pcl,ptl,ctrl,k); - Eps=10^(-3); - list=apply(listorg,Lcrd(#)); // 16.08.16 - k=length(list); - if(|list_1-list_k|>Eps, - pcl=list; - pcl_1=2*list_1-list_2; - pcl_k=2*list_k-list_(k-1); - , - pcl=concat(list,[list_2]); - ); - ctrl=apply(2..(length(pcl)-1),[pcl_#]); - ptl=apply(1..(length(pcl)-1),(pcl_#+pcl_(#+1))/2); - [ptl,ctrl]; -); - -Bspline(nm,ctrL):=Bspline(nm,ctrL,[]); -Bspline(nm,ctrL,options):=( -//help:Bspline("",[A,B,C]); - regional(list,tmp); - list=Listbspline2bz(ctrL); - tmp=BezierCurve("b"+nm,list_1,list_2,options); - tmp; -); - -MeetCurve(Crv,Xorg,Yorg):=( - regional(Cv,tmp,tmp1,tmp2,X0,Y0,x1,x2,y1,y2,Ylist,Ban,Tate); - if(isstring(Crv),Cv=parse(Crv),Cv=Crv); - if(MeasureDepth(Cv)==2,Cv=Cv_1); - Cv=apply(Cv,LLcrd(#)); // 14.12.18 - while(length(Cv)==1, - Cv=Cv_1; - ); - Cv=apply(Cv,Lcrd(#)); - tmp1=min(apply(Cv,#_1)); - tmp2=max(apply(Cv,#_1)); - if(isstring(Xorg),X0=parse(Xorg),X0=Xorg); - if(isstring(Yorg),Y0=parse(Yorg),Y0=Yorg); - if(X0<tmp1, - X0=tmp1; - , - if(X0>tmp2, - X0=tmp2; - ); - ); - tmp1=select( - 1..(length(Cv)-1),Cv_#_1<=X0 & X0<=Cv_(#+1)_1); - tmp2=select( - 1..(length(Cv)-1),Cv_#_1>=X0 & X0>=Cv_(#+1)_1); - tmp2=remove(tmp2,common(tmp2,tmp1)); - Ban=concat(tmp1,tmp2); - Tate=select(Ban, - abs(Cv_#_1-Cv_(#+1)_1)<= - 10^(-2)*abs(Cv_#_2-Cv_(#+1)_2) - ); - Ban=remove(Ban,Tate); - Ylist=[]; - forall(Ban, - tmp=Cv_#; - x1=tmp_1; y1=tmp_2; - tmp=Cv_(#+1); - x2=tmp_1; y2=tmp_2; - tmp=((x2-X0)*y1+(X0-x1)*y2)/(x2-x1); - Ylist=append(Ylist,tmp); - ); - forall(Tate, - tmp=Cv_#; - x1=tmp_1; y1=tmp_2; - tmp=Cv_(#+1); - x2=tmp_1; y2=tmp_2; - tmp1=min([y1,y2]); - tmp2=max([y1,y2]); - if(Y0<tmp1, - tmp=tmp1; - , - if(Y0>tmp2, - tmp=tmp2; - , - tmp=Y0; - ); - ); - Ylist=append(Ylist,tmp); - ); - tmp=sort(Ylist,abs(#_1-Y0)); - [X0,tmp_1]; -); - -PutonLine(name,p1,p2):=PutonLine(name,p1,p2,[]); -PutonLine(name,p1org,p2org,options):=( -//help:PutonLine("C","sgAB"); -//help:PutonLine("C",pA,pB); - regional(par,p1,p2,dx,dy,tmp,tmp1,tmp2); - par=0.5; - tmp=Divoptions(options); - if(length(tmp_6)>0, - par=tmp_6_1; - ); - p1=Lcrd(p1org);//16.10.11from - p2=Lcrd(p2org); - dx=p2_1-p1_1; - dy=p2_2-p1_2; - tmp1=(1-par)*p1+par*p2; - if(abs(dx)>abs(dy), - tmp=name+".x"; - tmp2="["+tmp+",dy/dx*("+tmp+"-p1_1)+p1_2]";//16.10.11upto - Putpoint(name,tmp1,parse(tmp2)); - , - if(abs(dy)>0, - tmp=name+".y"; - tmp2="[dx/dy*("+tmp+"-p1.y)+p1_1,"+tmp+"]"; - Putpoint(name,tmp1,parse(tmp2)); - , - tmp2=p1;//16.10.11 - Putpoint(name,tmp1,tmp2); - ); - ); -); - -PutonSeg(name,sgstr):=( - regional(seg,p1,p2); - if(isstring(sgstr),seg=parse(sgstr),seg=sgstr); - PutonSeg(name,LLcrd(seg_1),LLcrd(seg_2)); -); -PutonSeg(name,p1,p2):=PutonSeg(name,p1,p2,[]); -PutonSeg(name,p1org,p2org,options):=( -//help:PutonSeg("C","sgAB"); -//help:PutonSeg("C",pA,pB); - regional(par,dx,dy,p,tmp,tmp1,tmp2); - par=0.5; - tmp=Divoptions(options); - if(length(tmp_6)>0, - par=tmp_6_1; - ); - p1=Lcrd(p1org);//16.10.11from - p2=Lcrd(p2org); - PutonLine(name,p1,p2,[par]); - dx=p2_1-p1_1; - dy=p2_2-p1_2; - p=parse(name+".xy"); - p=LLcrd(p); - if(abs(dx)>abs(dy) & (p_1-p1_1)*(p_1-p2_1)>0, - if(|p-p1|<|p-p2|, - parse(name+".xy=Pcrd(p1)"); - , - parse(name+".xy=Pcrd(p2)"); - ); - ); - if(abs(dx)<abs(dy) & (p_2-p1_2)*(p_2-p2_2)>0, - if(|p-p1|<|p-p2|, - parse(name+".xy=Pcrd(p1)"); - , - parse(name+".xy=Pcrd(p2)");//16.10.11upto - ); - ); -); - -PutonCurve(pn,crv):=PutonCurve(pn,crv,[]); -PutonCurve(pn,crv,options):=( -//help:PutonCurve("A","gr1"); - regional(Pmt,pstr,optionL,leftlim,rightlim,tmp,tmp1,Flg,Msg); - if(!islist(options),optionL=[options],optionL=options); - leftlim=XMIN; - rightlim=XMAX; - Flg=0; - Msg="y"; - forall(optionL, - if(isstring(#), // 16.02.10 from - tmp=indexof(#,"="); - tmp1=Toupper(substring(#,tmp,tmp+1)); - if(tmp1=="N", Msg="n"); // 16.02.10 upto - , - if(Flg==0, - leftlim=#; - Flg=Flg+1; - , - rightlim=#; - ); - ); - ); - Pmt=MeetCurve(crv,leftlim,0); - pstr=apply(allpoints(),textformat(#,5)); // 15.04.07 - if(!contains(pstr,pn), - createpoint(pn,Pcrd(Pmt)); - , - tmp1=parse(pn+".x"); - if(tmp1< leftlim % tmp1>rightlim, - if(tmp1< leftlim,tmp= leftlim, tmp=rightlim); - Pmt=MeetCurve(crv,textformat(tmp,5),pn+".y"); - , - Pmt=MeetCurve(crv,pn+".x",pn+".y"); - ); - ptstr=pn+".xy="+textformat(Pcrd(Pmt),5)+";"; - parse(ptstr); - ); - if(Msg=="y", - println("Put "+pn+" on Curve "+text(crv)); - ); -); - -CrossPoint(name,Crv1,Crv2,range):=( - regional(Mx1,Mx2,Mx3,tmp,Crs1,Crs2,Crs3,Crs4,df1,df2); - Mx1=range_1; Mx2=range_2; - repeat(15, - Mx3=(Mx1+Mx2)/2; - Crs1=MeetCurve(Crv1,Mx1,0); - Crs2=MeetCurve(Crv2,Mx1,0); - Crs3=MeetCurve(Crv1,Mx3,0); - Crs4=MeetCurve(Crv2,Mx3,0); - df1=Crs1_2-Crs2_2; - df2=Crs3_2-Crs4_2; - if((df1>0 & df2>0) % (df1<0 & df2<0), - Mx1=Mx3; - , - Mx2=Mx3; - ); - ); - Putpoint(name,Crs1); -); - -Setscaling(sc):=( -//help:Setscaling(3); - SCALEX=1; - SCALEY=sc; - Com0th("Setscaling("+sc+")"); - Setwindow("Msg=no"); -); - -Tabledatalight(nm,xLst,yLst,rmvL):=Tabledatalight(nm,xLst,yLst,rmvL,[]); -Tabledatalight(nm,xLst,yLst,rmvL,options):=( -//help:Tabledatalight("",xLst,yLst,rmvL,[2]); - regional(name,upleft,ul,flg,tick,n,m,xsize,ysize,rlist,clist,Tb, - tmp,tmp1,tmp2,tmp3,Eps); -// name="tb"+nm; - name="tb"; - println("Tabledatalight "+name+" generated"); - tmp=sum(yLst); - upleft=[0,tmp]; - tick=1; - tmp=Divoptions(options); - flg=0; - forall(tmp_6, - if(flg==0, - tick=#; - flg=flg+1; - , - upleft=tmp_6_1; - ); - ); - ul=upleft/10; - m=length(xLst); - n=length(yLst); - xsize=sum(xLst); - ysize=sum(yLst); - clist=[ul]; - rlist=[ul]; - forall(1..m, - tmp1=clist_(#)_1+xLst_#/10; - clist=append(clist,[tmp1,clist_1_2]); - ); - forall(1..n, - tmp1=rlist_(#)_2-yLst_#/10; - rlist=append(rlist,[0,tmp1]); - ); - Tb=[clist,rlist]; - tmp=name+"="+Tb; - parse(tmp); - forall(0..m, - tmp1="c"+text(#)+"r0"; - tmp2="c"+text(#)+"r"+text(n); - Tlistplot("c"+text(#)+"r0r"+text(n),[tmp1,tmp2],options); - if(mod(#,tick)==0 % #==m, - tmp=clist_(#+1); - drawtext(clist_(#+1)-[0.04,-0.1],"c"+text(#)); - ); - ); - forall(0..n, - tmp1="c0r"+text(#); - tmp2="c"+text(m)+"r"+text(#); - Tlistplot("r"+text(#)+"c0c"+text(m),[tmp1,tmp2],options); - if(mod(#,tick)==0 % #==n, - tmp=rlist_(#+1); - drawtext(rlist_(#+1)-[0.4,0.1],"r"+text(#)); - ); - ); - Tsegrmv(rmvL,options); - Addax(0); - Eps=10^(-3); - tmp1=clist_(length(clist)); - tmp2=rlist_1; - tmp3=rlist_(length(rlist)); - Setwindow([0-Eps,tmp1_1+Eps],[tmp3_2-Eps,tmp2_2+Eps]); - Tb; -); - -Tabledata(nm,n,m,xsize,ysize,rmvL):= - Tabledata(nm,n,m,xsize,ysize,rmvL,[]); -Tabledata(nm,n,m,xsize,ysize,rmvL,options):=( - regional(Tb,name,tmp,xLst,yLst); - name="tb"+nm; - xLst=apply(1..n,xsize/n); - yLst=apply(1..m,ysize/m); - Tabledata(nm,xLst,yLst,rmvL,options) -); -Tabledata(nm,xLst,yLst,rmvL):=Tabledata(nm,xLst,yLst,rmvL,[]); -Tabledata(nm,xLst,yLst,rmvL,options):=( -//help:Tabledata("",xLst,yLst,rmvL,[2]); - regional(name,upleft,ul,flg,tick,n,m,xsize,ysize,rlist,clist,Tb, - tmp,tmp1,tmp2,tmp3,Eps); -// name="tb"+nm; - name="tb"; - println("Tabledata "+name+" generated"); - tmp=sum(yLst); - upleft=[0,tmp]; - tick=1; - tmp=Divoptions(options); - flg=0; - forall(tmp_6, - if(flg==0, - tick=#; - flg=flg+1; - , - upleft=tmp_6_1; - ); - ); - ul=upleft/10; - m=length(xLst); - n=length(yLst); - xsize=sum(xLst); - ysize=sum(yLst); - clist=[ul]; - rlist=[ul]; - forall(1..m, - tmp1=clist_(#)_1+xLst_#/10; - clist=append(clist,[tmp1,clist_1_2]); - ); - forall(1..n, - tmp1=rlist_(#)_2-yLst_#/10; - rlist=append(rlist,[0,tmp1]); - ); - Tb=[clist,rlist]; - tmp=name+"="+Tb; - parse(tmp); - forall(0..m, - tmp="C"+text(#); - tmp1="c"+text(#)+"r0"; - if(#==0, - Putpoint(tmp,Tgrid(tmp1)); - , - Putpoint(tmp,Tgrid(tmp1),[parse(tmp+".x"),C0.y]); - clist_(#+1)=parse(tmp+".xy"); - ); - inspect(parse(tmp),"ptsize",3); - inspect(parse(tmp),"labeled",false); - if(mod(#,tick)==0 % #==m, - tmp=clist_(#+1); - drawtext(clist_(#+1)-[0.04,-0.1],"c"+text(#)); - ); - ); - forall(0..n, - tmp="R"+text(#); - tmp1="c0r"+text(#); - if(#==0, - Putpoint(tmp,Tgrid(tmp1)); - , - Putpoint(tmp,Tgrid(tmp1),[R0.x,parse(tmp+".y")]); - rlist_(#+1)=parse(tmp+".xy"); - ); - Putpoint(tmp,Tgrid(tmp1),[R0.x,parse(tmp+".y")]); - inspect(parse(tmp),"ptsize",3); - inspect(parse(tmp),"labeled",false); - if(mod(#,tick)==0 % #==n, - tmp=rlist_(#+1); - drawtext(rlist_(#+1)-[0.4,0.1],"r"+text(#)); - ); - ); - Tb=[clist,rlist]; - tmp=name+"="+Tb; - parse(tmp); - forall(0..m, - tmp1="c"+text(#)+"r0"; - tmp2="c"+text(#)+"r"+text(n); - Tlistplot("c"+text(#)+"r0r"+text(n),[tmp1,tmp2],options); - if(#<m, - tmp1=parse("C"+text(#)); - tmp2=parse("C"+text(#+1)); - tmp=(tmp1.xy+tmp2.xy)/2; - drawtext(tmp+[-0.2,0.5],text((tmp2.x-tmp1.x)*10)); - ); - ); - forall(0..n, - tmp1="c0r"+text(#); - tmp2="c"+text(m)+"r"+text(#); - Tlistplot("r"+text(#)+"c0c"+text(m),[tmp1,tmp2],options); - if(#<n, - tmp1=parse("R"+text(#)); - tmp2=parse("R"+text(#+1)); - tmp=(tmp1.xy+tmp2.xy)/2; - drawtext(tmp-[1.2,0.1],text(abs(tmp1.y-tmp2.y)*10)); - ); - ); - Tsegrmv(rmvL,options); - Addax(0); - Eps=10^(-3); - tmp1=clist_(length(clist)); - tmp2=rlist_1; - tmp3=rlist_(length(rlist)); // 15.06.11 - Setwindow([0-Eps,tmp1_1+Eps],[tmp3_2-Eps,tmp2_2+Eps]); - Tb; -); - -Tseginfo(seg):=( - regional(cr,tp,tpc,n1,n2,n3,tmp,tmp1,tmp2); - if(substring(seg,0,2)=="sg", - cr=substring(seg,2,length(seg)); - , - cr=seg; - ); - tp=substring(cr,0,1); - if(tp=="c", - tpc="r"; - , - tpc="c"; - ); - tmp1=indexof(cr,tpc); - tmp=substring(cr,tmp1,length(cr)); - tmp2=tmp1+indexof(tmp,tpc); - n1=substring(cr,1,tmp1-1); - n2=substring(cr,tmp1,tmp2-1); - n3=substring(cr,tmp2,length(cr)); - [tp+n1,tpc,parse(n2),parse(n3)]; -); - -Tsegrmv(rmvL):=Tsegrmv(rmvL,[]); -Tsegrmv(rmvL,options):=( - regional(cr,gcL,flg,gc,hd,tail,tpc,m1,m2,n1,n2,tmp,tmp1,tmp2); - forall(rmvL,cr, - tmp1=Tseginfo(cr); - hd=tmp1_1; - tpc=tmp1_2; - m1=tmp1_3; - m2=tmp1_4; - gcL=select(GCLIST,Tseginfo(#_1)_1==tmp1_1); - flg=0; - forall(gcL, - if(flg==0, - tmp=Tseginfo(#_1); - n1=tmp_3; - n2=tmp_4; - if(m1>=n1 & m2<=n2, - gc=#; - flg=1; - ); - ); - ); - if(flg==1, - Changestyle([gc_1],["nodisp"]); - tail=""; - if(indexof(hd,"r")>0, - tail=hd; hd=""; - ); - if(n1<m1, - tmp1=tpc+text(n1); - tmp2=tpc+text(m1); - tmp=hd+tail+tmp1+tmp2; - Tlistplot(tmp,[hd+tmp1+tail,hd+tmp2+tail],options); - ); - if(m2<n2, - tmp1=tpc+text(m2); - tmp2=tpc+text(n2); - tmp=hd+tail+tmp1+tmp2; - Tlistplot(tmp,[hd+tmp1+tail,hd+tmp2+tail],options); - ); - ); - ); -); - -Tgrid(ptstr):=( -//help:Tgrid("c2r5"); - regional(tmp,tmp1,tmp2); - tmp=parse(ptstr); - if(islist(tmp), - tmp; - , - tmp=indexof(ptstr,"r"); - tmp1=substring(ptstr,1,tmp-1); - tmp1=parse(tmp1); - tmp2=substring(ptstr,tmp,length(ptstr)); - tmp2=parse(tmp2); - [tb_1_(tmp1+1)_1,tb_2_(tmp2+1)_2]; - ); -); - -Tlistplot(ptL):=Tlistplot(ptL,[]); -Tlistplot(Ag1,Ag2):=( - regional(nm,ptL,options); - if(isstring(Ag1), - nm=Ag1; - ptL=Ag2; - options=[]; - , - ptL=Ag1; - options=Ag2; - nm=ptL_1+ptL_2; - ); - Tlistplot(nm,ptL,options); -); -Tlistplot(nm,ptL,options):=( -//help:Tlistplot(["c0r0","c0r4"]); -//help:Tlistplot("1",["c0r0","c0r4"]); - regional(tmp); - tmp=apply(ptL,Tgrid(#)); // 15.06.03 - Listplot(nm,tmp,append(options,"Msg=no")); -); - -ChangeTablestyle(nameL,style):=( -////help:ChangeTablestyle(["r0c0c3"],["da"]); - regional(nmL,tmp,tmp1,tmp2); - if(islist(nameL),nmL=nameL,nmL=[nameL]); - nmL=apply(nmL,"sg"+#); - nmL=select(nmL,islist(parse(#))); - Changestyle(nmL,style); -); - -Findcell(pos1,pos2):=Findcell("",pos1,pos2); -Findcell(Tbdata,pos1,pos2):=( -//help:Findcell("c0r0","c2r1"); - regional(tmp1,tmp2,posnw,posse,ctr,dx,dy); - if(isstring(pos1), - posnw=Tgrid(pos1); // 15.05.20 - posse=Tgrid(pos2); - //posnw=parse(pos1); - //posse=parse(pos2); - , - if(islist(pos1), - posnw=pos1; - posse=pos2; - , - tmp1="c"+text(pos1-1)+"r"+text(pos2-1); - tmp2="c"+text(pos1)+"r"+text(pos2); - posnw=Tgrid(tmp1); - posse=Tgrid(tmp2); -// posnw=parse(tmp1); -// posse=parse(tmp2); - ); - ); - ctr=(posnw+posse)/2; - dx=abs(posse_1-ctr_1); - dy=abs(posnw_2-ctr_2); - [ctr,dx,dy]; -); - -Putcell(pos1,pos2,dir,lttr):=Putcell("",pos1,pos2,dir,lttr); -Putcell(Tbdata,pos1,pos2,dir,lttr):=( -//help:Putcell("c0r0","c2r1","lt","abc"); -//help:Putcell(2,3,"c","xyz"); - regional(tmp,tmp1,tmp2,posnw,posse, - posdir,posstr,ctr,dx,dy); - tmp=Findcell(Tbdata,pos1,pos2); - ctr=tmp_1; dx=tmp_2; dy=tmp_3; - posdir=ctr; - posstr=dir; - if(indexof(dir,"b")>0, - posdir_2=posdir_2-dy; - posstr=replace(posstr,"b","n"); - ); - if(indexof(dir,"t")>0, - posdir_2=posdir_2+dy; - posstr=replace(posstr,"t","s"); - ); - if(indexof(dir,"l")>0, - posdir_1=posdir_1-dx; - posstr=replace(posstr,"l","e"); - ); - if(indexof(dir,"r")>0, - posdir_1=posdir_1+dx; - posstr=replace(posstr,"r","w"); - ); - Letter(posdir,posstr,text(lttr)); -); - -Putcellexpr(pos1,pos2,dir,ex):=Putcellexpr("",pos1,pos2,dir,ex); -Putcellexpr(Tbdata,pos1,pos2,dir,ex):=( -//help:Putcellexpr("c0r0","c2r1","lt","abc"); -//help:Putcellexpr(2,3,"c","\sin x"); - Putcell(Tbdata,pos1,pos2,dir,"$"+text(ex)+"$"); -); - -Putrow(nrow,dir,lttrL):=Putrow("",nrow,dir,lttrL); -Putrow(Tbdata,nrow,dir,lttrL):=( -//help:Putrow(1,"c",["x","y","z"]); - regional(tmp,tmp1,mcol); - mcol=length(lttrL); - forall(1..mcol, - Putcell(Tbdata,#,nrow,dir,lttrL_#); - ); -); - -Putrowexpr(nrow,dir,exL):=Putrowexpr("",nrow,dir,exL); -Putrowexpr(Tbdata,nrow,dir,exL):=( -//help:Putrowexpr(2,"r",["x","y","z"]); - regional(lttrL); - lttrL=apply(exL,"$"+#+"$"); - Putrow(Tbdata,nrow,dir,lttrL); -); - -PutcoL(mcol,dir,lttrL):=PutcoL("",mcol,dir,lttrL); -PutcoL(Tbdata,mcol,dir,lttrL):=( -//help:PutcoL(1,"c",["x","y","z"]); - regional(tmp,tmp1,nrow); - nrow=length(lttrL); - forall(1..nrow, - Putcell(Tbdata,mcol,#,dir,lttrL_#); - ); -); -PutcoLexpr(mcol,dir,exL):=PutcoLexpr("",mcol,dir,exL); -PutcoLexpr(Tbdata,mcol,dir,exL):=( -//help:PutcoLexpr(2,"r",["x","y","z"]); - regional(lttrL); - lttrL=apply(exL,"$"+#+"$"); - PutcoL(Tbdata,mcol,dir,lttrL); -); - -Setwindow():=Setwindow("Msg=yes"); -Setwindow(str):=( - regional(tmp,tmp1,tmp2,msg); - msg="y"; - tmp=indexof(str,"="); // 16.02.10 - tmp1=Toupper(substring(str,tmp,tmp+1)); - if(tmp1=="N",msg="n"); - if((ispoint(SW) & ispoint(NE)), - tmp1=Lcrd(SW); - tmp2=Lcrd(NE); - XMIN=tmp1_1; XMAX=tmp2_1; - YMIN=tmp1_2; YMAX=tmp2_2; - , -// XMIN=-5; XMAX=5; -// YMIN=Lcrdy(-5); YMAX=Lcrdy(5); - createpoint("SW",Pcrd([XMIN,YMIN])); - createpoint("NE", Pcrd([XMAX,YMAX])); - ); - if(msg=="y", - println("Setwindow(["+XMIN+","+XMAX+"],["+YMIN+","+YMAX+"])"); - ); - layer(KETPICLAYER); - autoclearlayer(KETPICLAYER,true); - drawpoly([Pcrd([XMIN,YMIN]), Pcrd([XMAX,YMIN]), - Pcrd([XMAX,YMAX]),Pcrd([XMIN,YMAX])],color->[1,1,1]); -); -Setwindow(xrange,yrange):=( -//help:Setwindow([2,3],[-1,1]); - XMIN=xrange_1; - XMAX=xrange_2; - YMIN=yrange_1; - YMAX=yrange_2; -// Setwindow(); -); - -Sciform(list):=( - regional(plotlist,comp,pos,out,out2,nn,strL,flg, - tmp,tmp1,tmp2,tmp3,Nj); - plotlist=Flatten([list]); - out=replace(plotlist_1,".xy",""); - out=replace(out,".x","(1)"); - out=replace(out,".y","(2)"); - if(length(plotlist)==1, - comp=[]; - forall(1..length(out), - comp=append(comp,substring(out,#-1,#)); - ); - out=""; - pos=0; - forall(comp, - if(#!="'", - out=out+#; - , - if(pos==0, - tmp=indexof(out,"Assign("); - if(substring(out,length(out)-7,length(out))=="Assign(", - out=out+"'"; - pos=1; - , - out=out+"Assign('"; - pos=2; - ); - , - if(pos==2, - out=out+"')"; - , - out=out+"'"; - ); - pos=0; - ); - ); - ); - , - forall(2..length(plotlist), - comp=plotlist_#; - if(isstring(comp), - pos=indexof(comp,"Assign("); - if(pos>0, - comp=substring(comp,6,length(comp)); - ); - out=out+"Assign("; - comp=replace(comp,".xy",""); - comp=replace(comp,".x","(1)"); - comp=replace(comp,".y","(2)"); - out=out+"'"+comp+"'"; - out=out+"),"; - ); - if(islist(comp), - forall(comp, - out=out+"'"+#+"',"; - ); - ); - ); - if(length(plotlist)>1, - out=substring(out,0,length(out)-1); - out=out+");"; - ); - ); - pos=[]; - forall(1..length(out), - tmp=indexof(substring(out,#-1,length(out)),"Assign"); - if(tmp>0, - tmp1=#-1+tmp; - if(length(pos)==0, - pos=[tmp1]; - , - if(pos_(length(pos))<tmp1, - pos=append(pos,tmp1); - ); - ); - ); - ); - if(length(pos)>0, - strL=[]; - Nj=0; - forall(pos, - tmp=substring(out,Nj,#-1); - strL=append(strL,tmp); - Nj=#-1; - ); - strL=append(strL,substring(out,Nj,length(out))); - out=""; - forall(strL, - if(indexof(#,"Assign")==0, - out=out+#; - , - tmp=indexof(#,"('"); - tmp1=indexof(#,"')"); - tmp2=substring(#,tmp+1,tmp1-2); - tmp3=substring(#,tmp1-2,length(#)); - if(indexof(tmp2,"=")==0, - out=out+#; - , - tmp=substring(tmp2,0,indexof(tmp2,"=")); - out=out+"'"+tmp+"'+"+"Assign('"; - tmp=substring(tmp2,indexof(tmp2,"="),length(tmp2)); - out=out+tmp+tmp3; - ); - ); - ); - ); - out2=""; // patched 16.01.21 from - nn=length(out); - flg=0; - forall(1..nn, - if(flg==0, - tmp=indexof(out,"='+Assign('"); - if(tmp==0, - out2=out2+out; - flg=1; - , - out2=out2+substring(out,0,tmp); - out=substring(out,tmp+10,length(out)); - tmp=indexof(out,"'"); // 16.04.19 from - tmp1=substring(out,0,tmp-1); - tmp2="1234567890"; - tmp=apply(1..length(tmp1), - indexof(tmp2,substring(tmp1,#-1,#))); - tmp=min(tmp); - if(tmp==0, // 16.04.19 upto - out2=out2+"'+Assign('"; - , - tmp=indexof(out,"'"); - out=substring(out,0,tmp)+substring(out,tmp+1,length(out)); // 16.04.18 upto - ); - ); - ); - ); - out2=replace(out2,"Dist=","D="); - out2=replace(out2,"Dis=","D="); - out2; -); - - -Rform(list):=( - regional(plotlist,comp,pos,out,strL,tmp,tmp1,tmp2,tmp3,Nj); - out=list; - out=replace(out,"[[[","list([["); - out=replace(out,"[","c("); - out=replace(out,"]",")"); - out=replace(out,".xy",""); - out=replace(out,".x","[1]"); - out=replace(out,".y","[2]"); - out; -); - -Defvar(varstr):=( - regional(name,value,tmp,tmp1); - parse(varstr); - tmp=indexof(varstr,"="); - name=substring(varstr,0,tmp-1); - value=substring(varstr,tmp,length(varstr)); - value=parse(value); - tmp1=select(1..length(VLIST),VLIST_#_1==name+"="); - if(length(tmp1)>0, - tmp=tmp1_1; - VLIST_tmp=[name+"=",value]; - , - VLIST=prepend([name+"=",value],VLIST); - ); -); - -Defvar(name,value):=( -//help:Defvar("a",0.3); - regional(tmp,tmp1); - if(islist(value), - tmp1="["; - forall(value, - tmp1=tmp1+format(#,5)+","; - ); - tmp1=substring(tmp1,0,length(tmp1)-1)+"]"; - , - tmp1=format(value,5); - ); - tmp=name+"="+tmp1; // 15.02.06 - parse(tmp); - VLIST=select(VLIST,#_1!=name+"="); // 15.02.08 - VLIST=prepend([name+"=",value],VLIST); -); - -Iftosci(strorg):=( // 16.06.10 - regional(str,ifL,ppL,cpL,kk,sL, - tmp,tmp1,tmp2,tmp3,tmp4); - str=replace(strorg,LFmark,""); - ifL=Indexall(str,"if("); - ppL=Bracket(str,"()"); - cpL=Indexall(str,","); - tmp1=Bracket(str,"[]"); - forall(1..(length(tmp1)/2),kk, - cpL=select(cpL,#<tmp1_(2*kk-1)_1%#_1>tmp1_(2*kk)_1); - ); - forall(1..length(ifL),kk, - tmp=select(ppL,#_1>ifL_kk); - tmp1=tmp_1; - tmp2=select(tmp,#_2==-tmp1_2); - tmp2=tmp2_1; - tmp3=select(cpL,#>tmp1_1 & #<tmp2_1); - ifL_kk=[tmp1_1,tmp2_1,tmp1_2,tmp3]; - ); - forall(1..length(cpL),kk, - tmp=select(1..length(ifL),contains(ifL_#_4,cpL_kk)); - tmp1=tmp_(length(tmp)); - cpL_kk=[cpL_kk,tmp1]; - ); - sL=apply(1..length(str),substring(str,#-1,#)); - forall(1..length(ifL),kk, - tmp1=ifL_kk_1; - tmp2=ifL_kk_2; - tmp=select(cpL,#_2==kk); - tmp3=apply(tmp,#_1); - sL_tmp1=" "; - sL_tmp2=";end;"; - sL_(tmp3_1)=" then,"; - if(length(tmp3)>1, - sL_(tmp3_2)=";else,"; - ); - ); - tmp=sum(sL); -); - -Fortosci(strorg):=( - regional(str,jj,var,tmp,tmp1,tmp2,tmp3,tmp4, - Out,repL,Pflg,Iflg,Cflg); - str=strorg; - repL=[]; - tmp1=Indexall(str,"forall"); - tmp2=Indexall(str,","); - forall(1..length(tmp1),jj, - tmp=select(tmp2,#>tmp1_jj); - var=substring(str,tmp_1,tmp_2-1); - tmp3=substring(str,tmp1_jj-1,tmp_2-1); - tmp=indexof(tmp3,"("); - tmp4=substring(tmp3,tmp,length(tmp3)); - tmp=indexof(tmp4,","); - tmp4=substring(tmp4,0,tmp-1); - tmp4="for "+var+"="+tmp4; - tmp4=replace(tmp4,"..",":"); - repL=concat(repL,[tmp3,tmp4]); - ); - forall(1..length(repL)/2, - str=replace(str,repL_(2*#-1),repL_(2*#)); - ); - tmp=Bracket(str); - tmp=select(tmp,#_2==0); - tmp=tmp_1_1; - tmp1=substring(str,tmp-1,length(str)); - tmp1=replace(tmp1,")",";end"); - str=substring(str,0,tmp-1)+tmp1; - str=replace(str,";;",";"); - str; -); - -Deffun(name,bodylist):=( -//help:Deffun("f(x)",["regional(y)","y=x^2*(x-3)","y"]); // 16.02.18 - regional(funstr,tmp,tmp1,str,Pos); - funstr=name+":=("; - forall(bodylist, - funstr=funstr+#+";"; - ); - funstr=funstr+");"; - parse(funstr); - tmp=bodylist_(length(bodylist)); - str="function "+tmp+"="+name+","; - forall(1..(length(bodylist)-1), - tmp1=bodylist_#; - tmp1=replace(tmp1,LFmark,"");// 16.05.26 - tmp1=replace(tmp1," ","");// 16.05.26 - Pos=indexof(tmp1,"regional")+indexof(tmp1,"local"); - if(Pos==0, - tmp=replace(tmp1,".xy",""); - tmp=replace(tmp,".x","(1)"); - tmp=replace(tmp,".y","(2)"); - if(indexof(tmp,"if(")>0, - tmp=iftosci(tmp); - ); - if(indexof(tmp,"forall(")>0, // 16.05.26from - tmp=Fortosci(tmp); - ); // 16.05.26upto - str=str+tmp+","; - ); - ); - str=str+"endfunction;"; - FUNLIST=append(FUNLIST,str); -); - -Windispg():=( - regional(Nj,Nk,Dt,Vj,tmp,tmp1,tmp2,tmp3,opcindy); - gsave(); - layer(KETPIClayer); - forall(GCLIST,Nj, - if(isstring(Nj_1),Dt=parse(Nj_1),Dt=Nj_1); // 11.17 - if(islist(Dt) & length(Dt)>0, // 12.19,12.22 - tmp=MeasureDepth(Dt); - if(tmp==1,Dt=[Dt]); - opcindy=Nj_3; - if(Nj_2<0,tmp1=0,tmp1=Nj_2); - if(tmp1<10, - forall(Dt,Nk, -// tmp2=apply(Nk,if(ispoint(#),Lcrd(#),#)); -// tmp2=apply(tmp2,Pcrd(#)); - tmp2=Nk; // 14.12.04 - if(length(Nk)>1, - forall(2..length(Nk), - tmp3=textformat(Nk_[#-1,#],5); - tmp3=substring(tmp3,1,length(tmp3)-1); - if(tmp1==1,opcindy=opcindy+",dashpattern->[2,2]"); - tmp="draw("+tmp3+ - ",dashtype->"+text(tmp1)+",linecolor->"+KCOLOR+opcindy+")"; - parse(tmp); - ); - , - if(length(Nk)==1, - tmp="draw("+text(tmp2_1)+opcindy+")"; // 14.12.31 - parse(tmp); - ); - ); - ); - ); - ); - ); -// if(ADDAXES=="1", // 16.10.08from -// draw([XMIN,0],[XMAX,0],color->[0,0.2,0]); -// draw([0,YMIIN],[0,YMAX],color->[0,0.2,0]); -// Letter([[XMAX,0],"e","x",[0,YMAX],"n","y"]); -// Letter([[0,0],"sw","O"]); -// ); // 16.10.08upto - grestore(); - layer(0); -); |