HP Forums
Astronomy: Lunar - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Astronomy: Lunar (/thread-13311.html)

Astronomy: Lunar - StephenG1CMZ - 07-20-2019 09:10 PM

In celebration of the 50th anniversary of the Apollo 11 Moon Landing, here is a simple Lunar Astronomy program.

RE: Astronomy: Lunar - StephenG1CMZ - 07-20-2019 09:17 PM

Version 1 illustrates the Moon, the Earth, the Moon's orbit around the Earth, and animates the light-distance of the Moon from the Earth.

Variable XG can be changed to exaggerate the non-spherical/non-circular shape.
Caution: Changing that value will also change the listed radius values.


 LOCAL CRID:="Lunar V1.0 © 2019 StephenG1CMZ";


 LOCAL BLUE    :=RGB(0,0,255);
 LOCAL GREEN   :=RGB(0,255,0);
 LOCAL MOONGLOW:=RGB(244,201,201);
 LOCAL RED     :=RGB(255,0,0); 
 LOCAL YELLOWISH :=RGB(255,120,0);

 LOCAL SW:=320;
 LOCAL MIDX:=320/2;
 LOCAL MIDY:=240/2;


 LOCAL EARTHRR:={6378.1,6356.8/XG};//KM
 LOCAL MOONRR:={1738.1,1736.0/XG};//KM
 LOCAL ORADIUSRR:={0.4055ᴇ6,0.3633ᴇ6/XG};//KM
 LOCAL STATI:=35876;
 LOCAL MOONDENS:=3344; //KG/m3
 LOCAL MAXKM:=400000;
 //For radius down half the screen (allowing titles)
 LOCAL PIXELS:=100;//for the main sphere or orbit radius (ie half*MIN(320,240), less border edges)

 LOCAL DT:=1.27;//s //If you wish, *XG to exagerate seconds too
 LOCAL DTPP:=1*DT/PIXELS;//s per pixel



 EXPORT TheMoon()

  TEXTOUT_P("Radius  "+MOONRR+"km",0,20,0);


 EXPORT TheEarth()
  TEXTOUT_P("Radius  "+EARTHRR+"km",0,20,0);


  TEXTOUT_P("Earth  ",0,MIDY,0,BLUE); 
  TEXTOUT_P("Stationary Radius  "+STATI+" km",320/4,40,0,GREEN);
  TEXTOUT_P("Roche Radius       "+RR   +" km",320/4,60,0,RED);

  TEXTOUT_P("Stationary Radius  "+STATI+" km",320/4,20,0,GREEN);
  TEXTOUT_P("Radius  "+ORADIUSRR+"km",0,40,0,YELLOWISH); 
  TEXTOUT_P("That's one small step for a man",MIDX-PIXELS+10,MIDY-20,2);
  TEXTOUT_P("One giant leap for mankind",MIDX-PIXELS+10,MIDY+10,2);
  //TEXTOUT_P("Thats one small step for a man, One giant leap for mankind",0,200,2);

 EXPORT Legend()
  TEXTOUT_P("Earth "+STRING(EARTHRR)+"km",0,20,0,BLUE);
  TEXTOUT_P("Stationary Radius  "+STATI+" km",320/4,40,0,GREEN);
  TEXTOUT_P("Roche Radius       "+RR   +" km",320/4,60,0,RED);
  TEXTOUT_P("Moon  "+STRING(MOONRR)+" km",0,120,0);
  TEXTOUT_P("Lunar Orbit "+STRING(ORADIUSRR)+"km",0,140,0);
  TEXTOUT_P("Lunar Orbit "+DT+" s",0,160,0,RED);


RE: Astronomy: Lunar - StephenG1CMZ - 06-29-2023 10:37 AM

I have now written a Python version of this program, in time for the next anniversary:

(The PPL version is more interactive).

RE: Astronomy: Lunar - StephenG1CMZ - 09-25-2023 09:50 PM

I have now written a different version, now implementing Lunar Eclipse calculations based on Jean Meeus algorithms, separate from my earlier graphical program.

(Edit: now v0.2)
If you are wondering how large Numworks source can be, version 0.2 of my program is at the limit for a Numworks module (the last couple of lines which are not necessary, disappear).

Note:if reading the source online on a Chromebook, long lines may be visually truncated (full source shown if you inspect)
The My Numworks source compiles ok.

RE: Astronomy: Lunar - StephenG1CMZ - 10-03-2023 08:05 AM

I have now extended that to a version that calculates both solar eclipse and lunar eclipse, in time for the eclipses later this month.

Update: V0.1 has a bug in my solar eclipse calculation, use V0.2 instead.

RE: Astronomy: Lunar - StephenG1CMZ - 10-09-2023 09:32 AM

There is a bug in V0.1 of my solar eclipse calculation.
When working out the time of the eclipse I always call "adjustdays (True" Ie adjusting for a Lunar eclipse.
Workaround - change call to "adjustdays(koff" (koff is 0 or False when calculating Solar, Nonzero or True when lunar).
(The mistake is less than 2 minutes for the October 2023 solar eclipse, and luckily is earlier this time, so you won't be late)

RE: Astronomy: Lunar - StephenG1CMZ - 10-10-2023 09:05 AM

I have now uploaded V0.2 of aeclipse, which corrects the time of the solar eclipse calculation. Hope it is useful.