Geant4-11
Public Member Functions | Static Public Member Functions | Private Attributes
G4LineSection Class Reference

#include <G4LineSection.hh>

Public Member Functions

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

Static Public Member Functions

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

Private Attributes

G4ThreeVector EndpointA
 
G4double fABdistanceSq = 0.0
 
G4ThreeVector VecAtoB
 

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{
38}
double mag2() const
G4ThreeVector VecAtoB
G4double fABdistanceSq
G4ThreeVector EndpointA

References fABdistanceSq, CLHEP::Hep3Vector::mag2(), and VecAtoB.

Member Function Documentation

◆ Dist()

G4double G4LineSection::Dist ( 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 ) dist_sq = 0.0 ;
84
85 return std::sqrt(dist_sq) ;
86}
double G4double
Definition: G4Types.hh:83
double dot(const Hep3Vector &) const

References CLHEP::Hep3Vector::dot(), EndpointA, fABdistanceSq, CLHEP::Hep3Vector::mag2(), and VecAtoB.

Referenced by Distline().

◆ Distline()

G4double G4LineSection::Distline ( const G4ThreeVector OtherPnt,
const G4ThreeVector LinePntA,
const G4ThreeVector LinePntB 
)
inlinestatic

◆ GetABdistanceSq()

G4double G4LineSection::GetABdistanceSq ( ) const
inline

Definition at line 66 of file G4LineSection.hh.

67{
68 return fABdistanceSq;
69}

References fABdistanceSq.

Field Documentation

◆ EndpointA

G4ThreeVector G4LineSection::EndpointA
private

Definition at line 58 of file G4LineSection.hh.

Referenced by Dist().

◆ fABdistanceSq

G4double G4LineSection::fABdistanceSq = 0.0
private

Definition at line 60 of file G4LineSection.hh.

Referenced by Dist(), G4LineSection(), and GetABdistanceSq().

◆ VecAtoB

G4ThreeVector G4LineSection::VecAtoB
private

Definition at line 59 of file G4LineSection.hh.

Referenced by Dist(), and G4LineSection().


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