diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/randgauss.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/randgauss.h | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/linden/indra/newview/randgauss.h b/linden/indra/newview/randgauss.h new file mode 100644 index 0000000..c5bddca --- /dev/null +++ b/linden/indra/newview/randgauss.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /** | ||
2 | * @file randgauss.h | ||
3 | * @brief randgauss class definition | ||
4 | * | ||
5 | * Copyright (c) 2003-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include <stdlib.h> // for rand() | ||
29 | |||
30 | const F32 table[][2] = { | ||
31 | {.00f, .5f}, | ||
32 | {.01f, .504f}, | ||
33 | {.02f, .508f}, | ||
34 | {.03f, .512f}, | ||
35 | {.06f, .5239f}, | ||
36 | {.08f, .5319f}, | ||
37 | {.11f, .5438f}, | ||
38 | {.13f, .5517f}, | ||
39 | {.16f, .5636f}, | ||
40 | {.18f, .5714f}, | ||
41 | {.21f, .5832f}, | ||
42 | {.23f, .5910f}, | ||
43 | {.26f, .6026f}, | ||
44 | {.28f, .6103f}, | ||
45 | {.31f, .6217f}, | ||
46 | {.34f, .6331f}, | ||
47 | {.36f, .6406f}, | ||
48 | {.39f, .6517f}, | ||
49 | {.42f, .6628f}, | ||
50 | {.44f, .6700f}, | ||
51 | {.47f, .6808f}, | ||
52 | {.50f, .6915f}, | ||
53 | {.53f, .7019f}, | ||
54 | {.56f, .7123f}, | ||
55 | {.59f, .7224f}, | ||
56 | {.62f, .7324f}, | ||
57 | {.65f, .7422f}, | ||
58 | {.68f, .7517f}, | ||
59 | {.71f, .7611f}, | ||
60 | {.74f, .7703f}, | ||
61 | {.78f, .7823f}, | ||
62 | {.81f, .7910f}, | ||
63 | {.85f, .8023f}, | ||
64 | {.88f, .8106f}, | ||
65 | {.92f, .8212f}, | ||
66 | {.96f, .8315f}, | ||
67 | {1.0f, .8413f}, | ||
68 | {1.04f, .8508f}, | ||
69 | {1.09f, .8621f}, | ||
70 | {1.13f, .8708f}, | ||
71 | {1.18f, .8810f}, | ||
72 | {1.23f, .8907f}, | ||
73 | {1.29f, .9015f}, | ||
74 | {1.35f, .9115f}, | ||
75 | {1.41f, .9207f}, | ||
76 | {1.48f, .9306f}, | ||
77 | {1.56f, .9406f}, | ||
78 | {1.65f, .9505f}, | ||
79 | {1.76f, .9608f}, | ||
80 | {1.89f, .9706f}, | ||
81 | {2.06f, .9803f}, | ||
82 | {2.33f, .9901f}, | ||
83 | {99.0f, 1.0f}}; | ||
84 | |||
85 | inline F32 randGauss(F32 mean, F32 stdev) | ||
86 | { | ||
87 | S32 i = 0; | ||
88 | F32 u = rand() / (F32) RAND_MAX; | ||
89 | F32 n; | ||
90 | |||
91 | if (u >= 0.5) | ||
92 | { | ||
93 | while (u > table[i][1]) | ||
94 | i++; | ||
95 | |||
96 | n = table[i-1][0]; | ||
97 | |||
98 | } else { | ||
99 | u = 1 - u; | ||
100 | while (u > table[i][1]) | ||
101 | i++; | ||
102 | n = 1 - table[i-1][0]; | ||
103 | } | ||
104 | //printf("u: %f, n: %f, i: %d\n", u, n, i); //debug | ||
105 | |||
106 | return (mean + stdev * n); | ||
107 | } | ||
108 | |||