ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AffineTransform.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4AffineTransform.hh
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 // class G4AffineTransform
27 //
28 // Class description:
29 //
30 // A class for geometric affine transformations [see, eg. Foley & Van Dam]
31 // Supports efficient arbitrary rotation & transformation of vectors and the
32 // computation of compound & inverse transformations. A `rotation flag' is
33 // maintained internally for greater computational efficiency for transforms
34 // that do not involve rotation.
35 //
36 // Interfaces to the CLHEP classes G4ThreeVector & G4RotationMatrix
37 //
38 // For member function descriptions, see comments by declarations. For
39 // additional clarification, also check the `const' declarations for
40 // functions & their parameters.
41 //
42 // Member data:
43 //
44 // G4double rxx,rxy,rxz;
45 // G4double ryx,ryy,ryz; A 3x3 rotation matrix - net rotation
46 // G4double rzx,rzy,rzz;
47 // G4double tx,ty,tz; Net translation
48 
49 // 06.08.1996 Paul R C Kent:
50 // - initial version
51 // 19.09.1996 E.Tcherniaev:
52 // - direct access to the protected members of the G4RotationMatrix class
53 // replaced by access via public access functions
54 // - conversion of the rotation matrix to angle & axis used to get
55 // a possibility to remove "friend" from the G4RotationMatrix class
56 // 06.05.2018 E.Tcherniaev:
57 // - optimized InverseProduct
58 // - added methods for inverse transformation: InverseTrasformPoint,
59 // InverseTransformAxis, InverseNetRotation, InverseNetTranslation
60 // --------------------------------------------------------------------
61 #ifndef G4AFFINETRANSFORM_HH
62 #define G4AFFINETRANSFORM_HH
63 
64 #include "G4Types.hh"
65 #include "G4ThreeVector.hh"
66 #include "G4RotationMatrix.hh"
67 #include "G4Transform3D.hh"
68 
70 {
71  public:
72 
73  inline G4AffineTransform();
74 
75  public: // with description
76 
77  inline G4AffineTransform(const G4ThreeVector& tlate);
78  // Translation only: under t'form translate point at origin by tlate
79 
80  inline G4AffineTransform(const G4RotationMatrix& rot);
81  // Rotation only: under t'form rotate by rot
82 
83  inline G4AffineTransform(const G4RotationMatrix& rot,
84  const G4ThreeVector& tlate);
85  // Under t'form: rotate by rot then translate by tlate
86 
87  inline G4AffineTransform(const G4RotationMatrix* rot,
88  const G4ThreeVector& tlate);
89  // Optionally rotate by *rot then translate by tlate - rot may be null
90 
91  inline G4AffineTransform(const G4AffineTransform& rhs);
92  inline G4AffineTransform(G4AffineTransform&& rhs) = default;
93  // Copy and move constructors
94 
95  inline G4AffineTransform& operator=(const G4AffineTransform& rhs);
96  inline G4AffineTransform& operator=(G4AffineTransform&& rhs) = default;
97  // Assignment & Move operators
98 
99  inline ~G4AffineTransform();
100  // Destructor
101 
102  inline G4AffineTransform operator * (const G4AffineTransform& tf) const;
103  // Compound Transforms:
104  // tf2=tf2*tf1 equivalent to tf2*=tf1
105  // Returns compound transformation of self*tf
106 
108  // (Modifying) Multiplies self by tf; Returns self reference
109  // ie. A=AB for a*=b
110 
111  inline G4AffineTransform& Product(const G4AffineTransform& tf1,
112  const G4AffineTransform& tf2);
113  // 'Products' for avoiding (potential) temporaries:
114  // c.Product(a,b) equivalent to c=a*b
115  // c.InverseProduct(a*b,b ) equivalent to c=a
116  // (Modifying) Sets self=tf1*tf2; Returns self reference
117 
119  const G4AffineTransform& tf2);
120  // (Modifying) Sets self=tf1*(tf2^-1); Returns self reference
121 
122  inline G4ThreeVector TransformPoint(const G4ThreeVector& vec) const;
123  // Transform the specified point: returns vec*rot+tlate
124 
125  inline G4ThreeVector InverseTransformPoint(const G4ThreeVector& vec) const;
126  // Transform the specified point using inverse transformation
127 
128  inline G4ThreeVector TransformAxis(const G4ThreeVector& axis) const;
129  // Transform the specified axis: returns vec*rot
130 
131  inline G4ThreeVector InverseTransformAxis(const G4ThreeVector& axis) const;
132  // Transform the specified axis using inverse transfromation
133 
134  inline void ApplyPointTransform(G4ThreeVector& vec) const;
135  // Transform the specified point (in place): sets vec=vec*rot+tlate
136 
137  inline void ApplyAxisTransform(G4ThreeVector& axis) const;
138  // Transform the specified axis (in place): sets axis=axis*rot;
139 
140  inline G4AffineTransform Inverse() const;
141  // Return inverse of current transform
142 
143  inline G4AffineTransform& Invert();
144  // (Modifying) Sets self=inverse of self; Returns self reference
145 
146  inline G4AffineTransform& operator +=(const G4ThreeVector& tlate);
147  inline G4AffineTransform& operator -=(const G4ThreeVector& tlate);
148  // (Modifying) Adjust net translation by given vector;
149  // Returns self reference
150 
151  inline G4bool operator == (const G4AffineTransform& tf) const;
152  inline G4bool operator != (const G4AffineTransform& tf) const;
153 
154  inline G4double operator [] (const G4int n) const;
155 
156  inline G4bool IsRotated() const;
157  // True if transform includes rotation
158 
159  inline G4bool IsTranslated() const;
160  // True if transform includes translation
161 
162  inline G4RotationMatrix NetRotation() const;
163 
164  inline G4RotationMatrix InverseNetRotation() const;
165 
166  inline G4ThreeVector NetTranslation() const;
167 
168  inline G4ThreeVector InverseNetTranslation() const;
169 
170  inline void SetNetRotation(const G4RotationMatrix& rot);
171 
172  inline void SetNetTranslation(const G4ThreeVector& tlate);
173 
174  inline operator G4Transform3D () const;
175  // Conversion operator (cast) to G4Transform3D
176 
177  private:
178 
179  inline G4AffineTransform(
180  const G4double prxx, const G4double prxy, const G4double prxz,
181  const G4double pryx, const G4double pryy, const G4double pryz,
182  const G4double przx, const G4double przy, const G4double przz,
183  const G4double ptx, const G4double pty, const G4double ptz);
184 
189 };
190 
191 std::ostream& operator << (std::ostream& os, const G4AffineTransform& transf);
192 
193 #include "G4AffineTransform.icc"
194 
195 #endif