1. monoid
  2. starchartjs

Commits

monoid  committed 5bbf1f2

Google Closure Compiler port.

  • Participants
  • Parent commits 814095c
  • Branches gcc

Comments (0)

Files changed (4)

File build.sh

View file
+~/bin/google-compiler --js=../../starjs/dev/lib/StarJs{.js,/Math.js,/Vector.js,/Time.js,/Coord.js,/Kepler.js,/Solar.js} --js=starmap.js --js_output_file=starmap.min.js --compilation_level ADVANCED_OPTIMIZATIONS

File lib/starjs.min.js

-StarJs={};window.StarJs=StarJs;StarJs.b={};StarJs.Math=StarJs.b;StarJs.b.m=Math.PI/180;StarJs.b.DEG2RAD=Math.PI/180;StarJs.b.Aa=180/Math.PI;StarJs.b.RAD2DEG=180/Math.PI;StarJs.b.za=648E3/Math.PI;StarJs.b.RAD2ARCS=648E3/Math.PI;StarJs.b.t=Math.PI/648E3;StarJs.b.ARCS2RAD=Math.PI/648E3;StarJs.b.o=2*Math.PI;StarJs.b.PI2=2*Math.PI;StarJs.b.da=12/Math.PI;StarJs.b.ba=function(a){return a*a};StarJs.b.sqr=StarJs.b.ba;StarJs.b.r=function(a){return a-Math.floor(a)};StarJs.b.frac=StarJs.b.r;StarJs.b.I=function(a,b){return b*StarJs.b.r(a/b)};
-StarJs.b.mod=StarJs.b.I;StarJs.b.s=function(a,b,c,d){if(arguments.length===4){this.sign=a;this.degree=b;this.minute=c;this.second=d}else{var e=a;this.sign=1;if(e<0){e=-e;this.sign=-1}this.degree=Math.floor(e);e=60*(e-this.degree);this.minute=Math.floor(e);this.second=e=60*(e-this.minute)}};StarJs.b.Dms=StarJs.b.s;StarJs.b.H=function(a,b,c,d){return a*(b+c/60+d/3600)};StarJs.b.dms2deg=StarJs.b.H;StarJs.b.s.prototype.H=function(){return StarJs.b.H(this.sign,this.degree,this.minute,this.second)};
-StarJs.b.s.prototype.dms2deg=StarJs.b.s.prototype.H;StarJs.b.s.S=function(a){return new StarJs.b.s(a)};StarJs.b.s.deg2dms=StarJs.b.s.S;StarJs.b.ga=function(a){a=StarJs.b.I(a,StarJs.b.o);a=StarJs.b.S(StarJs.b.da*a);a.hour=a.deg;delete a.deg;delete a.sign;return a};StarJs.b.angle2hms=StarJs.b.ga;
-StarJs.b.aa=function(a,b,c){var d=0.5*(c+a)-b,e=0.5*(c-a);a=-e/(2*d);c=(d*a+e)*a+b;e=e*e-4*d*b;b=[];if(e>=0){e=0.5*Math.sqrt(e)/Math.abs(d);d=a-e;e=a+e;Math.abs(d)<=1&&b.push(d);Math.abs(e)<=1&&b.push(e)}return{xe:a,ye:c,roots:b}};StarJs.b.quadInterpolation=StarJs.b.aa;StarJs.b.Q=function(a){return(Math.exp(a)-Math.exp(-a))/2};StarJs.b.sinh=StarJs.b.Q;StarJs.b.L=function(a){return(Math.exp(a)+Math.exp(-a))/2};StarJs.b.cosh=StarJs.b.L;StarJs.c={};StarJs.Vector=StarJs.c;StarJs.c.l=function(a,b,c){this.x=a;this.y=b;this.z=c};StarJs.c.Vector3=StarJs.c.l;
-(function(a){a.qa=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};a.len=a.qa;a.add=function(b){return new StarJs.c.l(this.x+b.x,this.y+b.y,this.z+b.z)};a.add=a.add;a.sub=function(b){return new StarJs.c.l(this.x-b.x,this.y-b.y,this.z-b.z)};a.sub=a.sub;a.ta=function(){return new StarJs.c.l(-this.x,-this.y,-this.z)};a.neg=a.ta;a.scale=function(b){return new StarJs.c.l(b*this.x,b*this.y,b*this.z)};a.scale=a.scale;a.K=function(){return new StarJs.c.l(this.x,this.y,this.z)};a.clone=
-a.K})(StarJs.c.l.prototype);StarJs.c.p=function(a,b,c){var d=arguments.length;if(d===2)c=1;if(d===2||d===3){this.phi=a;this.theta=b;this.rad=c}else{d=a.x*a.x+a.y*a.y;this.rad=Math.sqrt(d+a.z*a.z);this.phi=a.x===0&&a.y===0?0:Math.atan2(a.y,a.x);if(this.phi<0)this.phi+=StarJs.b.o;d=Math.sqrt(d);this.theta=a.z===0&&d===0?0:Math.atan2(a.z,d)}};StarJs.c.Polar3=StarJs.c.p;
-(function(a){a.G=function(){var b=Math.cos(this.theta),c=this.rad;return new StarJs.c.l(c*b*Math.cos(this.phi),c*b*Math.sin(this.phi),c*Math.sin(this.theta))};a.toVector3=a.G;a.K=function(){return new StarJs.c.p(this.rad,this.phi,this.theta)};a.clone=a.K})(StarJs.c.p.prototype);StarJs.c.j=function(a,b,c){this.mat=arguments.length===3?[[a.x,a.y,a.z],[b.x,b.y,b.z],[c.x,c.y,c.z]]:b?a:[[a[0][0],a[0][1],a[0][2]],[a[1][0],a[1][1],a[1][2]],[a[2][0],a[2][1],a[2][2]]]};StarJs.c.Matrix3=StarJs.c.j;
-(function(a){a.apply=function(b){var c=this.mat[0],d=c[0]*b.x+c[1]*b.y+c[2]*b.z;c=this.mat[1];var e=c[0]*b.x+c[1]*b.y+c[2]*b.z;c=this.mat[2];return new StarJs.c.l(d,e,c[0]*b.x+c[1]*b.y+c[2]*b.z)};a.apply=a.apply;a.v=function(b){var c=[[0,0,0],[0,0,0],[0,0,0]];b=b.mat;for(var d=0;d<3;d+=1)for(var e=this.mat[d],f=c[d],h=0;h<3;h+=1)for(var j=0;j<3;j+=1)f[h]+=e[j]*b[j][h];return new StarJs.c.j(c,true)};a.mult=a.v})(StarJs.c.j.prototype);
-StarJs.c.j.A=function(a){var b=Math.cos(a);a=Math.sin(a);return new StarJs.c.j([[1,0,0],[0,b,a],[0,-a,b]])};StarJs.c.j.r_x=StarJs.c.j.A;StarJs.c.j.F=function(a){var b=Math.cos(a);a=Math.sin(a);return new StarJs.c.j([[b,0,-a],[0,1,0],[a,0,b]])};StarJs.c.j.r_y=StarJs.c.j.F;StarJs.c.j.B=function(a){var b=Math.cos(a);a=Math.sin(a);return new StarJs.c.j([[b,a,0],[-a,b,0],[0,0,1]])};StarJs.c.j.r_y=StarJs.c.j.F;StarJs.g={};StarJs.Time=StarJs.g;StarJs.g.DEFAULT_JULIAN_DATE={year:1582,month:10,day:4};StarJs.g.DEFAULT_JULIAN_JD=2299161;StarJs.g.JD_MJD=2400000.5;StarJs.g.xa=function(a){if(typeof a!=="number")a=a.getTime();return a/864E5+40587};StarJs.g.time2mjd=StarJs.g.xa;
-StarJs.g.sa=function(a,b){if(typeof b==="undefined")b=StarJs.g.DEFAULT_JULIAN_JD;var c=Math.floor(a)+2400001,d,e;if(c<b)b=c+1524;else{b=Math.floor((c-1867216.25)/36524.25);b=c+b-Math.floor(b/4)+1525}c=Math.floor((b-122.1)/365.25);d=365*c+Math.floor(c/4);e=Math.floor((b-d)/30.6001);b=b-d-Math.floor(30.6001*e);e=e-1-12*Math.floor(e/14);c=c-4715-Math.floor((7+e)/10);a=StarJs.g.X(24*(a-Math.floor(a)));a.year=c;a.month=e;a.day=b;return a};StarJs.g.mjd2dt=StarJs.g.sa;
-StarJs.g.W=function(a,b,c){return a+b/60+c/3600};StarJs.g.hms2hour=StarJs.g.W;StarJs.g.X=function(a){a=new StarJs.b.s(a);return{hour:a.degree,minute:a.minute,second:a.second}};StarJs.g.hour2hms=StarJs.g.X;
-StarJs.g.ka=function(a,b){if(typeof b==="undefined")b=StarJs.g.DEFAULT_JULIAN_DATE;var c=a.year,d=a.month;if(d<=2){d+=12;c-=1}return 365*c-679004+(c<=b.year&&d<=b.month&&a.day<=b.day?-2+Math.floor((c+4716)/4)-1179:Math.floor(c/400)-Math.floor(c/100)+Math.floor(c/4))+Math.floor(30.6001*(d+1))+a.day+StarJs.g.W(a.hour,a.minute,a.second)/24};StarJs.g.dt2mjd=StarJs.g.ka;StarJs.g.P=function(a){return(a-51544.5)/36525};StarJs.g.mjd2jct=StarJs.g.P;
-StarJs.g.V=function(a){var b=Math.floor(a),c=86400*(a-b);b=StarJs.g.P(b);a=StarJs.g.P(a);return StarJs.b.o/86400*StarJs.b.I(24110.54841+8640184.812866*b+1.0027379093*c+(0.093104-6.2E-6*a)*a*a,86400)};StarJs.g.gmst=StarJs.g.V;StarJs.k={};StarJs.Coord=StarJs.k;StarJs.k.ua=function(a,b){b=b-a;var c,d;c=174.876383889*StarJs.b.m+((3289.4789+0.60622*a)*a+(-869.8089-0.50491*a+0.03536*b)*b)*StarJs.b.t;d=(47.0029-(0.06603-5.98E-4*a)*a+(-0.03302+0.00598*a+6.0E-5*b)*b)*b*StarJs.b.t;return StarJs.c.j.B(-(c+(5029.0966+(2.22226-4.2E-5*a)*a+(1.11113-4.2E-5*a-6.0E-6*b)*b)*b*StarJs.b.t)).v(StarJs.c.j.A(d)).v(StarJs.c.j.B(c))};StarJs.k.precessionEclMatrix=StarJs.k.ua;
-StarJs.k.va=function(a,b){var c=b-a,d;b=(2306.2181+(1.39656-1.39E-4*a)*a+(0.30188-3.44E-4*a+0.017998*c)*c)*c*StarJs.b.t;d=b+(0.7928+4.11E-4*a+2.05E-4*c)*c*c*StarJs.b.t;a=(2004.3109-(0.8533+0.00217*a)*a-(0.42665+2.17E-4*a+0.041833*c)*c)*c*StarJs.b.t;return StarJs.c.j.B(-d).v(StarJs.c.j.F(a)).v(StarJs.c.j.B(-b))};StarJs.k.precessionEquMatrix=StarJs.k.va;StarJs.k.M=function(a){return(23.43929111-(46.815+(5.9E-4-0.001813*a)*a)*a/3600)*StarJs.b.m};StarJs.k.eclipticObliquity=StarJs.k.M;StarJs.k.ma=function(a){return StarJs.c.j.A(StarJs.k.M(a))};
-StarJs.k.equ2eclMatrix=StarJs.k.ma;StarJs.k.la=function(a){return StarJs.c.j.A(-StarJs.k.M(a))};StarJs.k.ecl2equMatrix=StarJs.k.la;StarJs.k.na=function(a,b,c){a=StarJs.c.j.F(Math.PI/2-c).apply((new StarJs.c.p(b,a)).G());a=new StarJs.c.p(a);return{h:a.theta,az:a.phi}};StarJs.k.equ2hor=StarJs.k.na;StarJs.k.oa=function(a,b,c){a=StarJs.c.j.F(-Math.PI/2+c).apply((new StarJs.c.p(b,c)).G());a=new StarJs.c.p(a);return{dec:a.theta,tau:a.phi}};StarJs.k.hor2equ=StarJs.k.oa;StarJs.f={};StarJs.Kepler=StarJs.f;StarJs.f.DEFAULT_ITERATIONS=100;StarJs.f.DEFAULT_PRECISION=1.0E-9;StarJs.f.T=function(a,b,c){var d,e=StarJs.f.DEFAULT_PRECISION;if(c===undefined)c=StarJs.f.DEFAULT_ITERATIONS;a=StarJs.b.I(a,StarJs.b.o);d=Math.sin(a);var f=a+b*d/(1-Math.sin(a+b)+d);do{d=f-b*Math.sin(f)-a;f-=d/(1-b*Math.cos(f))}while(c-- >0&&d>e);return c>0?f:null};StarJs.f.eccAnomaly=StarJs.f.T;
-StarJs.f.N=function(a,b,c,d){b=StarJs.f.T(b,d);a=Math.cos(b);b=Math.sin(b);return new StarJs.c.l(c*(a-d),c*Math.sqrt((1-d)*(1+d))*b,0)};StarJs.f.elliptic=StarJs.f.N;
-StarJs.f.$=function(a,b,c,d,e,f){function h(u,o){var t=StarJs.f.ya,q,m,i,g,r;i=g=r=0;m=q=1;do{i+=m;m/=2*q;g+=m;m/=2*q+1;r+=m;m*=-u;q+=1}while(Math.abs(m)>=t);o.ha=i;o.ia=g;o.ja=r}if(f===undefined)f=StarJs.f.DEFAULT_ITERATIONS;var j=0,k={},l,n=StarJs.f.DEFAULT_PRECISION;f=0.5*e;b=Math.sqrt(a)*(c-b);do{a=j;j=1.5*Math.sqrt(f/(d*d*d))*b;j=Math.pow(Math.sqrt(j*j+1)+j,1/3);c=j-1/j;l=c*c;j=l*(1-e)/f;h(j,k);f=3*e*k.ja}while(Math.abs(j-a)>=n);return new StarJs.c.l(d*(1-l*k.ia/f),d*Math.sqrt((1+e)/f)*c*k.ha,
-0)};StarJs.f.parabolic=StarJs.f.$;StarJs.f.Y=function(a,b,c){if(c===undefined)c=StarJs.f.DEFAULT_ITERATIONS;var d=StarJs.f.DEFAULT_PRECISION,e=0,f,h;f=Math.log(2*Math.abs(a)/b+1.8);if(a<0)f=-f;do{h=b*StarJs.b.Q(f)-f-a;f-=h/(b*StarJs.b.L(f)-1);++e;if(e===c)return null}while(Math.abs(h)>d*(1+Math.abs(f+a)));return f};StarJs.f.hypAnom=StarJs.f.Y;
-StarJs.f.Z=function(a,b,c,d,e){d=Math.abs(d);b=StarJs.f.Y(Math.sqrt(a/d)*(c-b)/d,e);a=StarJs.b.L(b);b=StarJs.b.Q(b);return new StarJs.c.l(d*(e-a),d*Math.sqrt((e+1)*(e-1))*b,0)};StarJs.f.hyperbolic=StarJs.f.Z;StarJs.f.pa=function(a,b,c,d,e,f){var h,j,k;j=Math.abs(1-e);k=j/d;h=Math.sqrt(a)*(c-b)*Math.sqrt(k*k*k);a=h<0.1&&j<e?StarJs.f.$(a,b,c,d,e):e<1?StarJs.f.N(a,h,1/k,e):StarJs.f.Z(a,b,c,1/k,e);return f.apply(a)};StarJs.f.keplerPos=StarJs.f.pa;StarJs.f.U=function(a,b,c){return StarJs.c.j.B(-a).v(StarJs.c.j.A(-b)).v(StarJs.c.j.B(-c))};
-StarJs.f.gaussVec=StarJs.f.U;StarJs.d={};StarJs.Solar=StarJs.d;StarJs.d.J=23.43920111*StarJs.b.m;StarJs.d.EPS=StarJs.d.J;
-StarJs.d.D=function(a){var b,c,d,e,f,h;b=StarJs.b.r(0.606433+1336.855225*a);c=StarJs.b.o*StarJs.b.r(0.374897+1325.55241*a);d=StarJs.b.o*StarJs.b.r(0.993133+99.997361*a);f=StarJs.b.o*StarJs.b.r(0.827361+1236.853086*a);e=StarJs.b.o*StarJs.b.r(0.259086+1342.227825*a);h=+22640*Math.sin(c)-4586*Math.sin(c-2*f)+2370*Math.sin(2*f)+769*Math.sin(2*c)-668*Math.sin(d)-412*Math.sin(2*e)+-212*Math.sin(2*c-2*f)-206*Math.sin(c+d-2*f)+192*Math.sin(c+2*f)-165*Math.sin(d-2*f)+-125*Math.sin(f)-110*Math.sin(c+d)+148*
-Math.sin(c-d)+-55*Math.sin(2*e-2*f);a=e+(h+412*Math.sin(2*e)+541*Math.sin(d))*StarJs.b.t;f=e-2*f;c=-526*Math.sin(f)+44*Math.sin(c+f)-31*Math.sin(f-c)+-23*Math.sin(d+f)+11*Math.sin(f-d)-25*Math.sin(e-2*c)+21*Math.sin(e-c);b=StarJs.b.o*StarJs.b.r(b+h/1296E3);a=(18520*Math.sin(a)+c)*StarJs.b.t;b=StarJs.c.j.A(-StarJs.d.J).apply((new StarJs.c.p(b,a)).G());b=new StarJs.c.p(b);return{ra:b.phi,dec:b.theta}};StarJs.d.approxMoon=StarJs.d.D;
-StarJs.d.u=function(a){var b,c;c=StarJs.b.r(0.993133+99.997361*a);b=StarJs.b.o*c;a=StarJs.b.o*StarJs.b.r(0.7859453+c+(6893*Math.sin(b)+72*Math.sin(2*b)+6191.2*a)/1296E3);a=StarJs.c.j.A(-StarJs.d.J).apply((new StarJs.c.p(a,0)).G());a=new StarJs.c.p(a);return{ra:a.phi,dec:a.theta}};StarJs.d.approxSun=StarJs.d.u;
-StarJs.d.fa=[{body:"moon",name:"day",title:"Moon",sinh0:Math.sin(+8/60*StarJs.b.m),posFunc:StarJs.d.D},{body:"sun",name:"day",title:"Sun",sinh0:Math.sin(-50/60*StarJs.b.m),posFunc:StarJs.d.u},{body:"sun",name:"twilightC",title:"Civil twilight",sinh0:Math.sin(-6*StarJs.b.m),posFunc:StarJs.d.u},{body:"sun",name:"twilightN",title:"Nautical twilight",sinh0:Math.sin(-12*StarJs.b.m),posFunc:StarJs.d.u},{body:"sun",name:"twilightA",title:"Astronomical twilight",sinh0:Math.sin(-18*StarJs.b.m),posFunc:StarJs.d.u}];
-StarJs.d.wa=function(a,b,c,d,e){function f(s,v,y,z,A){s=s((v-51544.5)/36525);v=StarJs.g.V(v)+y-s.ra;return A*Math.sin(s.dec)+z*Math.cos(s.dec)*Math.cos(v)}var h=StarJs.d.fa,j=[],k,l,n,u=1/24,o={},t={},q={},m=Math.cos(d);d=Math.sin(d);var i,g,r={sun:{},moon:{}},x={sun:{},moon:{}},w={sun:{},moon:{}},p={};if(typeof e==="undefined")e=function(s){return s};n=a;o.moon=f(StarJs.d.D,n,c,m,d);o.sun=f(StarJs.d.u,n,c,m,d);for(l=0;l<h.length;l+=1){g=h[l];i=g.name;r[g.body][i]=o[g.body]-g.sinh0}for(;n<b;){e={moon:{midnight:o.moon},
-sun:{midnight:o.sun}};for(k=1;k<24;k+=2){l=n+u;n=l+u;t.moon=f(StarJs.d.D,l,c,m,d);t.sun=f(StarJs.d.u,l,c,m,d);q.moon=f(StarJs.d.D,n,c,m,d);q.sun=f(StarJs.d.u,n,c,m,d);for(l=0;l<h.length;l+=1){g=h[l];i=g.name;e[g.body][i]=e[g.body][i]||{};x[g.body][i]=t[g.body]-g.sinh0;w[g.body][i]=q[g.body]-g.sinh0;p=StarJs.b.aa(r[g.body][i],x[g.body][i],w[g.body][i]);switch(p.roots.length){case 0:break;case 1:if(r[g.body][i]<0)e[g.body][i].rise=k+p.roots[0];else e[g.body][i].set=k+p.roots[0];break;case 2:if(p.ye<
-0){e[g.body][i].rise=k+p.roots[1];e[g.body][i].set=k+p.roots[0]}else{e[g.body][i].rise=k+p.roots[0];e[g.body][i].set=k+p.roots[1]}break}}r=w;w={moon:{},sun:{}};n=n}for(l=0;l<h.length;l+=1){g=h[l];i=g.name;if(!e[g.body][i].set&&!e[g.body][i].rise)e[g.body][i].alwaysAbove=t[g.body]>g.sinh0}n=a+=1;j.push(e)}return j};StarJs.d.sunAndMoonEvents=StarJs.d.wa;StarJs.d.C=function(){this.name="Sun"};StarJs.d.Sun=StarJs.d.C;StarJs.d.C.ca=new StarJs.c.l(0,0,0);StarJs.d.R=StarJs.b.ba(0.01720209895);
-StarJs.d.GM=StarJs.d.R;StarJs.d.C.prototype.keplerCoord=function(){return StarJs.d.C.ca};StarJs.d.q=function(a,b){this.name=a;this.a=b.a;this.ec=b.e;this.m0=b.M0;this.n=b.n;this.omega=b.O;this.i=b.i;this.w=b.w;this.t0=b.T0};StarJs.d.Body=StarJs.d.q;StarJs.d.q.prototype.keplerCoord=function(a){var b=StarJs.f.N(StarJs.d.R,StarJs.b.m*(this.m0+this.n*(a-this.t0)),this.a,this.ec);return StarJs.f.U(StarJs.b.m*(this.omega+1.397*a),StarJs.b.m*this.i,StarJs.b.m*(this.w-this.omega)).apply(b)};
-StarJs.d.ea={Sun:new StarJs.d.C,Mercury:new StarJs.d.q("Mercury",{a:0.387099,e:0.205634,M0:174.7947,n:149472.6738,O:48.331,i:7.0048,w:77.4552,T0:0}),Venus:new StarJs.d.q("Venus",{a:0.723332,e:0.006773,M0:50.4071,n:58517.8149,O:76.68,i:3.3946,w:131.5718,T0:0}),Earth:new StarJs.d.q("Earth",{a:1,e:0.016709,M0:357.5256,n:35999.372,O:174.876,i:0,w:102.94,T0:0}),Mars:new StarJs.d.q("Mars",{a:1.523692,e:0.093405,M0:19.3879,n:19140.3023,O:49.557,i:1.8496,w:336.059,T0:0}),Jupiter:new StarJs.d.q("Jupiter",
-{a:5.204267,e:0.048775,M0:18.8185,n:3033.6272,O:100.4908,i:1.3046,w:15.5576,T0:0}),Saturn:new StarJs.d.q("Saturn",{a:9.582018,e:0.055723,M0:320.3477,n:1213.8664,O:113.6427,i:2.4852,w:89.6567,T0:0}),Uranus:new StarJs.d.q("Uranus",{a:19.229412,e:0.044406,M0:142.9559,n:426.9282,O:73.9893,i:0.7726,w:170.531,T0:0}),Neptune:new StarJs.d.q("Neptune",{a:30.103658,e:0.011214,M0:267.7649,n:217.9599,O:131.7942,i:1.768,w:37.4435,T0:0})};StarJs.d.BODIES=StarJs.d.ea;

