Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
rnorm.cpp
Go to the documentation of this file.
1#ifdef VISUAL_STUDIO
2#define _USE_MATH_DEFINES
3// see comment in math.h:
4/* Define _USE_MATH_DEFINES before including math.h to expose these macro
5 * definitions for common math constants. These are placed under an #ifdef
6 * since these commonly-defined names are not part of the C/C++ standards.
7 */
8#endif
9#include <cmath>
11
12namespace Heed {
13
14void rnorm_double(const double r1, const double r2, double &x1, double &x2) {
15 const double r = sqrt(-2.0 * log(r1));
16 const double fi = 2.0 * M_PI * r2;
17 x1 = r * cos(fi);
18 x2 = r * sin(fi);
19}
20
21void rnorm_float(const float r1, const float r2, float &x1, float &x2) {
22 const float r = sqrt(-2.0 * log(r1));
23 const float fi = 2.0 * M_PI * r2;
24 x1 = r * cos(fi);
25 x2 = r * sin(fi);
26}
27}
Definition: BGMesh.cpp:6
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:432
void rnorm_double(const double r1, const double r2, double &x1, double &x2)
Definition: rnorm.cpp:14
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:384
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
void rnorm_float(const float r1, const float r2, float &x1, float &x2)
Definition: rnorm.cpp:21