What is an elegant way to position 8 circles around a point
actionscript, actionscript-3
Solution
for(var i:int = 0; i < 8; i++)
{
var ball:Ball = new Ball();
// Point has a useful static function for this, it takes two parameters
// First, length, in other words how far from the center we want to be
// Second, it wants the angle in radians, a complete circle is 2 * Math.PI
// So, we're multiplying that with (i / 8) to place them equally far apart
var pos:Point = Point.polar(50, (i / 8) * Math.PI * 2);
// Finally, set the position of the ball
ball.x = pos.x;
ball.y = pos.y;
circles.push(ball);
}
Problem
``` var circles:Array = new Array(); for(var i:int = 0; i < 8; i++) { var ball:Ball = new Ball(); ball.x = ??? ball.y = ??? circles.push(ball); } ``` What is the best way to position balls around some point lets say in 5-10 distance of each other, is there some formula?