title: Orbiting objects with equal spacing AS3
body: <p>I have a monster that produces crystals. I want each crystal to orbit the monster, but when there is more than one crystal, I want them to orbit at an equal distance from each other. I've been trying to get this to work using two blocks of code I already have, but each one does something different and i need one block of code that does it all.</p>
  
  <p>This block simply allows an object to orbit another:</p>
  
  <pre><code>orbitRadius = 110;
  angle += orbitSpeed;
  rad = (angle * (Math.PI / 180));
  orbitX = monster.x + orbitRadius * Math.cos(rad);
  orbitY = monster.y + orbitRadius * Math.sin(rad);
  </code></pre>
  
  <p>Here's a video of what it looks like:
  <a href="https://www.youtube.com/watch?v=ACclpQBsjPo" rel="nofollow noreferrer">https://www.youtube.com/watch?v=ACclpQBsjPo</a></p>
  
  <p>This block of code arranges crystals around the monster based on the amount of crystals there are:</p>
  
  <pre><code>radius = 110;
  angle = ((Math.PI * 2) / targetArray.length) * targetArray.indexOf(this);
  orbitX = monster.x - (radius * Math.cos(angle));
  orbitY = monster.y - (radius * Math.sin(angle));
  </code></pre>
  
  <p>And here's this video: <a href="https://www.youtube.com/watch?v=TY0mBHc2A8U" rel="nofollow noreferrer">https://www.youtube.com/watch?v=TY0mBHc2A8U</a></p>
  
  <p>I do not know how to both space the crystals equally <strong>and</strong> make them circle around the monster at the same time. What needs to be done in order to achieve this?</p>