Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RandomDirection.hh 96120 2016-03-16 20:29:21Z gcosmo $
|
||||
// $Id: G4RandomDirection.hh 103484 2017-04-11 08:31:44Z gcosmo $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
@@ -39,6 +39,7 @@
|
||||
// providing more performant results.
|
||||
|
||||
// History:
|
||||
// 06.04.17 E. Tcherniaev, added G4RandomDirection(cosTheta)
|
||||
// 15.03.16 E. Tcherniaev, removed unnecessary if and unit()
|
||||
// 18.03.08 V. Grichine, unit radius sphere surface based algorithm
|
||||
// ~ 2007 M. Kossov, algorithm based on 8 Quadrants technique
|
||||
@@ -61,4 +62,12 @@ inline G4ThreeVector G4RandomDirection()
|
||||
return G4ThreeVector(rho*std::cos(phi), rho*std::sin(phi), z);
|
||||
}
|
||||
|
||||
inline G4ThreeVector G4RandomDirection(G4double cosTheta)
|
||||
{
|
||||
G4double z = (1. - cosTheta)*G4UniformRand() + cosTheta;
|
||||
G4double rho = std::sqrt((1.+z)*(1.-z));
|
||||
G4double phi = CLHEP::twopi*G4UniformRand();
|
||||
return G4ThreeVector(rho*std::cos(phi), rho*std::sin(phi), z);
|
||||
}
|
||||
|
||||
#endif /* G4RANDOMDIR_HH */
|
||||
|
||||
Reference in New Issue
Block a user