Re: [Flashcoders] Position objects evenly around ellipse
Would anyone have a function, class, formula, idea whatever that would allow me to calculate X and Y values to place an n number of movie clips evenly spaced around an ellipse/oval shape? The number of clips can vary based on external data. The ellipse would also have to be calculated I suppose, but not actually drawn - the representation of it would be a separate graphic. 'evenly spaced' is a slightly ambiguous phrase. It could either mean that they are spaced with even angles (meaning that physically the clips at the 'pointy end' of the ellipse would be closer to each other) or that they are spaced with equal arc lengths, or various other metrics. I always find it easiest to think of an ellipse as a circle transformed by a stretch and rotate. So I'd do it something like this: for an ellipse with short radius (semiminor axis) a and long radius (semimajor axis) b, centred on c, pointed along the unit vector v: first place your clips evenly spaced around a unit circle: if there are N clips then place clip i at (sin(i*2*pi/N), cos(i*2*pi/N)) then stretch the positions: multiply the x-axis by a and y-axis by b: (a*sin(i*2*pi/N), b*cos(i*2*pi/N)) then rotate: move to i[2]*v+i[1]*normal(v) then translate: add c to each point. HTH Danny ___ Flashcoders@chattyfig.figleaf.com 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
[Flashcoders] Position objects evenly around ellipse
Would anyone have a function, class, formula, idea whatever that would allow me to calculate X and Y values to place an n number of movie clips evenly spaced around an ellipse/oval shape? The number of clips can vary based on external data. The ellipse would also have to be calculated I suppose, but not actually drawn - the representation of it would be a separate graphic. I found the algebraic formula for an ellipse on a Cartesian plane to be: Ax2 + Bxy + Cy2 + Dx + Ey + F = 0 But no idea how to make a translation to my problem. Thanks! Jason Merrill | E-Learning Solutions | icfconsulting.com NOTICE: This message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited. ___ Flashcoders@chattyfig.figleaf.com 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
Re: [Flashcoders] Position objects evenly around ellipse
I have some code I used in a project todo a similiar idea.. this should get you started.. puts the clips around a perfect circle.. you'll have to play with it a bit. var clipPosition:Number = 0; function setPosition(p_clip:MovieClip):Void { clipPosition += 60; var r:Number = clipPosition*Math.PI/180; var d:Number = 80; if (r/Math.PI*180760) { r += 180; d += 155; clipPosition -= 41; } else if (r/Math.PI*180360) { d += 80; clipPosition -= 30; } p_clip._x = Math.cos(R)*d; p_clip._y = Math.sin(R)*d; } for (var i = 0; i20; i++) { var clip = this.attachMovie(clip, clip_+i, i); setPosition(clip); } Cheers, Ryan On 3/16/06, Merrill, Jason [EMAIL PROTECTED] wrote: Would anyone have a function, class, formula, idea whatever that would allow me to calculate X and Y values to place an n number of movie clips evenly spaced around an ellipse/oval shape? The number of clips can vary based on external data. The ellipse would also have to be calculated I suppose, but not actually drawn - the representation of it would be a separate graphic. I found the algebraic formula for an ellipse on a Cartesian plane to be: Ax2 + Bxy + Cy2 + Dx + Ey + F = 0 But no idea how to make a translation to my problem. Thanks! Jason Merrill | E-Learning Solutions | icfconsulting.com NOTICE: This message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited. ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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
RE: [Flashcoders] Position objects evenly around ellipse
Thanks very much Ryan - looks like a good start - I can use maybe a little of that, but an ellipse is also mathematically quite different, and I'm not sure how I would go about modifying your example to fit an ellipse shape. Plus, it seems (though I haven't tested it) you are hard coding values in there, assuming there are 20 clips and thus have hard coded values such as 41 80, so that determines the spacing - I need a function that will dynamically spread them out evenly, not knowing how many there will be. But seriously, thanks very much, for sending what you did. I'm just not mathematically adept enough to translate that to my problem. Other ideas? Jason Merrill | E-Learning Solutions | icfconsulting.com -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ryan Matsikas Sent: Thursday, March 16, 2006 7:01 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Position objects evenly around ellipse I have some code I used in a project todo a similiar idea.. this should get you started.. puts the clips around a perfect circle.. you'll have to play with it a bit. var clipPosition:Number = 0; function setPosition(p_clip:MovieClip):Void { clipPosition += 60; var r:Number = clipPosition*Math.PI/180; var d:Number = 80; if (r/Math.PI*180760) { r += 180; d += 155; clipPosition -= 41; } else if (r/Math.PI*180360) { d += 80; clipPosition -= 30; } p_clip._x = Math.cos(R)*d; p_clip._y = Math.sin(R)*d; } for (var i = 0; i20; i++) { var clip = this.attachMovie(clip, clip_+i, i); setPosition(clip); } Cheers, Ryan On 3/16/06, Merrill, Jason [EMAIL PROTECTED] wrote: Would anyone have a function, class, formula, idea whatever that would allow me to calculate X and Y values to place an n number of movie clips evenly spaced around an ellipse/oval shape? The number of clips can vary based on external data. The ellipse would also have to be calculated I suppose, but not actually drawn - the representation of it would be a separate graphic. I found the algebraic formula for an ellipse on a Cartesian plane to be: Ax2 + Bxy + Cy2 + Dx + Ey + F = 0 But no idea how to make a translation to my problem. Thanks! Jason Merrill | E-Learning Solutions | icfconsulting.com NOTICE: This message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited. ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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
Re: [Flashcoders] Position objects evenly around ellipse
heres a js library has an oval function... might be of some use to get you going http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm Thanks very much Ryan - looks like a good start - I can use maybe a little of that, but an ellipse is also mathematically quite different, and I'm not sure how I would go about modifying your example to fit an ellipse shape. Plus, it seems (though I haven't tested it) you are hard coding values in there, assuming there are 20 clips and thus have hard coded values such as 41 80, so that determines the spacing - I need a function that will dynamically spread them out evenly, not knowing how many there will be. But seriously, thanks very much, for sending what you did. I'm just not mathematically adept enough to translate that to my problem. Other ideas? Jason Merrill | E-Learning Solutions | icfconsulting.com -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ryan Matsikas Sent: Thursday, March 16, 2006 7:01 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Position objects evenly around ellipse I have some code I used in a project todo a similiar idea.. this should get you started.. puts the clips around a perfect circle.. you'll have to play with it a bit. var clipPosition:Number = 0; function setPosition(p_clip:MovieClip):Void { clipPosition += 60; var r:Number = clipPosition*Math.PI/180; var d:Number = 80; if (r/Math.PI*180760) { r += 180; d += 155; clipPosition -= 41; } else if (r/Math.PI*180360) { d += 80; clipPosition -= 30; } p_clip._x = Math.cos(R)*d; p_clip._y = Math.sin(R)*d; } for (var i = 0; i20; i++) { var clip = this.attachMovie(clip, clip_+i, i); setPosition(clip); } Cheers, Ryan On 3/16/06, Merrill, Jason [EMAIL PROTECTED] wrote: Would anyone have a function, class, formula, idea whatever that would allow me to calculate X and Y values to place an n number of movie clips evenly spaced around an ellipse/oval shape? The number of clips can vary based on external data. The ellipse would also have to be calculated I suppose, but not actually drawn - the representation of it would be a separate graphic. I found the algebraic formula for an ellipse on a Cartesian plane to be: Ax2 + Bxy + Cy2 + Dx + Ey + F = 0 But no idea how to make a translation to my problem. Thanks! Jason Merrill | E-Learning Solutions | icfconsulting.com NOTICE: This message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited. ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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 ___ Flashcoders@chattyfig.figleaf.com 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