File starmap.js

View file
     var sl1 = Math.sin(dlam);
     if (Math.abs(sl1) < 1e-10 || Math.abs(cp1) < 1e-10) {
         return {
-            'type': 'line',
-            'x': 0,
-            'y': 0,
-            'vx': Math.cos(dlam),
-            'vy': sl1
+            type: 'line',
+            x: 0,
+            y: 0,
+            vx: Math.cos(dlam),
+            vy: sl1
         };
     } else {
         var x = -R/(cp1*Math.tan(dlam));
         var y = R*Math.tan(phi1);
         var rho = R/(cp1*sl1);
         return {
-            'type': 'circle',
-            'x': x,
-            'y': y,
-            'flip': rho < 0,
-	    'r': Math.abs(rho)
+            type: 'circle',
+            x: x,
+            y: y,
+            flip: rho < 0,
+	    r: Math.abs(rho)
         };
     }
 };
     // TODO: line if s == 0
     if (Math.abs(s) < 1e-10) {
         return {
-            'type': 'line',
-            'x': 0,
-            'y': 0,
-            'vx': 1,
-            'vy': 0
+            type: 'line',
+            x: 0,
+            y: 0,
+            vx: 1,
+            vy: 0
         };
     } else {
 	var rho = R*Math.cos(phi)/s;
         return {
-            'type': 'circle',
-            'x': 0,
-            'y': -R*this.cph1/s,
-            'flip': rho < 0,
-            'r': Math.abs(rho)
+            type: 'circle',
+            x: 0,
+            y: -R*this.cph1/s,
+            flip: rho < 0,
+            r: Math.abs(rho)
         };
     }
 };
     var a1 = Math.atan2(im1 - c2, re1 - c1);
     var a2 = Math.atan2(im2 - c2, re2 - c1);
     return {
-        'type': 'circle',
-        'x': c1*this.rad, 'y': c2*this.rad,
-        'a1': a1, 'a2': a2,
-        'p1': p1, 'p2': p2,
-        'flip': d < 0,
-        'r': r*this.rad
+        type: 'circle',
+        x: c1*this.rad, y: c2*this.rad,
+        a1: a1, a2: a2,
+        p1: p1, p2: p2,
+        flip: d < 0,
+        r: r*this.rad
     };
 };
 
     var cy = p[1]*(1+r*r)/denom;
 
     return {
-        'type': 'circle',
-        'x': cx, 'y': cy,
-        'flip': denom < 0,
-        'rad': this.rad*Math.abs(rho)
+        type: 'circle',
+        x: cx, y: cy,
+        flip: denom < 0,
+        rad: this.rad*Math.abs(rho)
     };
 };
 
         };
     }
 };
