title: rotation issues
body: <p>im having trouble getting this rotation function down pat. i have a turret that should be rotating towards another moving object. it should find the shortest direction to rotate.</p>
  
  <p>basically what ive done is converted action script rotation from using -1 -> -179 to 180 -> 359. but now im having issues when the object it is tracking passes over the zero degree point. the turrent then rotates around the other way.</p>
  
  <p>here is the code. my mind is getting a little boggled. it is being passed the x difference between the objects, and the y difference</p>
  
  <pre><code>public function Move(xdiff:Number,ydiff:Number){
          var currentRotation:Number;
          rot = Math.round(Math.atan(ydiff/xdiff) * (180/Math.PI));
          if(xdiff &lt; 0){
              //this.rotation = 180 + rot;
              rot = rot + 180
          }else{
              //this.rotation = rot;
          }
          if(rot &lt; 0 &amp;&amp; rot &gt; -90){
              rot = 270 + 90 + rot;
          }
          trace("idealrotation: " + rot + "currentrotation: " + rotation);
          currentRotation = rotation;
          if(currentRotation &lt; 0){
              currentRotation += 360;
          }
          if(rot - currentRotation &gt; 0){
              if(Math.abs(rot-currentRotation) &lt; 5){
                  rotation = rot;
              }else{
                  rotation += rotationSpeed;
              }
          }else if(rot - currentRotation &lt; 0){
              if(Math.abs(rot-currentRotation) &lt; 5){
                  rotation = rot;
              }else{
                  rotation -= rotationSpeed;
              }
          }else{
              rotation = rot;
          }
  
          //this.rotation = rot;
      }
  </code></pre>