Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LineSection Class Reference

#include <G4LineSection.hh>

Public Member Functions

 G4LineSection (const G4ThreeVector &PntA, const G4ThreeVector &PntB)
 
G4double Dist (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 47 of file G4LineSection.hh.

Constructor & Destructor Documentation

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

Definition at line 70 of file G4LineSection.hh.

72  : EndpointA(PntA), VecAtoB(PntB-PntA)
73 {
74  fABdistanceSq = VecAtoB.mag2();
75 }
double mag2() const

Here is the call graph for this function:

Member Function Documentation

G4double G4LineSection::Dist ( G4ThreeVector  OtherPnt) const

Definition at line 33 of file G4LineSection.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 84 of file G4LineSection.hh.

87 {
88  G4LineSection LineAB( LinePntA, LinePntB ); // Line from A to B
89  return LineAB.Dist( OtherPnt );
90 }

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4LineSection::GetABdistanceSq ( ) const
inline

Definition at line 78 of file G4LineSection.hh.

79 {
80  return fABdistanceSq;
81 }

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