MoonPhase 2.0 Lunar knowledge of any date and time


#1

Description

First update in under 12 hours. This provides information on the current lunar phase based on the time and date it is requested, OR based on any date in history or in the future. The computation is done on the device, no API’s are called.

Blocks

Index returns a number of or between 0 and 7.

  • 0 new moon,
  • 1 waxing crescent,
  • 2 first quarter,
  • 3 waxing gibbous,
  • 4 full moon,
  • 5 waning gibbous,
  • 6 last quarter,
  • 7 waning crescent.

Current moon phase gives a percentage of illumination of the lunar surface.

The age of the moon returns how old the moon is in its current lunar cycle.

These next blocks are a little Kepler calculation to tell you what the speed and orbital distance of a planet would be, if you changed the mass of the sun, and changed how long a “year” would be. It returns the Distance, and Velocity of the planet.

Instructions.

Index returns an integer, Phase returns a number with decimal points (technically it could be a negative -99.99 – 0 – 99.99.

Age returns a String with a description.

Here are all three blocks in action with some labels

For the blocks on any custom date, everything is number based. No dashes etc.

For the Orbital Calculator, please ensure the mass of the sun does not exceed 200x. That would collapse the solar system and I like our solar system as it is thank you!

Download .

MoonPhase.aix (21.8 KB)


#2

Maybe what you can do for the Lunar index is:

switch (lunarIndex) {
    case 0:
        return "New moon";
        break; 
    case 1:
        return "Waxing crescent";
        break; 
    case 2:
        return "First quarter";
        break; 
    case 3:
        return "Waxing gibbous";
        break; 
    case 4:
        return "Full moon";
        break; 
    case 5:
        return "Waning gibbous";
        break; 
    case 6:
        return "Last quarter";
        break; 
    case 7:
        return "Waning crescent";
        break; 
}

I learned this switch-case technique from @Monexy_28


#3

Well I specifically did not do it like that because I wanted people to be able to use their own graphics if they wanted.

switch-case technique is cool.


#4

What graphics are you using? You just convert it to a string for easier output so the users don’t have to keep coming back to a topic?


#5

If (num == 0 ) image = newmoon.png ;

is alot easier then

if (string =“New moon”) image = newmoon.png.;

Thats the way I did it, and that is why.


#6

You could use this:
https://www.timeanddate.com/scripts/moon.php?i=0.5&r=0.5

By changing “i” parameter (0 to 1) you change the illuminated surface of the moon.
By changing “r” parameter (0 to 1) you change the rotation of the image.


#7

Also, that way the extension will be more international language friendly.
@MeteorCoder Spoon feeding the user is not always a good idea.