I wish there were more discussions like this...
I experimented a bit with this with some curving equations,
this is what I
have to contribute:
import flash.geom.Point;
var particleAmount = 100;
var particles = [];
var radiusMin = 3;
var radiusMax = 100;
function createParticles(){
var i = -1, l = particleAmount, a = 0, rDiff = radiusMax
- radiusMin;
while(++i<l){
a = Math.pow(2, 10 * (i/l-1));
//a = Math.sin((Math.PI/2)*i/l);
trace(a);
var radius = a*rDiff;
//var theta = Math.random()*Math.PI*2;
var theta = (i/l)*(Math.PI*2);
//var theta = 0;
particles.push(Point.polar(radius, theta));
}
}
function drawParticles(){
var i = -1, l = particles.length;
_root.createEmptyMovieClip('emc', 1);
_root.emc._x = Stage.width/2;
_root.emc._y = Stage.height/2;
_root.emc.lineStyle(1, 0x000000, 100);
//trace(particles);
trace(particles.length);
while(++i<l){
var a = particles[i].x*3, b = particles[i].y*3, c =
a, d = b + 1;
_root.emc.moveTo(a,b);
_root.emc.lineTo(c,d);
}
}
createParticles();
drawParticles();
Variable a is a set of different equations that will create
curves, the
equation that uses pow uses an exponential curve. The
Math.sin one uses a
simple sin curve. The theta can be swaped around too to
check out the effect
the equations give.
I noticed you mentioned creating a bias on the right side of
a rectangle
too, I think you can do this by using a range for the x
property of a point
instead of the radius.
M.
On 5/26/06, clark slater <slater.clark gmail.com> wrote:
>
> I need to randomly distribute a series of particles in
a 2D space with a
> bias towards the zero point for both dimensions. I know
how to create a
> biased distribution towards the center (thanks Keith
peters) by averaging
> a
> series of throws - but I am stuck on the zero bias
distribution.
>
> Any ideas? I guess I need something like an exponential
decay curve?
>
> Clark
> _______________________________________________
> Flashcoders chattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
_______________________________________________
Flashcoders chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
|