+StereographicProjection.prototype['inverseObj'] = StereographicProjection.prototype.inverseObj;
 
 /**
  * Rendering scene: objects are cached for rotation and zooming.  When
     this.size = size;
     var halfsize = Math.floor(size/2);
 
-    this.planets = (typeof prop.planets === 'undefined') ? true : prop.planets;
+    this.planets = (typeof prop['planets'] === 'undefined') ? true : prop['planets'];
 
     this.orient = 0;
 
     this.stars = stars;
     this.cnstltns = cnstltns;
 
-    this.proj = new StereographicProjection(0, 0, halfsize);
+    this['proj'] = new StereographicProjection(0, 0, halfsize);
 
     //this.drawBg();
 }
 
 StarMap.prototype.setSize = function (size) {
-    this.proj.setRadius(Math.floor(size/2));
+    this['proj'].setRadius(Math.floor(size/2));
     this.size = size;
 };
+StarMap.prototype['setSize'] = StarMap.prototype.setSize;
 
 StarMap.prototype.drawBg = function () {
     var size = this.size;
     ctx.fillRect(-halfsize,-halfsize,size, size);
 
     ctx.beginPath();
-    ctx.fillStyle = (this.prop.circleFill || "#000010");
+    ctx.fillStyle = (this.prop['circleFill'] || "#000010");
     ctx.arc(0, 0, halfsize, 0, 2*Math.PI, true);
     ctx.fill();
     
     this.orient = orient;
 };
 
+/** A planet object.
+ * @constructor
+ */
 StarMap.Planet = function (pl, size, color) {
     this.pl = pl;
     this.size = size;
 }
 
 StarMap.Planet.prototype.getCoord = function (jct, earthPos, equ2ecl) {
-    var pos = this.pl.keplerCoord(jct);
+    var pos = this.pl['keplerCoord'](jct);
     return new StarJs.Vector.Polar3(equ2ecl.apply(pos.sub(earthPos)));
 };
 
