All righty... I can get a point within a given range of another point: // returns a point within a randomly determined distance from another point public static function randomLocationInRange(p : Point, range : Number) { var pResult : Point = new Point(0,0); pResult.x = randomRange(p.x, range); pResult.y = randomRange(p.y, range); // done! return pResult; } However, this returns a point within a rectangle. What I would really like is to get a point within a circle. I can get the random angle, but I'm stumped with regards to determining the subsequent x,y vals. My thinking is that the solution involves reversing this : // returns the distance between two points public static function distance(p1 : Point, p2 : Point) { var dx : Number = 0 ; var dy : Number = 0; dx = p2.x - p1.x; dy = p2.y - p1.y; return Math.sqrt(dx * dx + dy * dy); } Trigonometry confuses and frightens me. Any suggestions?
Got it. Sloppy, but it works: public static function randomLocationInRange(p : Point, range : Number, circle:Boolean = true) { var pResult : Point = new Point(0,0);
// TODO: work with radians rather than degrees
var angle:Number = Math.floor(Math.random()*360);
if (circle){
// finds a point within a circle
pResult.x = p.x + Math.cos(toRadians(angle))*range*Math.random();
pResult.y = p.y + Math.sin(toRadians(angle))*range*Math.random();
} else {
// finds a point within a rectangle
pResult.x = randomRange(p.x, range);
pResult.y = randomRange(p.y, range);
}
// done!
return pResult;
}
Yeah, defining angle in radians would be better than defining it in degrees, but as I said... trigonometry, confusion, and fear.
var angle:Number = Math.random()*2*Math.PI;
I am clearly an idiot. 
no just used to degrees