|
Lines 91-94
inline G4ThreeVector G4PlaneVectorRand(const G4ThreeVector& normal)
Link Here
|
| 91 |
return cosphi * vec1 + sinphi * vec2; |
91 |
return cosphi * vec1 + sinphi * vec2; |
| 92 |
} |
92 |
} |
| 93 |
|
93 |
|
|
|
94 |
// --------------------------------------------------------------------------- |
| 95 |
// Choose a random vector in a cone with an angle between [0 , 2 pi] |
| 96 |
// |
| 97 |
|
| 98 |
inline G4ThreeVector G4RandomDirectionWithinACone(G4ThreeVector coneAxis, G4double coneAngle) |
| 99 |
{ |
| 100 |
// Creating a random vector inside a north poiting cone |
| 101 |
G4double zMin = cos(coneAngle/CLHEP::rad / 2.0); |
| 102 |
G4double zMax = 1.; |
| 103 |
G4double z = zMin + (zMax - zMin) * G4UniformRand(); |
| 104 |
|
| 105 |
G4double rho = sqrt((1.+z)*(1.-z)); // rho = sqrt(1-z*z) |
| 106 |
G4double phi = CLHEP::twopi*G4UniformRand(); |
| 107 |
|
| 108 |
G4ThreeVector rndDirection = G4ThreeVector(rho*cos(phi), rho*sin(phi), z); |
| 109 |
|
| 110 |
// Rotating the coneAxis by rndDirection |
| 111 |
return coneAxis.rotateUz(rndDirection); |
| 112 |
} |
| 113 |
|
| 94 |
#endif /* G4RANDOMTOOLS_HH */ |
114 |
#endif /* G4RANDOMTOOLS_HH */ |
| 95 |
- |
|
|