+/** A Moon object.
+ * @constructor
+ */
 StarMap.Moon = function (size, color) {
     this.size = size;
     this.color = color;
 };
 
 StarMap.PLANETS = [
-    new StarMap.Planet(StarJs.Solar.BODIES.Sun, 20, '#FF0'),
+    new StarMap.Planet(StarJs.Solar.BODIES['Sun'], 20, '#FF0'),
     new StarMap.Moon(20, '#880'),
-    new StarMap.Planet(StarJs.Solar.BODIES.Mercury, 3, '#888'),
-    new StarMap.Planet(StarJs.Solar.BODIES.Venus, 4, '#AAA'),
-    new StarMap.Planet(StarJs.Solar.BODIES.Mars, 4, '#F80'),
-    new StarMap.Planet(StarJs.Solar.BODIES.Jupiter, 6, '#FB0'),
-    new StarMap.Planet(StarJs.Solar.BODIES.Saturn, 6, '#AA0'),
-    new StarMap.Planet(StarJs.Solar.BODIES.Uranus, 6, '#CAF'),
-    new StarMap.Planet(StarJs.Solar.BODIES.Neptune, 6, '#CAF')
+    new StarMap.Planet(StarJs.Solar.BODIES['Mercury'], 3, '#888'),
+    new StarMap.Planet(StarJs.Solar.BODIES['Venus'], 4, '#AAA'),
+    new StarMap.Planet(StarJs.Solar.BODIES['Mars'], 4, '#F80'),
+    new StarMap.Planet(StarJs.Solar.BODIES['Jupiter'], 6, '#FB0'),
+    new StarMap.Planet(StarJs.Solar.BODIES['Saturn'], 6, '#AA0'),
+    new StarMap.Planet(StarJs.Solar.BODIES['Uranus'], 6, '#CAF'),
+    new StarMap.Planet(StarJs.Solar.BODIES['Neptune'], 6, '#CAF')
 ];
 
