diff --git a/apps.json b/apps.json index 09462a8ba..556ed8f29 100644 --- a/apps.json +++ b/apps.json @@ -2698,8 +2698,8 @@ "name": "Planetarium", "shortName":"Planetarium", "icon": "planetarium.png", - "version":"0.01", - "description": "Planetarium showing up to 350 stars using the watch location and time", + "version":"0.02", + "description": "Planetarium showing up to 500 stars using the watch location and time", "tags": "", "storage": [ {"name":"planetarium.app.js","url":"planetarium.app.js"}, diff --git a/apps/planetarium/ChangeLog b/apps/planetarium/ChangeLog new file mode 100644 index 000000000..5ff3fde91 --- /dev/null +++ b/apps/planetarium/ChangeLog @@ -0,0 +1,2 @@ +0.01: New App! +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 ff2178888..56dc66be9 100644 --- a/apps/planetarium/README.md +++ b/apps/planetarium/README.md @@ -2,10 +2,18 @@ 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. 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..925a2c0dc 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,48 +58,62 @@ 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?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); + 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 //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],[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;iv?'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