title: AS3 Object with Initial Position Entering Elliptical Orbit
body: <p><br /><br />
  So far I am able to make an object called satelite rotate around another object called turret in an elliptical manner. The only thing is that before the satelite starts rotating around the turret it has an initial position <b>(Figure 1)</b>. However after the first frame the satelite is moved from it's initial position to somewhere else<b>(Figure 2)</b>. I'm trying to have the satelite enter the elliptical rotation from it's initial position, not for it to be moved to another position and then start the elliptical rotation from that new position.</p>
  
  <h3>Figure 1 . . . . . . . . . . . . . . . . . . . Figure 2</h3>
  
  <p><a href="https://i.stack.imgur.com/iR6EQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iR6EQ.png" alt="Initial position at first frame"></a>
  
  <a href="http://s1.postimage.org/xscznk8bz/After_Initial_Position.png" rel="nofollow noreferrer">After first frame resulting position http://s1.postimage.org/xscznk8bz/After_Initial_Position.png</a><br />
  <br /></p>
  
  <h2>Code :</h2>
  
  <pre class="lang-js prettyprint-override"><code>private var fixedPoint1:int = 0;
  private var fixedPoint2:int = 0;
  private var currentDegrees:Number = 0;
  
  private function onEnterFrame(event:Event):void
  {   
      var dx:Number = turret.x - satelite.x; // This code deals with turret rotation
      var dy:Number = turret.y - satelite.y; // So does this code
  
      var angle:Number = Math.atan2(dy, dx); // As does this code
  
      turret.rotation = (angle * 180 / Math.PI); // Finally done with turret rotation code
  
      if (firstRun) {
          currentDegrees = angle * 180 / Math.PI;
          fixedPoint1 = satelite.x;
          fixedPoint2 = satelite.y;
          firstRun = false;
      }
  
      currentDegrees += 1;
  
      var radians:Number = currentDegrees * Math.PI / 180;
      var posX:Number = turret.x + Math.cos(radians) * (fixedPoint1);
      var posY:Number = turret.y + Math.sin(radians) * (fixedPoint2);
  
      satelite.x = posX;
      satelite.y = posY;      
  }
  </code></pre>
  
  <p>I kind of understand why it's moving the satelite from it's initial position to it's elliptical position based off the equations used. I just can't figure out how to edit the equations or variables to have the ellipse "start from" (maybe encompass is a better word) the initial position.
  <br />
  <br />
  Thank you for any help provided.
  <br />
  <br /></p>
  
  <h2>Update :</h2>
  
  <p>This code works, but it resembles a circular orbit instead of an elliptical orbit.<br />
  Thank you Markus Jarderot!</p>
  
  <pre><code>private function onEnterFrame(event:Event):void
  {   
          var dx:Number = turret.x - satellite.x;
          var dy:Number = turret.y - satellite.y;
  
          var angle:Number = Math.atan2(dy, dx);
  
          turret.rotation = (angle * 180 / Math.PI);
  
          if (firstRun) {
               currentAngle = (180 * Math.PI/180); // Start out at pi
                                                   // instead of 0 for some reason?
  
              fixedPointX = turret.x - satellite.x; // xRadius = distance between turret.x and satellite.x
              fixedPointY = turret.y - satellite.y; // yRadius = distance between turret.y and satellite.y
  
              firstRun = false;
          }
  
          currentAngle += Math.PI / 180.0; // one degree
          if (currentAngle &gt; Math.PI) currentAngle -= 2.0 * Math.PI;
  
          var cosAngle : Number = Math.cos(currentAngle);
          var sinAngle : Number = Math.sin(currentAngle);
  
          satellite.x = turret.x + cosAngle * fixedPointX + sinAngle * fixedPointY;
          satellite.y = turret.y - sinAngle * fixedPointX + cosAngle * fixedPointY;
  }
  </code></pre>