-StarMap.EARTH = StarJs.Solar.BODIES.Earth;
+StarMap.EARTH = StarJs.Solar.BODIES['Earth'];
 
+/** Celestial path (of a comet, asteroid, satellite etc.).
+ * @constructor
+ */
 StarMap.Path = function (labels, ras, des, style, labelStyle) {
     this.labels = labels;
     this.ras = ras;
 
 };
 
+/** Telrad pattern.
+ * @constructor
+ */
 StarMap.Telrad = function (lat, lon) {
     this.lat = lat;
     this.lon = lon;
     drawBullEye(g40);
 };
 
+/** Constellation boundaries.
+ * @constructor
+ */
 StarMap.ConstellationBoundaries = function (boundaries, epoch) {
     var DEG2RAD = StarJs.Math.DEG2RAD;
 
                                          DEG2RAD*pt[1]).toVector3();
         var p = new StarJs.Vector.Polar3(prec.apply(v));
         pt[0] *= 15;
-        pt.push(p.phi/DEG2RAD)
-        pt.push(p.theta/DEG2RAD);
+        pt.push(p['phi']/DEG2RAD)
+        pt.push(p['theta']/DEG2RAD);
         result[i] = pt;
     }
 
             a2 = DEG2RAD*l[0];
 	    seg = proj.projectSegment(
                 // Center
-                polarPrec.theta, polarPrec.phi,
+                polarPrec['theta'], polarPrec['phi'],
                 // Radius
                 Math.PI/2-DEG2RAD*l[1],
                 // Point 1
     }
 };
 
