Radians / Degrees Utility AS3


/ Published in: ActionScript 3
Save to your folder(s)

example: posX += Math.cos(Radians.fromDegrees(rotation)) * speed;


Copy this code and paste it in your HTML
  1. package utils {
  2.  
  3. public class Radians {
  4.  
  5. public function Radians() {
  6.  
  7. }
  8.  
  9. /* Radians to degrees */
  10. public static function toDegrees(radians:Number):Number
  11. {
  12. return radians * 180 / Math.PI;
  13. }
  14.  
  15. /* Degrees to radians */
  16. public static function fromDegrees(degrees:Number):Number
  17. {
  18. return degrees * Math.PI / 180;
  19. }
  20. }
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.