Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RandomTools.hh File Reference
Include dependency graph for G4RandomTools.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

G4ThreeVector G4LambertianRand (const G4ThreeVector &normal)
 
G4ThreeVector G4PlaneVectorRand (const G4ThreeVector &normal)
 

Function Documentation

G4ThreeVector G4LambertianRand ( const G4ThreeVector normal)
inline

Definition at line 55 of file G4RandomTools.hh.

56 {
57  G4ThreeVector vect;
58  G4double ndotv;
59  G4int count=0;
60  const G4int max_trials = 1024;
61 
62  do
63  {
64  ++count;
65  vect = G4RandomDirection();
66  ndotv = normal * vect;
67 
68  if (ndotv < 0.0)
69  {
70  vect = -vect;
71  ndotv = -ndotv;
72  }
73 
74  } while (!(G4UniformRand() < ndotv) && (count < max_trials));
75 
76  return vect;
77 }
G4ThreeVector G4RandomDirection()
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4ThreeVector G4PlaneVectorRand ( const G4ThreeVector normal)
inline

Definition at line 82 of file G4RandomTools.hh.

83 {
84  G4ThreeVector vec1 = normal.orthogonal();
85  G4ThreeVector vec2 = vec1.cross(normal);
86 
88  G4double cosphi = std::cos(phi);
89  G4double sinphi = std::sin(phi);
90 
91  return cosphi * vec1 + sinphi * vec2;
92 }
#define G4UniformRand()
Definition: Randomize.hh:97
Hep3Vector orthogonal() const
Hep3Vector cross(const Hep3Vector &) const
double G4double
Definition: G4Types.hh:76
static constexpr double twopi
Definition: SystemOfUnits.h:55

Here is the call graph for this function: