Geant4  10.02
G4AffineTransform.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: G4AffineTransform.hh 93152 2015-10-08 11:53:57Z gcosmo $
28 //
29 //
30 // class G4AffineTransform
31 //
32 // Class description:
33 //
34 // A class for geometric affine transformations [see, eg. Foley & Van Dam]
35 // Supports efficient arbitrary rotation & transformation of vectors and the
36 // computation of compound & inverse transformations. A `rotation flag' is
37 // maintained internally for greater computational efficiency for transforms
38 // that do not involve rotation.
39 //
40 // Interfaces to the CLHEP classes G4ThreeVector & G4RotationMatrix
41 //
42 // For member function descriptions, see comments by declarations. For
43 // additional clarification, also check the `const' declarations for
44 // functions & their parameters.
45 //
46 // Member data:
47 //
48 // G4double rxx,rxy,rxz;
49 // G4double ryx,ryy,ryz; A 3x3 rotation matrix - net rotation
50 // G4double rzx,rzy,rzz;
51 // G4double tx,ty,tz; Net translation
52 
53 // History:
54 // Paul R C Kent 6 Aug 1996 - initial version
55 //
56 // 19.09.96 E.Chernyaev:
57 // - direct access to the protected members of the G4RotationMatrix class
58 // replaced by access via public access functions
59 // - conversion of the rotation matrix to angle & axis used to get
60 // a possibility to remove "friend" from the G4RotationMatrix class
61 // --------------------------------------------------------------------
62 #ifndef G4AFFINETRANSFORM_HH
63 #define G4AFFINETRANSFORM_HH
64 
65 #include "G4Types.hh"
66 #include "G4ThreeVector.hh"
67 #include "G4RotationMatrix.hh"
68 
70 {
71 
72 public:
73 
75 
76 public: // with description
77 
78  G4AffineTransform(const G4ThreeVector& tlate);
79  // Translation only: under t'form translate point at origin by tlate
80 
82  // Rotation only: under t'form rotate by rot
83 
85  const G4ThreeVector& tlate);
86  // Under t'form: rotate by rot then translate by tlate
87 
89  const G4ThreeVector& tlate);
90  // Optionally rotate by *rot then translate by tlate - rot may be null
91 
93  // Compound Transforms:
94  // tf2=tf2*tf1 equivalent to tf2*=tf1
95  // Returns compound transformation of self*tf
96 
98  // (Modifying) Multiplies self by tf; Returns self reference
99  // ie. A=AB for a*=b
100 
101 
103  const G4AffineTransform& tf2);
104  // 'Products' for avoiding (potential) temporaries:
105  // c.Product(a,b) equivalent to c=a*b
106  // c.InverseProduct(a*b,b ) equivalent to c=a
107  // (Modifying) Sets self=tf1*tf2; Returns self reference
108 
110  const G4AffineTransform& tf2);
111  // (Modifying) Sets self=tf1*(tf2^-1); Returns self reference
112 
113  G4ThreeVector TransformPoint(const G4ThreeVector& vec) const;
114  // Transform the specified point: returns vec*rot+tlate
115 
116  G4ThreeVector TransformAxis(const G4ThreeVector& axis) const;
117  // Transform the specified axis: returns
118 
119  void ApplyPointTransform(G4ThreeVector& vec) const;
120  // Transform the specified point (in place): sets vec=vec*rot+tlate
121 
122  void ApplyAxisTransform(G4ThreeVector& axis) const;
123  // Transform the specified axis (in place): sets axis=axis*rot;
124 
125  G4AffineTransform Inverse() const;
126  // Return inverse of current transform
127 
129  // (Modifying) Sets self=inverse of self; Returns self reference
130 
133  // (Modifying) Adjust net translation by given vector;
134  // Returns self reference
135 
136  G4bool operator == (const G4AffineTransform& tf) const;
137  G4bool operator != (const G4AffineTransform& tf) const;
138 
139  G4double operator [] (const G4int n) const;
140 
141  G4bool IsRotated() const;
142  // True if transform includes rotation
143 
144  G4bool IsTranslated() const;
145  // True if transform includes translation
146 
148 
150 
151  void SetNetRotation(const G4RotationMatrix& rot);
152 
153  void SetNetTranslation(const G4ThreeVector& tlate);
154 
155 private:
156 
157  G4AffineTransform(const G4double prxx,const G4double prxy,const G4double prxz,
158  const G4double pryx,const G4double pryy,const G4double pryz,
159  const G4double przx,const G4double przy,const G4double przz,
160  const G4double ptx, const G4double pty, const G4double ptz);
161 
166 };
167 
168 std::ostream& operator << (std::ostream& os, const G4AffineTransform& transf);
169 
170 #include "G4AffineTransform.icc"
171 
172 #endif
G4bool operator==(const G4AffineTransform &tf) const
G4AffineTransform & operator*=(const G4AffineTransform &tf)
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4AffineTransform Inverse() const
G4bool IsRotated() const
G4ThreeVector NetTranslation() const
void ApplyAxisTransform(G4ThreeVector &axis) const
int G4int
Definition: G4Types.hh:78
G4AffineTransform operator*(const G4AffineTransform &tf) const
G4AffineTransform & Invert()
G4AffineTransform & InverseProduct(const G4AffineTransform &tf1, const G4AffineTransform &tf2)
void SetNetTranslation(const G4ThreeVector &tlate)
void SetNetRotation(const G4RotationMatrix &rot)
std::ostream & operator<<(std::ostream &os, const G4AffineTransform &transf)
G4bool operator!=(const G4AffineTransform &tf) const
bool G4bool
Definition: G4Types.hh:79
G4bool IsTranslated() const
const G4int n
G4RotationMatrix NetRotation() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
G4AffineTransform & Product(const G4AffineTransform &tf1, const G4AffineTransform &tf2)
G4AffineTransform & operator+=(const G4ThreeVector &tlate)
double G4double
Definition: G4Types.hh:76
G4double operator[](const G4int n) const
G4AffineTransform & operator-=(const G4ThreeVector &tlate)
void ApplyPointTransform(G4ThreeVector &vec) const