Solar System

Introductory Notes

This notebook creates a simple Sun-Earth-Moon system. Each object is built upon the same three-dimensional graphics created using ParametricPlot3D.
The objects are positioned, scaled, and colored in Dynamic Visualizer. You can then rotate the Earth around the Sun and the Moon around the Earth.
The initialization cells create the model but do not run the animation.

Create Objects

<< DynamicVisualizer`

ClearVisualizer[];

Create the Generic Sphere

\($DisplayFunction\  = \ Identity; 

    ballGraphics = 
      ParametricPlot3D[{Sin[u]\ Cos[v], Sin[u]\ Sin[v], Cos[u]}, {u, 0, 
          π}, {v, 0, 2\ π}]; \)

Set the Planetary Distances (Note: Not to Scale)

moonSize = 0.2; earthSize = 0.4; emRotationRadius = 0.7; seRotationRadius = 3;

Create the Earth, Moon, and Sun

Create the Earth, Moon, and Sun objects in Dynamic Visualizer. Each is based on the preceding ball graphics, but is given a specific name.
This step takes some time. Ensure that the kernel and Dynamic Visualizer each have at least 3 MB free.

\(CreateObject[Object3D["Earth"], ballGraphics, 
      Scale -> earthSize, 
      Color -> {Table[Hue[If[Random[] >  .8,  .3, \(- .3\)]], {60}]}, 
      RenderMode -> SmoothShaded, 
      Location -> {seRotationRadius, 0, 0}]; 

    CreateObject[Object3D["Moon"], ballGraphics, Scale -> moonSize, 
      Color -> {Table[GrayLevel[Random[]], {20}]}, 
      RenderMode -> SmoothShaded, 
      Location -> {seRotationRadius + emRotationRadius, 0, 0}]; 

    CreateObject[\ Object3D["Sun"], ballGraphics, Scale -> 1, 
      Color -> {Table[RGBColor[1. , 1. ,  .5 +  .5\ Random[]], {60}]}, 
      Diffuse ->  .0, Ambient ->  .9, Specular ->  .0, 
      RenderMode -> SmoothShaded, InteractiveMovement -> False]; 
    \)

Turn off the default model bounding box and the camera icon.

\(SetOptions[Camera[{VisualizerUniverse, "Camera"}], 
      Visible -> Off, Location -> {0, \(-8\), 0}]; 

    SetOptions[$DefaultModel3D, BoundingBox -> Off, Scale -> \ 2, 
      ModelRange -> 
        seRotationRadius\ {{\(-1\), \(-1\), \(-1\)}, {1, 1, 1}}]; \)

Animate

Create the Animation Script

anim = 
      Table[{c = Cos[theta]; s = Sin[theta]; 
          earthPosition = seRotationRadius {c, -s, 0}; 
          DV`SetOptions[Object3D["Moon"], 
            EulerAngles -> {0, 0, theta}, 
            Location -> earthPosition + emRotationRadius {c, s, 0}], 
          DV`SetOptions[Object3D["Earth"], 
            Location -> earthPosition]}, {theta, 0, 8 π, 
          (π/32)}];

Send the Animation to Dynamic Visualizer

Visualize[anim];