+/** An object catalogue (Messier, Caldwell, NGC, etc).
+ * @constructor
+ */
 StarMap.Catalogue = function (name, data, colors, renderer) {
     function messierColor(mag) {
         var v = Math.min(15, Math.floor(19-mag));
     }
 };
 
+/** A graticule.
+ * @constructor
+ */
 StarMap.Graticule = function (lon) {
     this.lon = lon;
 };
     ctx.lineWidth = 1;
 };
 
+/** Ecliptics circle.
+ * @constructor
+ */
 StarMap.Ecliptics = function () {
 };
 
     }
 };
 
+/** Any object.
+ * @constructor
+ */
 StarMap.Object = function (params, color, mjd, jct) {
     this.params = params;
     this.color = color;
                                       this.params.q,
                                       this.params.e,
                                       this.pqr);
-    var earthPos = StarMap.EARTH.keplerCoord(this.jct);
+    var earthPos = StarMap.EARTH['keplerCoord'](this.jct);
     var ecl2equ = StarJs.Coord.ecl2equMatrix(this.jct);
     pos = new StarJs.Vector.Polar3(ecl2equ.apply(pos.sub(earthPos)));
-    var cm = proj.projectObj(pos.theta, pos.phi);
+    var cm = proj.projectObj(pos['theta'], pos['phi']);
 
     ctx.strokeStyle = ctx.fillStyle = this.color;
     ctx.lineWidth = 2;
 
     lat += gms_t;
 
