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.
Code:
LOCAL CRID:="Lunar V1.0 © 2019 StephenG1CMZ";
//CUSTOMISE
LOCAL XG:=1;//EXAGERATE XY SCALING,1=NORMAL
//VISUALLY CHANGE XY SCALING, TO EXAGERRATE NON-CIRCULARITY
//(NOTE-CIRCULAR ITEMS ARE UNCHANGED,SO IT IS NOT IDEAL FOR ACCOMODATING NONSQUARE PIXELS)
//NB REPORTING OF POLAR RADIUS ETC MAY ALSO CHANGE, RUN WITH XG=1 FOR STANDARD VALUES
//END CUSTOM
//COLOURS
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);
//SCRN
LOCAL SW:=320;
LOCAL LEFTX:=SW/3;
LOCAL RIGHTX:=2*SW/3;
LOCAL MIDX:=320/2;
LOCAL MIDY:=240/2;
LOCAL MOONX:=LEFTX;
LOCAL EARTHX:=MIDX;
LOCAL EARTHRR:={6378.1,6356.8/XG};//KM
LOCAL EARTHR:=EARTHRR(1);
LOCAL EARTHEQ:=EARTHRR(1);
LOCAL MOONRR:={1738.1,1736.0/XG};//KM
LOCAL MOONR:=MOONRR(1);
LOCAL MOONEQ:=MOONRR(1);
LOCAL ORADIUSRR:={0.4055ᴇ6,0.3633ᴇ6/XG};//KM
LOCAL ORADIUS:=ORADIUSRR(1);
//LOCAL RADIUS:={};
LOCAL STATI:=35876;
LOCAL EARTHDENS:=5514;//KG/m3
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 SCL:=PIXELS/MAXKM;
LOCAL DT:=1.27;//s //If you wish, *XG to exagerate seconds too
LOCAL DTPP:=1*DT/PIXELS;//s per pixel
LOCAL PX;
LOCAL RR;
EXPORT GetRoche(RADIUS1,DENS1,DENS2)
//ROCHE LIMIT DEPENDS ON
//RADIUS OF PRIMARY
//RELATIVE DENSITIES OF PRIMARY AND SECONDARY
//RETURN ROCHE LIMIT RADIUS IN RADIUS1 UNITS
BEGIN
//MSGBOX({RADIUS1,DENS1,DENS2});
RR:=RADIUS1*(2*DENS1/DENS2)^(1/3);
//MSGBOX(RR);
//RR:=9492;//EXPECTED VALUE:FIX POOR CALC
RETURN ROUND(RR,0);
END;
INITS()
BEGIN
RECT_P();
TEXTOUT_P(CRID,0,0);
END;
EXPORT TheMoon()
BEGIN
LOCAL SCL:=PIXELS/2000;
INITS();
ARC_P(MOONX,MIDY,ROUND(MOONRR*SCL,0),{YELLOWISH,MOONGLOW});
//ARC_P(MOONX,MIDY,ROUND(MOONREQ*SCL,0),{RED});
TEXTOUT_P("Moon",MOONX,210);
TEXTOUT_P("Radius "+MOONRR+"km",0,20,0);
WAIT;
END;
TheEarthy(SCL)
BEGIN
INITS();
ARC_P(EARTHX,MIDY,ROUND(EARTHRR*SCL,0),{BLUE,BLUE});
//ARC_P(EARTHX,MIDY,ROUND(EARTHEQ*SCL,0),{GREEN});//COMPARE WITH CIRCULAR
//TEXTOUT_P("Earth",EARTHX,210,0,BLUE);
END;
EXPORT TheEarth()
BEGIN
LOCAL RR;
LOCAL SCL:=PIXELS/7500;
TheEarthy(SCL);
ARC_P(MOONX,MIDY,ROUND(MOONRR*SCL,0),{YELLOWISH,MOONGLOW});//COMPARE WITH MOON
TEXTOUT_P("Moon",MOONX-20,MIDY-10);
TEXTOUT_P("Radius "+EARTHRR+"km",0,20,0);
WAIT;
RR:=GetRoche(EARTHR,EARTHDENS,MOONDENS);//FIX
SCL:=PIXELS/STATI;
TheEarthy(SCL);
//PX:=PIXELS*(STATI/ORADIUS);
ARC_P(EARTHX,MIDY,STATI*SCL,GREEN); //E STATIONARY
ARC_P(EARTHX,MIDY,RR*SCL,RED); //E ROCHE
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);
ARC_P(EARTHX,MIDY,RR*SCL,RED);
WAIT;
END;
EXPORT EM()
BEGIN
LOCAL II;
LOCAL SCL:=PIXELS/MAXKM;
TheEarth();
INITS();TheEarthy(SCL);
PX:=PIXELS*(STATI/ORADIUS);
//MSGBOX(STATI*SCL);
WAIT;
ARC_P(MIDX,MIDY,STATI*SCL,GREEN);
TEXTOUT_P("Stationary Radius "+STATI+" km",320/4,20,0,GREEN);
PX:=PIXELS; //RADIUS*SCL;
ARC_P(MIDX,MIDY,{PX,PX/XG},MOONGLOW);//NEEDS FIXING
//TO PROPERLY REFERENCE THE TWO ORADIUS VALUES
TEXTOUT_P("Radius "+ORADIUSRR+"km",0,40,0,YELLOWISH);
WAIT;
TEXTOUT_P("That's one small step for a man",MIDX-PIXELS+10,MIDY-20,2);
FOR II FROM PIXELS DOWNTO 2 DO
LINE_P(II+MIDX,MIDY,PIXELS+MIDX,MIDY,RED);
WAIT(DTPP);
END;
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);
//DRAWMENU("77");
FREEZE;
WAIT;
END;
EXPORT Legend()
BEGIN
INITS();
RR:=GetRoche(EARTHR,EARTHDENS,MOONDENS);//FIX
TEXTOUT_P("XG: "+XG,RIGHTX,220);
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);
//TEXTOUT_P("{MAX,MIN",0,240);
FREEZE;
WAIT;
END;
EXPORT LUNAR()
BEGIN
EM();
END;