Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:10:20

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4LineSection
0027 //
0028 // Class description:
0029 //
0030 // A utility class that calculates the distance of a point from a 
0031 // line section.
0032 
0033 // Author: John Apostolakis (CERN), 1999
0034 // --------------------------------------------------------------------
0035 
0036 #ifndef G4LineSection_hh
0037 #define G4LineSection_hh
0038 
0039 #include "G4Types.hh" 
0040 #include "G4ThreeVector.hh"
0041 
0042 /**
0043  * @brief G4LineSection is a utility class that calculates the distance
0044  * of a point from a line section.
0045  */
0046 
0047 class G4LineSection
0048 {
0049   public:
0050 
0051     /**
0052      * Constructor for G4LineSection.
0053      *  @param[in] PntA Coordinates of point A defining the line.
0054      *  @param[in] PntB Coordinates of point B defining the line.
0055      */
0056     G4LineSection( const G4ThreeVector& PntA,
0057                    const G4ThreeVector& PntB );
0058 
0059     /**
0060      * Default Destructor.
0061      */
0062     ~G4LineSection() = default;
0063 
0064     /**
0065      * Returns the distance of point 'OtherPnt' from the line.
0066      */
0067     G4double Dist( const G4ThreeVector& OtherPnt ) const;
0068 
0069     /**
0070      * Returns the distance squared.
0071      */
0072     inline G4double GetABdistanceSq() const;
0073 
0074     /**
0075      * Defines line and returns the distance of point 'OtherPnt' from it.
0076      */
0077     inline static G4double Distline( const G4ThreeVector& OtherPnt, 
0078                                      const G4ThreeVector& LinePntA, 
0079                                      const G4ThreeVector& LinePntB );
0080   private:
0081 
0082     G4ThreeVector EndpointA;
0083     G4ThreeVector VecAtoB;
0084     G4double fABdistanceSq = 0.0;
0085 };
0086 
0087 // Inline methods implementations
0088 
0089 inline
0090 G4double G4LineSection::GetABdistanceSq() const
0091 {
0092   return fABdistanceSq;
0093 }
0094 
0095 inline
0096 G4double G4LineSection::Distline( const G4ThreeVector& OtherPnt, 
0097                                   const G4ThreeVector& LinePntA, 
0098                                   const G4ThreeVector& LinePntB )
0099 {
0100   G4LineSection LineAB( LinePntA, LinePntB );  // Line from A to B
0101   return LineAB.Dist( OtherPnt );
0102 }
0103 
0104 #endif