> I suppose you know the width/diameter of the circles?
>
> 1. First calulate the length of you line:
> ringLength=circle1Diameter+circle2Diameter etc
> 2. Calculate the ringRadius from ringLength (I don't remember the formula
> but it's high school math)
> 3. Calculate the angle that every circle should be on:
> circleXDiameter/ringLength*360
> 4. Place the circles by converting their angle to a vector and
> multiply it
> with the ringRadius (google search for angle to vector functions,
> possibly
> it's easier to find functions that convert radians to vectors)
This sounds pretty much like I would do it. I think you're going to need an
approximate solution - it'd be a nightmare to solve algebraically. Basically
if you have a set of circles with radius r(i), and want to place them on a
ring with radius R, the angle that each circle subtends at the centre of the
circle is 2*atan(r(i)/R). So you want to find R such that the sum of
atan(r(i)/R) is pi. Here's a function that ought to work (I'm arbitrarily
assuming your ring will never have a radius greater than 1024):
function getRingRadius(tArray:Array):Number {
var tMaxError = 0.1
var tMax = 1024
var tMin = 0
do {
var tCheck = (tMax + tMin) / 2
var tSum = 0
for (var i = 0; i<tArray.length; i++) {
tSum += Math.atan2(tArray[i]/tCheck)
}
if (tSum>Math.PI) {
tMax = tCheck
} else {
tMin = tCheck
}
} while (Math.abs(tSum - Math.PI)>tMaxError)
return tCheck
}
Danny
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com