Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RandomDirection.hh File Reference
#include <CLHEP/Units/PhysicalConstants.h>
#include "globals.hh"
#include "Randomize.hh"
#include "G4ThreeVector.hh"
Include dependency graph for G4RandomDirection.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

G4ThreeVector G4RandomDirection ()
 

Function Documentation

G4ThreeVector G4RandomDirection ( )
inline

Definition at line 56 of file G4RandomDirection.hh.

57 {
58  G4double z = 2.*G4UniformRand() - 1.; // z = cos(theta)
59  G4double rho = std::sqrt((1.+z)*(1.-z)); // rho = sqrt(1-z*z)
61  return G4ThreeVector(rho*std::cos(phi), rho*std::sin(phi), z);
62 }
CLHEP::Hep3Vector G4ThreeVector
#define G4UniformRand()
Definition: Randomize.hh:97
tuple z
Definition: test.py:28
double G4double
Definition: G4Types.hh:76
static constexpr double twopi
Definition: SystemOfUnits.h:55

Here is the caller graph for this function: