private float calculateDifferenceBetweenAngles(float firstAngle, float secondAngle)
   {
   	float difference = secondAngle - firstAngle;
         while (difference < -180) difference += 360;
         while (difference > 180) difference -= 360;
         return difference;
  }