#include <CLHEP/Units/PhysicalConstants.h>
#include "globals.hh"
#include "Randomize.hh"
#include "G4RandomDirection.hh"
Go to the source code of this file.
Functions | |
G4ThreeVector | G4LambertianRand (const G4ThreeVector &normal) |
G4ThreeVector | G4PlaneVectorRand (const G4ThreeVector &normal) |
G4ThreeVector G4LambertianRand | ( | const G4ThreeVector & | normal | ) | [inline] |
Definition at line 55 of file G4RandomTools.hh.
References G4RandomDirection(), and G4UniformRand.
00056 { 00057 G4ThreeVector vect; 00058 G4double ndotv; 00059 00060 do 00061 { 00062 vect = G4RandomDirection(); 00063 ndotv = normal * vect; 00064 00065 if (ndotv < 0.0) 00066 { 00067 vect = -vect; 00068 ndotv = -ndotv; 00069 } 00070 00071 } while (!(G4UniformRand() < ndotv)); 00072 00073 return vect; 00074 }
G4ThreeVector G4PlaneVectorRand | ( | const G4ThreeVector & | normal | ) | [inline] |
Definition at line 79 of file G4RandomTools.hh.
References G4UniformRand.
00080 { 00081 G4ThreeVector vec1 = normal.orthogonal(); 00082 G4ThreeVector vec2 = vec1.cross(normal); 00083 00084 G4double phi = CLHEP::twopi*G4UniformRand(); 00085 G4double cosphi = std::cos(phi); 00086 G4double sinphi = std::sin(phi); 00087 00088 return cosphi * vec1 + sinphi * vec2; 00089 }