Function Repository Resource:

MoonPositionPlot3D

Source Notebook

Plot the relative positions of the Moon and Earth in 3D, illuminated by the Sun

Contributed by: Jeff Bryant

ResourceFunction["MoonPositionPlot3D"][]

plot the current relative positions of the Moon and Earth in 3D.

ResourceFunction["MoonPositionPlot3D"][date]

plot the relative positions of the Moon and Earth in 3D on the specified date.

Details and Options

Relative distances and sizes are scaled by default for optimal viewing and illustrative purposes.
ResourceFunction["MoonPositionPlot3D"] takes the same options as Graphics3D, with the following additions and changes:
BackgroundBlackbackground color for the plot
BoxStyleOpacity[0]style specifications for the box
PlotRange10range of values to include in Earth radii
SphericalRegionTruewhether to make the circumscribing sphere fit in the final display area
ViewAnglePi/10angle of the field of view
ViewPointAboveviewing position
"LunarDistance"5lunar distance in Earth radii
"LunarRadius".5lunar radius in Earth radii
"ShowEarthShadow"Falseshow Earth shadow
"ShowSubLunarPoint"Falseshow sublunar point
"ShowSubSolarPoint"Falseshow subsolar point
"ShowSunArrows"Trueshow Sun arrows
"SubLunarPointStyle"Directive[White,PointSize[.02]]sublunar point style
"SubSolarPointStyle"Directive[Opacity[.5,Yellow,PointSize[.02]]subsolar point style
"SunArrowStyle"Directive[Opacity[.5,Yellow]Sun arrow style

Examples

Basic Examples (2) 

Plot the current relative positions of the Moon and Earth:

In[1]:=
ResourceFunction["MoonPositionPlot3D"][]
Out[1]=

Plot the relative position of the Moon and Earth on a specified date:

In[2]:=
ResourceFunction["MoonPositionPlot3D"][DateObject[{2021, 1, 28, 12}]]
Out[2]=

Scope (1) 

View the relative positions of the Moon and Earth as seen from different viewpoints:

In[3]:=
newmoon = ResourceFunction["MoonPositionPlot3D"][
   DateObject[{2021, 2, 11, 12}]];
In[4]:=
GraphicsGrid[{{newmoon, Show[newmoon, ViewPoint -> Front]}, {Show[newmoon, ViewPoint -> Left], Show[newmoon, ViewPoint -> Right]}}, ImageSize -> 500]
Out[4]=

Options (4) 

Change the background and arrow colors:

In[5]:=
ResourceFunction["MoonPositionPlot3D"][Background -> White, "SunArrowStyle" -> Orange]
Out[5]=

View a full moon from the front:

In[6]:=
ResourceFunction["MoonPositionPlot3D"][
 DateObject[{2021, 2, 1, 14}, TimeZone -> -6], "ShowSunArrows" -> False, ViewPoint -> Front]
Out[6]=

View a full moon from the back:

In[7]:=
ResourceFunction["MoonPositionPlot3D"][
 DateObject[{2021, 2, 1, 14}, TimeZone -> -6], "ShowSunArrows" -> False, ViewPoint -> Back]
Out[7]=

Show the subsolar and sublunar points on the Earth:

In[8]:=
ResourceFunction["MoonPositionPlot3D"][
 DateObject[{2021, 2, 1, 21, 35}, TimeZone -> -6], "ShowSubSolarPoint" -> True, "ShowSubLunarPoint" -> True, ViewPoint -> {1.72, 1.0, -0.1}]
Out[8]=

Zoom in to see the subsolar and sublunar points in more detail:

In[9]:=
ResourceFunction["MoonPositionPlot3D"][
 DateObject[{2021, 2, 1, 21, 35}, TimeZone -> -6], "ShowSubSolarPoint" -> True, "ShowSubLunarPoint" -> True, ViewPoint -> {1.72, 1.0, -0.1}, ViewAngle -> Pi/25]
Out[9]=

Show the shadow of the Earth during a lunar eclipse:

In[10]:=
ResourceFunction["MoonPositionPlot3D"][
 DateObject[{2021, 5, 26, 6, 19}], "ShowEarthShadow" -> True, "ShowSunArrows" -> False]
Out[10]=

Adjust scaling factors for a more realistic representation:

In[11]:=
ResourceFunction["MoonPositionPlot3D"][
 DateObject[{2021, 5, 26, 6, 19}], "LunarRadius" -> .2727, "LunarDistance" -> 60.34, "ShowEarthShadow" -> True, ViewAngle -> Pi/7, PlotRange -> 61, "ShowSunArrows" -> False]
Out[11]=

Properties and Relations (1) 

Use MoonPhase to associate the view from Earth with the 3D orientation:

In[12]:=
GraphicsGrid[{With[{date = #},
     ResourceFunction["MoonPositionPlot3D"][date, PlotLabel -> Show[MoonPhase[date, "Icon"], ImageSize -> 25]]] & /@ {DateObject[{2021, 1, 12, 23}, TimeZone -> -6], DateObject[{2021, 1, 20, 23}, TimeZone -> -6], DateObject[{2021, 1, 28, 23}, TimeZone -> -6], DateObject[{2021, 2, 4, 23}, TimeZone -> -6]}}, ImageSize -> 600]
Out[12]=

Possible Issues (1) 

Time of day affects the orientation of the scene as the Earth rotates:

In[13]:=
GraphicsGrid[{ResourceFunction["MoonPositionPlot3D"][
     DateObject[{2021, 1, 12, #}, TimeZone -> -6]] & /@ {0, 6, 12, 18}}, ImageSize -> 600]
Out[13]=

Version History

  • 1.0.1 – 10 February 2021
  • 1.0.0 – 08 February 2021

Related Resources

License Information