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

Ben Chambers bjchamb at bellsouth.net
Mon Jun 2 13:44:57 CEST 2003


DGD would require me to write a table of values for cos and sin... wouldn't
it?
----- Original Message -----
From: "White, Ben" <ben.white at dsto.defence.gov.au>
To: <dgd at list.imaginary.com>
Sent: Monday, June 02, 2003 2:13 AM
Subject: RE: [DGD] Damage Weapons and Stuff (Math and Code)


>
> You can generate gaussian distributed random numbers
> with the following (assuming randf() generates a
> uniformly distributed number between 0 and 1):
>
>   mag = sqrt (-2.0 * log10 (randf() + 1E-9));
>   phase = 2.0 * pi * randf();
>
>   x = mag * cos (phase);
>   y = mag * sin (phase);
>
> Both x and y will be normally distributed (mean 0,
> std. dev 1).
>
> Another version that some people use is to add up
> a whole bunch of uniformly distributed numbers.  It
> works out very nicely if you use 12 numbers.  Eg:
>
>   sum = 0.0;
>   for (i = 0; i < 12; i++) sum += randf();
>   x = sum - 6.0;
>
> Hope this helps.
> Ben White.
>
> _________________________________________________________________
> 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