title: How to rotate an object around another moving object in java?
body: <p>I'm quite new to Java and want to program an easy sun system where the moon rotates around the earth and the earth around the sun. 
  Everything works well except the moon doesn't want to move correctly :/ 
  Because the earth diverges from the moon's initial position, the rotation radius of the moon grows accordingly to that distance. And again when the earth gets closer to the moons inertial position, the rotation radius decreases.
  If the initial position is (0;0), it works but the moon hits the sun...</p>
  
  <p>So how can I keep the distance between earth and moon constant? 
  I'm using AffineTransforms and here is a snippet of my code ;)</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>Ellipse2D.Double MoonFrame = new Ellipse2D.Double(orbitEarth + orbitMoon - radiusMoon, -radiusMoon, radiusMoon*2, radiusMoon*2);
  
  for (int i = 0; i &lt; 360; i++)
    {
      theta += Math.PI/30;
      AffineTransform TransformMoon = AffineTransform.getRotateInstance(theta,TransformEarth.getTranslateX(),TransformEarth.getTranslateY());
  
      g2d.fill(TransformMond.createTransformedShape(MoonFrame));
    }
  </code></pre>