Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RandomTools.hh File Reference

Go to the source code of this file.

Functions

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

Function Documentation

◆ G4LambertianRand()

G4ThreeVector G4LambertianRand ( const G4ThreeVector normal)
inline

Definition at line 55 of file G4RandomTools.hh.

56{
57 G4ThreeVector vect;
58 G4double ndotv;
59
60 do
61 {
62 vect = G4RandomDirection();
63 ndotv = normal * vect;
64
65 if (ndotv < 0.0)
66 {
67 vect = -vect;
68 ndotv = -ndotv;
69 }
70
71 } while (!(G4UniformRand() < ndotv));
72
73 return vect;
74}
G4ThreeVector G4RandomDirection()
double G4double
Definition: G4Types.hh:64
#define G4UniformRand()
Definition: Randomize.hh:53

◆ G4PlaneVectorRand()

G4ThreeVector G4PlaneVectorRand ( const G4ThreeVector normal)
inline

Definition at line 79 of file G4RandomTools.hh.

80{
81 G4ThreeVector vec1 = normal.orthogonal();
82 G4ThreeVector vec2 = vec1.cross(normal);
83
84 G4double phi = CLHEP::twopi*G4UniformRand();
85 G4double cosphi = std::cos(phi);
86 G4double sinphi = std::sin(phi);
87
88 return cosphi * vec1 + sinphi * vec2;
89}
Hep3Vector orthogonal() const
Hep3Vector cross(const Hep3Vector &) const