[DGD] Damage Weapons and Stuff (Math and Code)

Ben Chambers bjchamb at bellsouth.net
Tue Jun 3 04:26:07 CEST 2003


yeah, I was looking on line, this version is taken straight from that
version but doesn't use the calls to cos/sin... which would be slower...
sin/cos or this version?

----- Original Message -----
From: "White, Ben" <ben.white at dsto.defence.gov.au>
To: <dgd at list.imaginary.com>
Sent: Monday, June 02, 2003 10:12 PM
Subject: RE: [DGD] Damage Weapons and Stuff (Math and Code)


> From: Ben Chambers [mailto:bjchamb at bellsouth.net]
> >
> > http://www.taygeta.com/random/gaussian.html
> >
> > The code found there follows:
> >          float x1, x2, w, y1, y2;
> >
> >          do {
> >                  x1 = 2.0 * ranf() - 1.0;
> >                  x2 = 2.0 * ranf() - 1.0;
> >                  w = x1 * x1 + x2 * x2;
> >          } while ( w >= 1.0 );
> >
> >          w = sqrt( (-2.0 * ln( w ) ) / w );
> >          y1 = x1 * w;
> >          y2 = x2 * w;
> >
> > As the websites explains, ranf is a function to return a
> > random number in
> > the range [0, 1].  The problem is the number of calls that
> > occur to ranf.
> > There is the potential that a lot of calls would be made.
> > How would DGD
> > handle this?  How fast is the random generation function in DGD?
> >
>
> The area of the square in which the number is being uniformly
> generated is 4 (2 * 2).  The area of the circle in which the
> numbers are chosen is 3.14159... (pi * r**2).  So you have a
> better than 75% chance of getting your number first pop.
> This does the same thing as one version I posted before, only
> with the looping instead of a cos/sin...
>
> Ben.
>
> _________________________________________________________________
> List config page:  http://list.imaginary.com/mailman/listinfo/dgd
>

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list