AS3 Get Point Using Polar Co-ordinates


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

This function returns a point object based upon the position, angle and distance of a starting point (polar co-ordinates).


Copy this code and paste it in your HTML
  1. private function getPolarPoint($startPt:Point, $degrees:Number, $distance:Number):Point
  2. {
  3. var destinationPt:Point = new Point();
  4. destinationPt.x = $startPt.x + Math.round($distance * Math.cos( $degrees * Math.PI / 180 ));
  5. destinationPt.y = $startPt.y + Math.round($distance * Math.sin( $degrees * Math.PI / 180 ));
  6. return destinationPt;
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.