Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-29 09:09:30

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 // G4ScaleTransform
0027 //
0028 // Class description:
0029 //
0030 // A class for geometric scaling transformations.
0031 // Supports efficient arbitrary transformation of points, vectors and
0032 // normals and the computation of compound & inverse transformations.
0033 //
0034 // Interfaces to the CLHEP class G4ThreeVector
0035 //
0036 // For member function descriptions, see comments by declarations. For
0037 // additional clarification, also check the `const' declarations for
0038 // functions & their parameters.
0039 //
0040 // Member data:
0041 //
0042 //    G4ThreeVector fScale;  // scale transformation 
0043 //    G4ThreeVector fIScale; // inverse scale (avoid divisions)
0044 //    G4double flFactor;     // factor for conversion to local frame
0045 //    G4double fgFactor;     // factor for conversion to global frame
0046 
0047 // Author: Gabriele Cosmo (CERN), 18.02.2016 - Initial version
0048 //         Evgueni Tcherniaev (CERN), 11.03.2016 - Added normals transforms
0049 // --------------------------------------------------------------------
0050 #ifndef G4SCALETRANSFORM_HH
0051 #define G4SCALETRANSFORM_HH
0052 
0053 #include "G4Types.hh"
0054 #include "G4ThreeVector.hh"
0055 #include "G4Transform3D.hh"
0056 
0057 /**
0058  * @brief G4ScaleTransform is a class for geometric scaling transformations.
0059  * It supports efficient arbitrary transformation of points, vectors and
0060  * normals and the computation of compound and inverse transformations.
0061  */
0062 
0063 class G4ScaleTransform
0064 {
0065   public:
0066 
0067     /**
0068      * Default Constructor.
0069      */
0070     inline G4ScaleTransform();
0071     
0072     /**
0073      * Constructor with scale parameters on each axis.
0074      *  @param[in] sx Scaling in X.
0075      *  @param[in] sy Scaling in Y.
0076      *  @param[in] sz Scaling in Z.
0077      */
0078     inline G4ScaleTransform(G4double sx, G4double sy, G4double sz);
0079 
0080     /**
0081      * Constructor taking a 3-vector.
0082      *  @param[in] scale Scaling transformation.
0083      */
0084     inline G4ScaleTransform(const G4ThreeVector& scale);
0085 
0086     /**
0087      * Constructor taking a Scale3D.
0088      *  @param[in] scale Scaling transformation.
0089      */
0090     inline G4ScaleTransform(const G4Scale3D& scale);
0091         
0092     /**
0093      * Copy constructor and assignment operator.
0094      */
0095     inline G4ScaleTransform(const G4ScaleTransform& right);
0096     inline G4ScaleTransform& operator=(const G4ScaleTransform& right);
0097 
0098     /**
0099      * Updates the backed-up inverse scale and special conversion factors
0100      * based on the values of the scale. Needed at initialisation and
0101      * whenever the scale has changed value.
0102      */
0103     inline void Init();
0104 
0105     /**
0106      * Accessors returning a reference to the scale and inverse scale
0107      * transformations.
0108      */
0109     inline const G4ThreeVector& GetScale() const;
0110     inline const G4ThreeVector& GetInvScale() const;
0111  
0112     /**
0113      * Modifiers for the scale transformation.
0114      */
0115     inline void SetScale(const G4ThreeVector& scale);
0116     inline void SetScale(const G4Scale3D& scale);
0117     inline void SetScale(G4double sx, G4double sy, G4double sz);
0118 
0119     /**
0120      * Methods to transform a point from global to local frame.
0121      */
0122     inline void Transform(const G4ThreeVector& global,
0123                                 G4ThreeVector& local) const;  
0124     inline G4ThreeVector Transform(const G4ThreeVector& global) const;
0125 
0126     /**
0127      * Methods to transform a point from local to global frame.
0128      */
0129     inline void InverseTransform(const G4ThreeVector& local, 
0130                                        G4ThreeVector& global) const;
0131     inline G4ThreeVector InverseTransform(const G4ThreeVector& local) const;
0132 
0133     /**
0134      * Methods to transform a normal from global to local frame.
0135      */
0136     inline void TransformNormal(const G4ThreeVector& global,
0137                                       G4ThreeVector& local) const;  
0138     inline G4ThreeVector TransformNormal(const G4ThreeVector& global) const;
0139 
0140     /**
0141      * Methods to transform a normal from local to global frame.
0142      */
0143     inline void InverseTransformNormal(const G4ThreeVector& local, 
0144                                              G4ThreeVector& global) const;
0145     inline G4ThreeVector InverseTransformNormal(const G4ThreeVector& local) const;
0146 
0147     /**
0148      * Transforms a distance 'dist' along a given direction 'dir'
0149      * from global to local frame.
0150      */
0151     inline G4double TransformDistance(G4double dist,
0152                                       const G4ThreeVector& dir) const;
0153 
0154     /**
0155      * Transforms a 'safety' distance from global to local frame (conservative).
0156      */
0157     inline G4double TransformDistance(G4double safety) const;
0158 
0159     /**
0160      * Transforms a distance 'dist' along a given direction 'dir'
0161      * from local to global frame.
0162      */
0163     inline G4double InverseTransformDistance(G4double dist,
0164                                              const G4ThreeVector& dir) const;
0165 
0166     /**
0167      * Transforms a 'safety' distance from local to global frame (conservative).
0168      */
0169     inline G4double InverseTransformDistance(G4double safety) const;
0170 
0171   private:
0172 
0173     G4ThreeVector fScale;  // scale transformation 
0174     G4ThreeVector fIScale; // inverse scale (avoid divisions)
0175 
0176     /** Conversion factors to local/global frames. */
0177     G4double flFactor = 1.0, fgFactor = 1.0;
0178 };
0179 
0180 std::ostream& operator<<(std::ostream& os, const G4ScaleTransform& scale);
0181 
0182 #include "G4ScaleTransform.icc"
0183 
0184 #endif