Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:52

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 // class G4AffineTransform
0027 //
0028 // Class description:
0029 //
0030 // A class for geometric affine transformations [see, eg. Foley & Van Dam]
0031 // Supports efficient arbitrary rotation & transformation of vectors and the
0032 // computation of compound & inverse transformations. A `rotation flag' is
0033 // maintained internally for greater computational efficiency for transforms
0034 // that do not involve rotation.
0035 //
0036 // Interfaces to the CLHEP classes G4ThreeVector & G4RotationMatrix
0037 //
0038 // For member function descriptions, see comments by declarations. For
0039 // additional clarification, also check the `const' declarations for
0040 // functions & their parameters.
0041 //
0042 // Member data:
0043 //
0044 //      G4double rxx,rxy,rxz; 
0045 //      G4double ryx,ryy,ryz;  A 3x3 rotation matrix - net rotation
0046 //      G4double rzx,rzy,rzz;
0047 //      G4double tx,ty,tz;     Net translation 
0048 
0049 // 06.08.1996 Paul R C Kent:
0050 // - initial version
0051 // 19.09.1996 E.Tcherniaev:
0052 // - direct access to the protected members of the G4RotationMatrix class
0053 //   replaced by access via public access functions
0054 // - conversion of the rotation matrix to angle & axis used to get
0055 //   a possibility to remove "friend" from the G4RotationMatrix class
0056 // 06.05.2018 E.Tcherniaev:
0057 // - optimized InverseProduct
0058 // - added methods for inverse transformation: InverseTrasformPoint,  
0059 //   InverseTransformAxis, InverseNetRotation, InverseNetTranslation
0060 // --------------------------------------------------------------------
0061 #ifndef G4AFFINETRANSFORM_HH
0062 #define G4AFFINETRANSFORM_HH
0063 
0064 #include "G4Types.hh"
0065 #include "G4ThreeVector.hh"
0066 #include "G4RotationMatrix.hh"
0067 #include "G4Transform3D.hh"
0068 
0069 class G4AffineTransform
0070 {
0071   public:
0072 
0073     inline G4AffineTransform();
0074 
0075   public: // with description
0076 
0077     inline G4AffineTransform(const G4ThreeVector& tlate);
0078       // Translation only: under t'form translate point at origin by tlate
0079 
0080     inline G4AffineTransform(const G4RotationMatrix& rot);
0081       // Rotation only: under t'form rotate by rot
0082 
0083     inline G4AffineTransform(const G4RotationMatrix& rot,
0084                              const G4ThreeVector& tlate);
0085       // Under t'form: rotate by rot then translate by tlate
0086 
0087     inline G4AffineTransform(const G4RotationMatrix* rot,
0088                              const G4ThreeVector& tlate);
0089       // Optionally rotate by *rot then translate by tlate - rot may be null
0090 
0091     inline G4AffineTransform(const G4AffineTransform& rhs) = default;
0092     inline G4AffineTransform(G4AffineTransform&& rhs) = default;
0093       // Copy and move constructors
0094 
0095     inline G4AffineTransform& operator=(const G4AffineTransform& rhs);
0096     inline G4AffineTransform& operator=(G4AffineTransform&& rhs) = default;
0097       // Assignment & Move operators
0098 
0099     inline ~G4AffineTransform() = default;
0100       // Destructor
0101 
0102     inline G4AffineTransform operator * (const G4AffineTransform& tf) const;
0103       // Compound Transforms:
0104       //       tf2=tf2*tf1 equivalent to tf2*=tf1
0105       //       Returns compound transformation of self*tf
0106 
0107     inline G4AffineTransform& operator *= (const G4AffineTransform& tf);
0108       // (Modifying) Multiplies self by tf; Returns self reference
0109       //             ie. A=AB for a*=b
0110 
0111     inline G4AffineTransform& Product(const G4AffineTransform& tf1,
0112                                       const G4AffineTransform& tf2);
0113       // 'Products' for avoiding (potential) temporaries:
0114       //            c.Product(a,b) equivalent to c=a*b
0115       //            c.InverseProduct(a*b,b ) equivalent to c=a
0116       // (Modifying) Sets self=tf1*tf2; Returns self reference
0117 
0118     inline G4AffineTransform& InverseProduct(const G4AffineTransform& tf1,
0119                                              const G4AffineTransform& tf2);
0120       // (Modifying) Sets self=tf1*(tf2^-1); Returns self reference
0121 
0122     inline G4ThreeVector TransformPoint(const G4ThreeVector& vec) const;
0123       // Transform the specified point: returns vec*rot+tlate
0124 
0125     inline G4ThreeVector InverseTransformPoint(const G4ThreeVector& vec) const;
0126       // Transform the specified point using inverse transformation
0127 
0128     inline G4ThreeVector TransformAxis(const G4ThreeVector& axis) const;
0129       // Transform the specified axis: returns vec*rot
0130 
0131     inline G4ThreeVector InverseTransformAxis(const G4ThreeVector& axis) const;
0132       // Transform the specified axis using inverse transfromation
0133 
0134     inline void ApplyPointTransform(G4ThreeVector& vec) const;
0135       // Transform the specified point (in place): sets vec=vec*rot+tlate
0136 
0137     inline void ApplyAxisTransform(G4ThreeVector& axis) const;
0138       // Transform the specified axis (in place): sets axis=axis*rot;
0139 
0140     inline G4AffineTransform Inverse() const;
0141       // Return inverse of current transform
0142 
0143     inline G4AffineTransform& Invert();
0144       // (Modifying) Sets self=inverse of self; Returns self reference
0145 
0146     inline G4AffineTransform& operator +=(const G4ThreeVector& tlate);
0147     inline G4AffineTransform& operator -=(const G4ThreeVector& tlate);
0148       // (Modifying) Adjust net translation by given vector;
0149       //             Returns self reference
0150 
0151     inline G4bool operator == (const G4AffineTransform& tf) const;
0152     inline G4bool operator != (const G4AffineTransform& tf) const;
0153 
0154     inline G4double operator [] (const G4int n) const;
0155 
0156     inline G4bool IsRotated() const;
0157       // True if transform includes rotation
0158 
0159     inline G4bool IsTranslated() const;
0160       // True if transform includes translation
0161 
0162     inline G4RotationMatrix NetRotation() const;
0163 
0164     inline G4RotationMatrix InverseNetRotation() const;
0165 
0166     inline G4ThreeVector NetTranslation() const;
0167 
0168     inline G4ThreeVector InverseNetTranslation() const;
0169 
0170     inline void SetNetRotation(const G4RotationMatrix& rot);
0171 
0172     inline void SetNetTranslation(const G4ThreeVector& tlate);
0173 
0174     inline operator G4Transform3D () const;
0175       // Conversion operator (cast) to G4Transform3D
0176 
0177   private:
0178 
0179     inline G4AffineTransform(
0180                   const G4double prxx, const G4double prxy, const G4double prxz,
0181                   const G4double pryx, const G4double pryy, const G4double pryz,
0182                   const G4double przx, const G4double przy, const G4double przz,
0183                   const G4double ptx, const G4double pty, const G4double ptz);
0184 
0185     G4double rxx,rxy,rxz;
0186     G4double ryx,ryy,ryz;
0187     G4double rzx,rzy,rzz;
0188     G4double tx,ty,tz;
0189 };
0190 
0191 std::ostream& operator << (std::ostream& os, const G4AffineTransform& transf);
0192 
0193 #include "G4AffineTransform.icc"
0194 
0195 #endif