title: Moon orbit in relation to sun
body: <p>I can get the Earth to rotate around the Sun and around its own axis, but I can't get the Moon to rotate around the Earth. (I just want it to circulate around it, I don't need to calculate gravity or anything like that.)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>double earth_x = 50.0 * cos(orbit / 180.0 * Math::Constants&lt;double&gt;::pi);
  double earth_y = 45.0 * sin(orbit / 180.0 * Math::Constants&lt;double&gt;::pi);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  //sun
  glMaterialAmbientAndDiffuse(GLMaterialEnums::FRONT,GLColor&lt;GLfloat,4&gt;(1.5f,1.0f,0.0f));
  glTranslate(0.0f, 0.0f, 0.0f);
  glRotate(0.0, 0.0, 0.0, 00.0);
  drawEllipsoid(10.0, 1.0, 4, 4);
  
  
  
  //Earth
  glPushMatrix();
  glTranslate(earth_x, earth_y, 0.0);
  glMaterialAmbientAndDiffuse(GLMaterialEnums::FRONT,GLColor&lt;GLfloat,4&gt;(0.2f,50.0f,50.5f));
  glRotatef(110,0.0,23.0,110.0f); 
  
  glRotatef(orbit2, 0.0f, 0.0f,1.0f);
  drawPlanetGrid(5, 1, 20, 20, 1.5);
  
  glPopMatrix();
  
  glMaterialAmbientAndDiffuse(GLMaterialEnums::FRONT,GLColor&lt;GLfloat,4&gt;(50.2f,50.0f,50.5f));
  //Moon
  glTranslate(earth_x+10, earth_y+10, 0.0);
  glRotate(moonOrb, 0.0, 0.0, 1.0);
  
  drawEllipsoid(1, 1, 9, 9);  
  
  moonOrb += .5;
  if (moonOrb &gt; 360)
  moonOrb = 0.0;
  orbit += .9;
  if (orbit &gt; 360)    
  {
      orbit = 0;
  }
  orbit2 += 6.5;
  if (orbit2 &gt; 360)
  {
   orbit2 = 0;
  }
  </code></pre>
  
  <p>Any idea what could be wrong with my code? 
  As of right now I don't have texture on my objects, so that's why it's missing from the code. I am really just trying to understand how the solar system works before I make any changes to the sizes, orbit shape and things like that. </p>