Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LineSection Class Reference

#include <G4LineSection.hh>

Public Member Functions

 G4LineSection (const G4ThreeVector &PntA, const G4ThreeVector &PntB)
 
G4double Dist (const G4ThreeVector &OtherPnt) const
 
G4double GetABdistanceSq () const
 

Static Public Member Functions

static G4double Distline (const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
 

Detailed Description

Definition at line 42 of file G4LineSection.hh.

Constructor & Destructor Documentation

◆ G4LineSection()

G4LineSection::G4LineSection ( const G4ThreeVector & PntA,
const G4ThreeVector & PntB )

Definition at line 33 of file G4LineSection.cc.

35 : EndpointA(PntA), VecAtoB(PntB-PntA)
36{
37 fABdistanceSq = VecAtoB.mag2();
38}
double mag2() const

Member Function Documentation

◆ Dist()

G4double G4LineSection::Dist ( const G4ThreeVector & OtherPnt) const

Definition at line 40 of file G4LineSection.cc.

41{
42 G4double dist_sq;
43 G4ThreeVector VecAZ;
44 G4double sq_VecAZ, inner_prod, unit_projection ;
45
46 VecAZ= OtherPnt - EndpointA;
47 sq_VecAZ = VecAZ.mag2();
48
49 inner_prod= VecAtoB.dot( VecAZ );
50
51 // Determine Projection(AZ on AB) / Length(AB)
52 //
53 if( fABdistanceSq != 0.0 )
54 {
55 // unit_projection= inner_prod * InvsqDistAB();
56 unit_projection = inner_prod/fABdistanceSq;
57
58 if( (0. <= unit_projection ) && (unit_projection <= 1.0 ) )
59 {
60 dist_sq= sq_VecAZ - unit_projection * inner_prod ;
61 }
62 else
63 {
64 // The perpendicular from the point to the line AB meets the line
65 // in a point outside the line segment!
66
67 if( unit_projection < 0. ) // A is the closest point
68 {
69 dist_sq= sq_VecAZ;
70 }
71 else // B is the closest point
72 {
73 G4ThreeVector EndpointB = EndpointA + VecAtoB;
74 G4ThreeVector VecBZ = OtherPnt - EndpointB;
75 dist_sq = VecBZ.mag2();
76 }
77 }
78 }
79 else
80 {
81 dist_sq = (OtherPnt - EndpointA).mag2() ;
82 }
83 if( dist_sq < 0.0 )
84 {
85 dist_sq = 0.0 ;
86 }
87
88 return std::sqrt(dist_sq) ;
89}
double G4double
Definition G4Types.hh:83
double dot(const Hep3Vector &) const

Referenced by Distline().

◆ Distline()

◆ GetABdistanceSq()

G4double G4LineSection::GetABdistanceSq ( ) const
inline

Definition at line 66 of file G4LineSection.hh.

67{
68 return fABdistanceSq;
69}

The documentation for this class was generated from the following files: