Geant4-11
Functions
G4INCL::IntersectionFactory::anonymous_namespace{G4INCLIntersection.hh} Namespace Reference

Functions

Intersection getTrajectoryIntersection (const ThreeVector &x0, const ThreeVector &v, const G4double r, const G4bool earliest)
 

Function Documentation

◆ getTrajectoryIntersection()

Intersection G4INCL::IntersectionFactory::anonymous_namespace{G4INCLIntersection.hh}::getTrajectoryIntersection ( const ThreeVector x0,
const ThreeVector v,
const G4double  r,
const G4bool  earliest 
)

Definition at line 104 of file G4INCLIntersection.hh.

104 {
105 const G4double scalarVelocity = v.mag();
106 ThreeVector velocityUnitVector = v / scalarVelocity;
107
108 ThreeVector positionTransverse = x0 - velocityUnitVector * x0.dot(velocityUnitVector);
109 const G4double impactParameter = positionTransverse.mag();
110
111 const G4double r2 = r*r;
112 G4double distanceZ2 = r2 - impactParameter * impactParameter;
113 if(distanceZ2 < 0.0)
114 return Intersection(false, 0.0, ThreeVector());
115
116 const G4double distanceZ = std::sqrt(distanceZ2);
117 const ThreeVector position = positionTransverse + velocityUnitVector * (earliest ? -distanceZ : distanceZ);
118 const G4double time = (position-x0).dot(velocityUnitVector)/scalarVelocity;
119 return Intersection(true, time, position);
120 }
double G4double
Definition: G4Types.hh:83
G4double mag() const
G4double dot(const ThreeVector &v) const
Intersection-point structure.

References G4INCL::ThreeVector::dot(), and G4INCL::ThreeVector::mag().

Referenced by G4INCL::IntersectionFactory::getEarlierTrajectoryIntersection(), G4INCL::IntersectionFactory::getLaterTrajectoryIntersection(), and G4INCL::IntersectionFactory::getTrajectoryIntersections().