-    this.proj.setCoords(lon, lat);
+    this['proj'].setCoords(lon, lat);
 
-    var ortho = this.proj.projectPoints(this.stars);
+    var ortho = this['proj'].projectPoints(this.stars);
     var cst = [], i, j, slen = ortho.length, co = this.cnstltns, clen = co.length, halfsize = Math.floor(this.size/2);
     
     var ctx = this.ctx;
     this.drawBg();
 
     // Draw graticule
-    (new StarMap.Graticule(lon)).draw(ctx, this.proj);
+    (new StarMap.Graticule(lon)).draw(ctx, this['proj']);
 
 
     // Boundaries
-    (new StarMap.ConstellationBoundaries(CON_BOUND_18)).draw(ctx, this.proj);
+    (new StarMap.ConstellationBoundaries(CON_BOUND_18)).draw(ctx, this['proj']);
 
     // Constellations
     ctx.beginPath();
     ctx.stroke();
 
     // Draw ecliptics
-    (new StarMap.Ecliptics()).draw(ctx, this.proj);
+    (new StarMap.Ecliptics()).draw(ctx, this['proj']);
 
     // Stars
     ctx.fillStyle = '#FFF';
     }
 
     // Draw Messier objects
-    if (this.prop && this.prop.messier) {
-        (new StarMap.Catalogue("Messier", this.prop.messier, this.prop.messier_colors)).draw(ctx, this.proj);
+    if (this.prop && this.prop['messier']) {
+        (new StarMap.Catalogue("Messier", this.prop['messier'], this.prop['messier_colors'])).draw(ctx, this['proj']);
     }
     // Draw Caldwell objects
-    if (this.prop && this.prop.caldwell) {
-        (new StarMap.Catalogue("Caldwell", this.prop.caldwell, this.prop.caldwell_colors)).draw(ctx, this.proj);
+    if (this.prop && this.prop['caldwell']) {
+        (new StarMap.Catalogue("Caldwell", this.prop['caldwell'], this.prop['caldwell_colors'])).draw(ctx, this['proj']);
     }
 
     // Draw planets
     var jct = Ti.mjd2jct(mjd);
     if (this.planets) {
-        var earthPos = StarMap.EARTH.keplerCoord(jct);
+        var earthPos = StarMap.EARTH['keplerCoord'](jct);
         var equ2ecl = StarJs.Coord.ecl2equMatrix(jct);
         for (i = 0; i < StarMap.PLANETS.length; ++i) {
             var planet = StarMap.PLANETS[i];
             cc = planet.getCoord(jct, earthPos, equ2ecl);
             
-            cm = this.proj.projectObj(cc.theta, cc.phi);
+            cm = this['proj'].projectObj(cc['theta'], cc['phi']);
             if (cm[2]) {
                 ctx.beginPath();
                 ctx.fillStyle = planet.color;
     }
 
     // Draw sample telrads
-    (new StarMap.Telrad(0.901, 0.451)).draw(ctx, this.proj);
-    (new StarMap.Telrad(0.301, 2.151)).draw(ctx, this.proj);
+    (new StarMap.Telrad(0.901, 0.451)).draw(ctx, this['proj']);
+    (new StarMap.Telrad(0.301, 2.151)).draw(ctx, this['proj']);
 
     // Draw path of C/2009 R1 (McNaught)
     var C2009R1_DA = ["2010 05 04", "2010 05 09", "2010 05 14",
         'fillStyle': '#8F8',
         'strokeStyle': '#8F8'
     });
-    C2009R1.draw(ctx, this.proj);
+    C2009R1.draw(ctx, this['proj']);
     
     // Draw current position of the comet
     var C2009R1_param = {
         incl: 77.0319*DEG2RAD
     };
 
-    (new StarMap.Object(C2009R1_param, 'rgba(220, 255, 220, 0.7)', mjd, jct)).draw(ctx, this.proj);
+    (new StarMap.Object(C2009R1_param, 'rgba(220, 255, 220, 0.7)', mjd, jct)).draw(ctx, this['proj']);
 
 
     var lutetia = {
         incl: 3.063753824680438*DEG2RAD
     };
 
-    (new StarMap.Object(lutetia, 'rgba(255, 255, 255, 0.7)', mjd, jct)).draw(ctx, this.proj);
+    (new StarMap.Object(lutetia, 'rgba(255, 255, 255, 0.7)', mjd, jct)).draw(ctx, this['proj']);
 
     
     // Draw sides of Earth
 
 window['StarMap']=StarMap;
 StarMap.prototype['setPos'] = StarMap.prototype.setPos;
+StarMap.prototype['draw'] = StarMap.prototype.draw;

File test800.html

View file
       <canvas id="test-map800" width="800" height="800"></canvas>
     </div>
     <div id="coord">&nbsp;</div>
-    <script type="text/javascript" src="lib/starjs.min.js"></script>
     <script type="text/javascript" src="constellations-rey60.js"></script>
     <script type="text/javascript" src="messier.js"></script>
     <script type="text/javascript" src="caldwell.js"></script>
     <script type="text/javascript" src="boundaries-18.js"></script>
-    <script type="text/javascript" src="starmap.js"></script>
+    <script type="text/javascript" src="starmap.min.js"></script>
     <script type="text/javascript">
+      var RAD = 800;
       var map;
       function onload() {
-      map = new StarMap("test-map800", 800, REY_STARS60, REY_CONSTELLATIONS60, {messier: MESSIER, messier_colors: MESSIER_COLORS,caldwell: CALDWELL, caldwell_colors: MESSIER_COLORS});
+      map = new StarMap("test-map800", RAD, REY_STARS60, REY_CONSTELLATIONS60, {messier: MESSIER, messier_colors: MESSIER_COLORS,caldwell: CALDWELL, caldwell_colors: MESSIER_COLORS});
       map.setPos(83, 54);
-      map.setSize(800, 800);
+      map.setSize(RAD, RAD);
       map.draw();
       var el = document.getElementById("test-map800");
       var out = document.getElementById("coord");
       el.onmousemove = function (ev) {
         //console.debug(ev);
         if (!ev) var ev = window.event;
-        var h = map.proj.rad;
+        var h = RAD;
         var x = ev.pageX - h - /* HACK */ 8;
         var y = h - ev.pageY + /* HACK */ 8;
         //var y = ev.pageY - h - 8;