From 96c75058a3a525a2ccf30fb7af0d738a48d43d85 Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Fri, 29 Jan 2021 13:25:34 +0100 Subject: [PATCH 1/8] speed improvements --- apps/planetarium/README.md | 10 ++++- apps/planetarium/planetarium.app.js | 67 ++++++++++++++--------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/apps/planetarium/README.md b/apps/planetarium/README.md index ff2178888..206fa5b50 100644 --- a/apps/planetarium/README.md +++ b/apps/planetarium/README.md @@ -8,4 +8,12 @@ Plan is to show also constellations, but this is work in progress. Now it shows I think code is quite optimized already. It runs as fast as I could make it run. If someone has some ideas to speed it up, I could plot more stars. -Basic equations to compute declination and right ascension for stars where taken from this [github repo](https://github.com/Michi83/planetarium). \ No newline at end of file +Basic equations to compute declination and right ascension for stars where taken from this [github repo](https://github.com/Michi83/planetarium). Thanks! + +## How to use +The planetarium plots the stars as if you are looking to the sky (with your watch screen pointing downwards). This means, if you have the watch in your wrist, you have to look south to see the stars matching. If you want to look north, just take out the watch from your wrist and make a 180ยบ turn. + +## Improvements +I plan to add more constellations as soon as I have time. I am adding the constellations that I know of, but the plan is to add all the main ones (at least for North Hemisphere). + +Please note that the watch hardware is limited and computing the stars positions is a quite intensive task for this little processor. This is why it plots only stars and no planets or the moon. For plotting the planets, storage will be a limiting factor as well as computing the position for planets needs more initial data compared with stars. \ No newline at end of file diff --git a/apps/planetarium/planetarium.app.js b/apps/planetarium/planetarium.app.js index bd36bf4b7..e860345a8 100644 --- a/apps/planetarium/planetarium.app.js +++ b/apps/planetarium/planetarium.app.js @@ -46,7 +46,6 @@ function drawStars(lat,lon,date){ storage = require('Storage'); f=storage.read("planetarium.data.csv","r"); - linestart=0; g.clear(); //Common calculations based only on time @@ -59,42 +58,42 @@ function drawStars(lat,lon,date){ let starNumber = 0; var starPositions = {}; - for (i=0;i= 0) - { - //Compute azimuth - var azi = Math.atan2(Math.sin(H), Math.cos(H) * Math.sin(latitude) - Math.tan(dec) * Math.cos(latitude)); - var x = size / 2 + size / 2 * Math.cos(alt) * Math.sin(azi); - var y = size / 2 + size / 2 * Math.cos(alt) * Math.cos(azi); - starPositions[starNumber] = [x,y]; - var magnitude = starMag<1.5?2:1; - g.fillCircle(x, y, magnitude); - if (starMag<1 && settings.starnames) - g.drawString(starInfo[3],x,y+2); - g.flip(); + var line,linestart = 0; + lineend = f.indexOf("\n"); + while (lineend>=0) { + line = f.substring(linestart,lineend); + starNumber++; + //console.log(line); + //Process the star + starInfo = line.split(','); + //console.log(starInfo[0]); + starRA = parseFloat(starInfo[0]); + starDE = parseFloat(starInfo[1]); + starMag = parseFloat(starInfo[2]); + //var start = new Date().getTime(); + var dec = Math.asin(Math.sin(theta) * Math.cos(starDE) * Math.cos(starRA + zeta) + Math.cos(theta) * Math.sin(starDE)); + var ascen = Math.atan2(Math.cos(starDE) * Math.sin(starRA + zeta), Math.cos(theta) * Math.cos(starDE) * Math.cos(starRA + zeta) - Math.sin(theta) * Math.sin(starDE)) + z; + var H = siderealTime(julianDay) - longitude - ascen; + //Compute altitude + var alt = Math.asin(Math.sin(latitude) * Math.sin(dec) + Math.cos(latitude) * Math.cos(dec) * Math.cos(H)); + if(alt >= 0) + { + //Compute azimuth + var azi = Math.atan2(Math.sin(H), Math.cos(H) * Math.sin(latitude) - Math.tan(dec) * Math.cos(latitude)); + var x = size / 2 + size / 2 * Math.cos(alt) * Math.sin(azi); + var y = size / 2 + size / 2 * Math.cos(alt) * Math.cos(azi); + starPositions[starNumber] = [x,y]; + var magnitude = starMag<1.5?2:1; + g.fillCircle(x, y, magnitude); + if (starMag<1 && settings.starnames) + g.drawString(starInfo[3],x,y+2); + g.flip(); - } } + linestart = lineend+1; + lineend = f.indexOf("\n",linestart); } + if (settings.constellations){ //Each star has a number (the position on the file (line number)). These are the lines From 189d2cde36b6fe2e7187fe21666b289b32f06f33 Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Fri, 29 Jan 2021 13:33:17 +0100 Subject: [PATCH 2/8] adding more stars --- apps/planetarium/ChangeLog | 2 + apps/planetarium/planetarium.data.csv | 159 +++++++++++++++++++++++++- 2 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 apps/planetarium/ChangeLog diff --git a/apps/planetarium/ChangeLog b/apps/planetarium/ChangeLog new file mode 100644 index 000000000..9d28d3d8d --- /dev/null +++ b/apps/planetarium/ChangeLog @@ -0,0 +1,2 @@ +0.01: New App! +0.02: Major speed improvement \ No newline at end of file diff --git a/apps/planetarium/planetarium.data.csv b/apps/planetarium/planetarium.data.csv index 7b178c767..99c943239 100644 --- a/apps/planetarium/planetarium.data.csv +++ b/apps/planetarium/planetarium.data.csv @@ -340,4 +340,161 @@ 1.134,0.273,3.6,GA TAU 3.323,-0.025,3.6,GA VIR 3.684,1.124,3.6,AL DRA -5.475,-1.020,3.6,BE IND \ No newline at end of file +5.475,-1.020,3.6,BE IND +0.161,0.941,3.7,ZE CAS +1.462,0.173,3.7,LA ORI +4.096,-0.520,3.7,TA LIB +4.741,-0.874,3.7,TH ARA +6.063,-0.370,3.7,88 AQR +2.494,1.101,3.7,23 UMA +4.129,0.269,3.7,BE SER +2.285,-0.579,3.7,AL PYX +3.323,-0.025,3.7,GA VIR +4.048,0.508,3.7,BE CRB +5.673,-0.291,3.7,GA CAP +0.871,-0.380,3.7,TA4 ERI +1.271,0.098,3.7,PI4 ORI +2.554,-1.091,3.7,_ +6.096,0.057,3.7,GA PSC +0.506,-0.901,3.7,CH ERI +0.981,0.421,3.7,17 TAU +4.703,0.510,3.7,XI HER +1.555,-0.247,3.7,ET LEP +3.081,0.834,3.7,CH UMA +4.149,0.078,3.7,EP SER +5.216,0.112,3.7,BE AQL +1.284,0.043,3.7,PI5 ORI +1.569,0.947,3.7,DE AUR +3.867,0.033,3.7,109 VIR +5.519,0.767,3.7,XI CYG +5.562,0.664,3.7,TA CYG +0.486,-0.180,3.7,ZE CET +0.929,-0.165,3.7,EP ERI +2.060,-0.708,3.7,_ +4.744,0.167,3.7,72 OPH +0.904,0.170,3.7,XI TAU +5.614,-0.391,3.7,ZE CAP +5.989,-0.132,3.7,LA AQR +1.320,0.717,3.8,ZE AUR +2.374,-0.822,3.8,_ +4.284,0.334,3.8,GA HER +4.660,0.047,3.8,GA OPH +4.684,0.993,3.8,XI DRA +5.887,1.020,3.8,DE CEP +0.745,0.976,3.8,ET PER +1.147,0.306,3.8,DE1 TAU +1.456,-1.091,3.8,BE DOR +4.406,-1.030,3.8,ET ARA +5.679,-1.351,3.8,NY OCT +5.790,0.442,3.8,JO PEG +0.983,0.743,3.8,NY PER +2.207,-1.154,3.8,BE VOL +4.995,-0.379,3.8,OK SGR +5.049,0.931,3.8,KA CYG +5.409,0.278,3.8,AL DEL +5.444,-0.166,3.8,EP AQR +5.896,0.878,3.8,AL LAC +1.871,-1.230,3.8,GA2 VOL +2.851,-1.027,3.8,_ +1.851,0.359,3.8,ZE GEM +1.945,0.485,3.8,JO GEM +5.104,0.903,3.8,JO2 CYG +5.295,0.816,3.8,31 CYG +0.827,0.783,4.8,KA PER +2.579,1.030,4.8,YP UMA +2.705,0.346,4.8,GA2 LEO +4.079,0.184,4.8,DE SER +4.079,0.184,4.8,DE SER +4.623,0.803,4.8,JO HER +1.478,-0.045,4.8,SI ORI +1.533,-0.364,4.8,DE LEP +2.732,-0.294,4.8,MY HYA +1.202,-0.533,4.8,YP2 ERI +2.438,0.642,4.8,38 LYN +2.740,-1.025,4.8,_ +4.324,0.035,4.8,LA OPH +5.181,0.323,4.8,DE SGE +6.185,0.811,4.8,LA AND +0.979,0.564,4.8,OK PER +2.851,0.597,4.8,46 LMI +3.658,-0.735,4.8,PH CEN +3.874,-1.380,4.8,AL APS +4.745,0.502,4.8,OK HER +5.184,1.226,4.8,EP DRA +1.172,0.279,4.8,TH1 TAU +2.272,-0.814,4.8,_ +2.335,-1.058,4.8,_ +2.781,-0.842,4.8,_ +3.017,1.210,4.8,LA DRA +4.113,0.459,4.8,GA CRB +4.816,0.380,4.8,109 HER +5.854,-0.024,4.8,GA AQR +0.978,-1.131,4.8,BE RET +1.515,-0.891,4.8,BE PIC +1.667,-0.584,4.8,DE COL +1.897,-0.467,4.8,OM CMA +2.682,-0.735,4.8,_ +2.761,0.162,4.8,RH LEO +4.173,0.273,4.8,GA SER +4.256,-1.112,4.8,DE TRA +4.866,-0.144,4.8,AL SCT +1.108,-0.738,4.9,AL HOR +3.306,-0.847,4.9,TA CEN +4.696,0.650,4.9,TH HER +4.772,-0.368,4.9,MY SGR +0.248,0.672,4.9,MY AND +0.838,-0.506,4.9,AL FOR +0.985,0.425,4.9,20 TAU +1.214,-0.250,4.9,53 ERI +1.445,-0.619,4.9,EP COL +1.807,-0.422,4.9,OK1 CMA +3.283,-1.259,3.9,GA MUS +3.288,1.218,3.9,KA DRA +3.659,-0.782,3.9,YP1 CEN +3.979,-0.851,3.9,KA1 LUP +0.041,-0.798,3.9,EP PHE +2.419,0.040,3.9,TH HYA +2.586,0.454,3.9,MY LEO +3.539,-0.688,3.9,_ +3.853,-0.099,3.9,MY VIR +4.175,-0.510,3.9,RH SCO +0.770,-0.155,3.9,ET ERI +2.971,-0.951,3.9,PI CEN +3.228,-0.012,3.9,ET VIR +4.275,0.808,3.9,TA HER +4.335,-1.377,3.9,GA APS +5.220,0.612,3.9,ET CYG +2.206,-0.068,3.9,_ +5.203,0.018,3.9,ET AQL +6.067,-0.790,3.9,JO GRU +1.061,0.105,3.9,NY TAU +2.295,-0.804,3.9,_ +2.530,-0.020,3.9,JO HYA +2.917,-1.029,3.9,_ +3.264,-0.877,3.9,SI CEN +4.082,-0.258,3.9,GA LIB +0.298,-0.964,3.9,ZE PHE +4.452,0.540,3.9,EP HER +5.567,0.092,3.9,AL EQU +1.206,-0.059,3.9,NY ERI +2.013,-0.167,3.9,AL MON +5.069,-0.311,3.9,RH1 SGR +0.114,-0.762,3.9,KA PHE +2.289,0.317,3.9,DE CNC +2.984,0.184,3.9,JO LEO +5.485,0.719,3.9,NY CYG +0.398,-0.856,4.0,DE PHE +0.760,0.921,4.0,TA PER +1.731,-0.336,4.0,NY2 CMA +2.015,-1.267,4.0,ZE VOL +3.508,0.959,4.0,ZE UMA +4.149,-0.587,4.0,CH LUP +5.963,0.411,4.0,LA PEG +1.152,-0.594,4.0,43 ERI +1.567,-0.747,4.0,ET COL +1.788,-0.567,4.0,KA CMA +2.024,-0.505,4.0,3 PUP +3.192,-0.914,4.0,RH CEN +4.218,-0.361,4.0,OM1 SCO +5.239,-1.273,4.0,EP PAV +1.534,0.683,4.0,NY AUR \ No newline at end of file From eb58e84d4f80db49073ecfa857eaae785c8e26fd Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Fri, 29 Jan 2021 13:36:12 +0100 Subject: [PATCH 3/8] updating readme and changelog --- apps/planetarium/ChangeLog | 2 +- apps/planetarium/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/planetarium/ChangeLog b/apps/planetarium/ChangeLog index 9d28d3d8d..5ff3fde91 100644 --- a/apps/planetarium/ChangeLog +++ b/apps/planetarium/ChangeLog @@ -1,2 +1,2 @@ 0.01: New App! -0.02: Major speed improvement \ No newline at end of file +0.02: Major speed improvement. Added more stars. Up to 500! \ No newline at end of file diff --git a/apps/planetarium/README.md b/apps/planetarium/README.md index 206fa5b50..56dc66be9 100644 --- a/apps/planetarium/README.md +++ b/apps/planetarium/README.md @@ -2,7 +2,7 @@ This planetarium takes your position and time and plots the sky as it is. -No planets, or moon, only stars. It can show the 350 most brilliant stars in the sky. +No planets, or moon, only stars. It can show the 500 most brilliant stars in the sky. Plan is to show also constellations, but this is work in progress. Now it shows Taurus and Orion as examples. From 565b621f2ea873d46047bd221ea8eacff27e93a0 Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Fri, 29 Jan 2021 13:36:57 +0100 Subject: [PATCH 4/8] updating readme and changelog --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 4e6f83c9c..9f7a67534 100644 --- a/apps.json +++ b/apps.json @@ -2679,7 +2679,7 @@ "name": "Planetarium", "shortName":"Planetarium", "icon": "planetarium.png", - "version":"0.01", + "version":"0.02", "description": "Planetarium showing up to 350 stars using the watch location and time", "tags": "", "storage": [ From b661679c19fc492d68fea9a2943f4e959f22e0ac Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Fri, 29 Jan 2021 13:37:44 +0100 Subject: [PATCH 5/8] updating app.js --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 9f7a67534..b42942e58 100644 --- a/apps.json +++ b/apps.json @@ -2680,7 +2680,7 @@ "shortName":"Planetarium", "icon": "planetarium.png", "version":"0.02", - "description": "Planetarium showing up to 350 stars using the watch location and time", + "description": "Planetarium showing up to 500 stars using the watch location and time", "tags": "", "storage": [ {"name":"planetarium.app.js","url":"planetarium.app.js"}, From 3c76559fce30d76ae4ef8ae9ecfccb349bdee40d Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Fri, 29 Jan 2021 20:19:34 +0100 Subject: [PATCH 6/8] adding a few more stars --- apps/planetarium/planetarium.app.js | 18 ++++- apps/planetarium/planetarium.data.csv | 98 +++++++++++++-------------- 2 files changed, 65 insertions(+), 51 deletions(-) diff --git a/apps/planetarium/planetarium.app.js b/apps/planetarium/planetarium.app.js index e860345a8..d750771a3 100644 --- a/apps/planetarium/planetarium.app.js +++ b/apps/planetarium/planetarium.app.js @@ -83,7 +83,21 @@ function drawStars(lat,lon,date){ var x = size / 2 + size / 2 * Math.cos(alt) * Math.sin(azi); var y = size / 2 + size / 2 * Math.cos(alt) * Math.cos(azi); starPositions[starNumber] = [x,y]; - var magnitude = starMag<1.5?2:1; + var magnitude = starMag<1?2:1; + //Stars between 1.5 and 4 magnitude should get a different colour + var col=1; + if (starMag<=1.5) + col=1; + else if (starMag>1.5 && starMag<2) + col=0.9; + else if (starMag>=2 && starMag<3) + col=0.7; + else if (starMag>=3 && starMag<3.5) + col=0.5; + else + col=0.3; + + g.setColor(col,col,col); g.fillCircle(x, y, magnitude); if (starMag<1 && settings.starnames) g.drawString(starInfo[3],x,y+2); @@ -99,7 +113,7 @@ function drawStars(lat,lon,date){ //Each star has a number (the position on the file (line number)). These are the lines //joining each star in the constellations. constelations=[[[7,68],[10,53],[53,56],[28,68],"Orion"],[[13,172],[13,340],[293,340],[29,293],"Taurus"], - [[155,8],"Canis Menor"],[[36,81],[87,81],[235,87],[33,235],[33,75],[75,40],"Ursa Major"],[[67,91],[74,67],[91,110],[110,252],"Cassiopeia"],[[23,166],[16,294],[294,44],[166,149],[230,149],[16,23],"Gemini"]]; + [[155,8],"Canis Menor"],[[36,81],[87,81],[235,87],[33,235],[33,75],[75,40],"Ursa Major"],[[67,91],[74,67],[91,110],[110,252],"Cassiopeia"],[[23,166],[16,294],[294,44],[166,149],[230,149],[16,23],"Gemini"],[[88,218],[215,292],[218,292],[245,88],[292,245],[215,218],"Cepheus"],[[150,62],[150,175],[175,35],[403,62],[487,158],[384,487],[384,158],[35,158],[487,403],"Perseus"],[[19,65],[65,90],[65,147],[466,65],[466,189],[147,401],[213,90],"Cygnus"],[[6,42],[168,6],[168,113],[113,29],[104,29],[104,42],"Auriga"]]; g.setColor(0,255,0); for (i=0;i Date: Fri, 29 Jan 2021 20:28:56 +0100 Subject: [PATCH 7/8] settings for the constellations names --- apps/planetarium/planetarium.app.js | 4 ++-- apps/planetarium/settings.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/planetarium/planetarium.app.js b/apps/planetarium/planetarium.app.js index d750771a3..f9200c9a1 100644 --- a/apps/planetarium/planetarium.app.js +++ b/apps/planetarium/planetarium.app.js @@ -132,7 +132,7 @@ function drawStars(lat,lon,date){ g.flip(); } //Write the name - if (constelationShowing) + if (constelationShowing && settings.consnames) g.drawString(constelations[i][constelations[i].length-1],positionStar2[0]+10,positionStar2[1]); } } @@ -145,7 +145,7 @@ var prevSats = 0; g.clear(); var settings = require('Storage').readJSON('planetarium.json',1)|| - { starnames:false,constellations:true}; + { starnames:false,constellations:true,consnames:false}; g.setFontAlign(0,0); diff --git a/apps/planetarium/settings.js b/apps/planetarium/settings.js index 21dd36f6b..d2351e0db 100644 --- a/apps/planetarium/settings.js +++ b/apps/planetarium/settings.js @@ -19,7 +19,13 @@ format: v =>v?'On':'Off', onchange: v => { save('constellations',v); - } - }}; + }}, + 'Const. names': { + value: !!settings.consnames, + format: v =>v?'On':'Off', + onchange: v => { + save('consnames',v); + }}, + }; E.showMenu(appMenu) }) \ No newline at end of file From 5cafc41dcf5994894cc70ea35e40d2dab74ef664 Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Date: Sun, 31 Jan 2021 16:15:00 +0100 Subject: [PATCH 8/8] adding a few constelations --- apps/planetarium/planetarium.app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/planetarium/planetarium.app.js b/apps/planetarium/planetarium.app.js index f9200c9a1..925a2c0dc 100644 --- a/apps/planetarium/planetarium.app.js +++ b/apps/planetarium/planetarium.app.js @@ -113,7 +113,7 @@ function drawStars(lat,lon,date){ //Each star has a number (the position on the file (line number)). These are the lines //joining each star in the constellations. constelations=[[[7,68],[10,53],[53,56],[28,68],"Orion"],[[13,172],[13,340],[293,340],[29,293],"Taurus"], - [[155,8],"Canis Menor"],[[36,81],[87,81],[235,87],[33,235],[33,75],[75,40],"Ursa Major"],[[67,91],[74,67],[91,110],[110,252],"Cassiopeia"],[[23,166],[16,294],[294,44],[166,149],[230,149],[16,23],"Gemini"],[[88,218],[215,292],[218,292],[245,88],[292,245],[215,218],"Cepheus"],[[150,62],[150,175],[175,35],[403,62],[487,158],[384,487],[384,158],[35,158],[487,403],"Perseus"],[[19,65],[65,90],[65,147],[466,65],[466,189],[147,401],[213,90],"Cygnus"],[[6,42],[168,6],[168,113],[113,29],[104,29],[104,42],"Auriga"]]; + [[155,8],"Canis Menor"],[[36,81],[87,81],[235,87],[33,235],[33,75],[75,40],[36,235],"Ursa Major"],[[67,91],[74,67],[91,110],[110,252],"Cassiopeia"],[[23,166],[16,294],[294,44],[166,149],[230,149],[16,23],"Gemini"],[[88,218],[215,292],[218,292],[245,88],[292,245],[215,218],"Cepheus"],[[150,62],[150,175],[175,35],[403,62],[487,158],[384,487],[384,158],[35,158],[487,403],"Perseus"],[[19,65],[65,90],[65,147],[466,65],[466,189],[147,401],[213,90],"Cygnus"],[[6,42],[168,6],[168,113],[113,29],[104,29],[104,42],"Auriga"],[[1,47],[1,37],[37,22],[22,178],[37,89],"Can Maior"],[[3,118],[118,279],[279,286],[286,180],[180,316],[316,3],"Bootes"]]; g.setColor(0,255,0); for (i=0;i