Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ScaleTransform.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id:$
28 //
29 //
30 // class G4ScaleTransform
31 //
32 // Class description:
33 //
34 // A class for geometric scaling transformations.
35 // Supports efficient arbitrary transformation of points, vectors and
36 // normals and the computation of compound & inverse transformations.
37 //
38 // Interfaces to the CLHEP class G4ThreeVector
39 //
40 // For member function descriptions, see comments by declarations. For
41 // additional clarification, also check the `const' declarations for
42 // functions & their parameters.
43 //
44 // Member data:
45 //
46 // G4ThreeVector fScale; // scale transformation
47 // G4ThreeVector fIScale; // inverse scale (avoid divisions)
48 // G4double flFactor; // factor for conversion to local frame
49 // G4double fgFactor; // factor for conversion to global frame
50 
51 // History:
52 // E.Tcherniaev 11 Mar 2016 - added transformations for normal
53 // G.Cosmo 18 Feb 2016 - initial version
54 //
55 // --------------------------------------------------------------------
56 #ifndef G4SCALETRANSFORM_HH
57 #define G4SCALETRANSFORM_HH
58 
59 #include "G4Types.hh"
60 #include "G4ThreeVector.hh"
61 #include "G4Transform3D.hh"
62 
64 {
65 
66  public:
67 
68  inline G4ScaleTransform();
69  // Default constructor
70 
71  inline G4ScaleTransform(G4double sx, G4double sy, G4double sz);
72  // Constructor with scale parameters on each axis
73 
74  inline G4ScaleTransform(const G4ThreeVector& scale);
75  // Constructor taking a 3-vector
76 
77  inline G4ScaleTransform(const G4Scale3D& scale);
78  // Constructor taking a Scale3D
79 
80  inline G4ScaleTransform(const G4ScaleTransform& right);
81  // Copy constructor
82 
83  inline G4ScaleTransform& operator=(const G4ScaleTransform& right);
84  // Assignment operator
85 
86  inline void Init();
87  // Update the backed-up inverse scale and special conversion factors
88  // based on the values of the scale. Needed at initialisation and
89  // whenever the scale has changed value
90 
91  inline const G4ThreeVector& GetScale() const;
92  inline const G4ThreeVector& GetInvScale() const;
93  // Get reference to the inverse scale transformation
94 
95  inline void SetScale(const G4ThreeVector& scale);
96  // Set scale based on vector
97  inline void SetScale(const G4Scale3D& scale);
98  // Set scale based on a G4Scale3D transformation
99  inline void SetScale(G4double sx, G4double sy, G4double sz);
100  // Set scale based on values
101 
102  inline void Transform(const G4ThreeVector& global,
103  G4ThreeVector& local) const;
104  inline G4ThreeVector Transform(const G4ThreeVector& global) const;
105  // Transform point from global to local frame
106 
107  inline void InverseTransform(const G4ThreeVector& local,
108  G4ThreeVector& global) const;
109  inline G4ThreeVector InverseTransform(const G4ThreeVector& local) const;
110  // Transform point from local to global frame
111 
112  inline void TransformNormal(const G4ThreeVector& global,
113  G4ThreeVector& local) const;
114  inline G4ThreeVector TransformNormal(const G4ThreeVector& global) const;
115  // Transform normal from global to local frame
116 
117  inline void InverseTransformNormal(const G4ThreeVector& local,
118  G4ThreeVector& global) const;
119  inline G4ThreeVector InverseTransformNormal(const G4ThreeVector& local) const;
120  // Transform normal from local to global frame
121 
122  inline G4double TransformDistance(G4double dist,
123  const G4ThreeVector& dir) const;
124  // Transform distance along given direction from global to local frame
125 
126  inline G4double TransformDistance(G4double safety) const;
127  // Transform distance from global to local frame (conservative)
128 
130  const G4ThreeVector& dir) const;
131  // Transform distance along given direction from local to global frame
132 
133  inline G4double InverseTransformDistance(G4double safety) const;
134  // Transform distance from local to global frame (conservative)
135 
136  private:
137 
138  G4ThreeVector fScale; // scale transformation
139  G4ThreeVector fIScale; // inverse scale (avoid divisions)
140  G4double flFactor, fgFactor; // conversion factors to local/global frames
141 
142 }; // End class G4ScaleTransform
143 
144 std::ostream& operator<<(std::ostream& os, const G4ScaleTransform& scale);
145 
146 #include "G4ScaleTransform.icc"
147 
148 #endif // G4SCALETRANSFORM_HH
G4double InverseTransformDistance(G4double dist, const G4ThreeVector &dir) const
void TransformNormal(const G4ThreeVector &global, G4ThreeVector &local) const
const G4ThreeVector & GetScale() const
void InverseTransformNormal(const G4ThreeVector &local, G4ThreeVector &global) const
#define local
Definition: adler32.cc:10
void Transform(const G4ThreeVector &global, G4ThreeVector &local) const
void InverseTransform(const G4ThreeVector &local, G4ThreeVector &global) const
G4double TransformDistance(G4double dist, const G4ThreeVector &dir) const
const G4ThreeVector & GetInvScale() const
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
G4ScaleTransform & operator=(const G4ScaleTransform &right)
void SetScale(const G4ThreeVector &scale)
double G4double
Definition: G4Types.hh:76