Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// 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// Author: Paul R C Kent (CERN), 06.08.1996 - Initial version
50// E.Tcherniaev (CERN), 19.09.1996, 06.05.2018 - Revised
51// --------------------------------------------------------------------
52#ifndef G4AFFINETRANSFORM_HH
53#define G4AFFINETRANSFORM_HH
54
55#include "G4Types.hh"
56#include "G4ThreeVector.hh"
57#include "G4RotationMatrix.hh"
58#include "G4Transform3D.hh"
59
60/**
61 * @brief G4AffineTransform is a class for geometric affine transformations.
62 * It supports efficient arbitrary rotation & transformation of vectors and
63 * the computation of compound & inverse transformations. A 'rotation flag'
64 * is maintained internally for greater computational efficiency for transforms
65 * that do not involve rotation.
66 */
67
69{
70 public:
71
72 /**
73 * Constructor for G4AffineTransform. Initialises components to zero.
74 */
76
77 /**
78 * Constructor for Translation only: under t'form, translate point
79 * at origin by 'tlate'.
80 */
81 inline G4AffineTransform(const G4ThreeVector& tlate);
82
83 /**
84 * Constructor for Rotation only: under t'form, rotate by 'rot'.
85 */
87
88 /**
89 * Constructor for Translation and Rotation: under t'form, rotate
90 * by 'rot' then translate by 'tlate'.
91 */
93 const G4ThreeVector& tlate);
94
95 /**
96 * Alternative Constructor optionally rotating by 'rot' by pointer then
97 * translate by 'tlate' - 'rot' may be null.
98 */
100 const G4ThreeVector& tlate);
101
102 /**
103 * Copy & move constructor.
104 */
105 inline G4AffineTransform(const G4AffineTransform& rhs) = default;
106 inline G4AffineTransform(G4AffineTransform&& rhs) = default;
107
108 /**
109 * Assignment & move operators.
110 */
113
114 /**
115 * Default Destructor.
116 */
117 inline ~G4AffineTransform() = default;
118
119 /**
120 * Compound Transforms: tf2=tf2*tf1 equivalent to tf2*=tf1.
121 * @param[in] tf Transformation to combine.
122 * @returns The compound transformation of self*tf.
123 */
125
126 /**
127 * [Modifying] compound Transforms: Multiplies self by 'tf'.
128 * @param[in] tf Transformation to combine.
129 * @returns Returns self reference, i.e. A=AB for a*=b.
130 */
132
133 /**
134 * [Modifying] Product function, for avoiding (potential) temporaries:
135 * c.Product(a,b) equivalent to c=a*b
136 * c.InverseProduct(a*b,b ) equivalent to c=a
137 * Sets self=tf1*tf2.
138 * @param[in] tf1 First transformation operand.
139 * @param[in] tf2 Second transformation operand.
140 * @returns Returns Self reference.
141 */
143 const G4AffineTransform& tf2);
144
145 /**
146 * [Modifying] Inverse Product function. Sets self=tf1*(tf2^-1).
147 * @param[in] tf1 First transformation operand.
148 * @param[in] tf2 Second transformation operand.
149 * @returns Returns Self reference.
150 */
152 const G4AffineTransform& tf2);
153
154 /**
155 * Transforms the specified point 'vec'.
156 * @returns vec*rot+tlate.
157 */
159
160 /**
161 * Transforms the specified point 'vec' using inverse transformation.
162 * @returns The inverse transformation of the given point.
163 */
165
166 /**
167 * Transforms the specified 'axis'.
168 * @returns vec*rot.
169 */
171
172 /**
173 * Transforms the specified 'axis' using inverse transformation.
174 * @returns The inverse transformation of the given axis.
175 */
177
178 /**
179 * Transforms the specified point 'vec' (in place): sets vec=vec*rot+tlate.
180 * @param[in,out] vec The point to transform.
181 */
182 inline void ApplyPointTransform(G4ThreeVector& vec) const;
183
184 /**
185 * Transforms the specified 'axis' (in place): sets axis=axis*rot.
186 * @param[in,out] axis The axis to transform.
187 */
189
190 /**
191 * Returns the inverse of the current transform.
192 */
194
195 /**
196 * [Modifying] Sets self=inverse of self.
197 * @returns Self reference.
198 */
200
201 /**
202 * [Modifying] Adjust the net translation by the given vector.
203 * @returns Self reference.
204 */
207
208 /**
209 * Equality and inequality operators.
210 */
211 inline G4bool operator == (const G4AffineTransform& tf) const;
212 inline G4bool operator != (const G4AffineTransform& tf) const;
213
214 /**
215 * Access operator.
216 */
217 inline G4double operator [] (const G4int n) const;
218
219 /**
220 * Returns true if transform includes rotation.
221 */
222 inline G4bool IsRotated() const;
223
224 /**
225 * Returns true if transform includes translation.
226 */
227 inline G4bool IsTranslated() const;
228
229 /**
230 * Returns the net rotation matrix.
231 */
233
234 /**
235 * Returns the inverse net rotation matrix.
236 */
238
239 /**
240 * Returns the net translation vector.
241 */
243
244 /**
245 * Returns the inverse net translation vector.
246 */
248
249 /**
250 * Setters for rotation and translation.
251 */
252 inline void SetNetRotation(const G4RotationMatrix& rot);
253 inline void SetNetTranslation(const G4ThreeVector& tlate);
254
255 /**
256 * Conversion operator (cast) to G4Transform3D.
257 */
258 inline operator G4Transform3D () const;
259
260 private:
261
262 /**
263 * Private components Constructor.
264 */
265 inline G4AffineTransform(
266 const G4double prxx, const G4double prxy, const G4double prxz,
267 const G4double pryx, const G4double pryy, const G4double pryz,
268 const G4double przx, const G4double przy, const G4double przz,
269 const G4double ptx, const G4double pty, const G4double ptz);
270
271 private:
272
273 G4double rxx,rxy,rxz;
274 G4double ryx,ryy,ryz;
275 G4double rzx,rzy,rzz;
276 G4double tx,ty,tz;
277};
278
279/**
280 * Streaming operator.
281 */
282std::ostream& operator << (std::ostream& os, const G4AffineTransform& transf);
283
284#include "G4AffineTransform.icc"
285
286#endif
std::ostream & operator<<(std::ostream &os, const G4AffineTransform &transf)
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Transform3D G4Transform3D
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4AffineTransform & Product(const G4AffineTransform &tf1, const G4AffineTransform &tf2)
G4ThreeVector InverseNetTranslation() const
G4AffineTransform(const G4RotationMatrix &rot, const G4ThreeVector &tlate)
~G4AffineTransform()=default
G4bool IsRotated() const
G4AffineTransform Inverse() const
void SetNetRotation(const G4RotationMatrix &rot)
G4AffineTransform & operator=(G4AffineTransform &&rhs)=default
G4ThreeVector NetTranslation() const
G4AffineTransform(const G4RotationMatrix *rot, const G4ThreeVector &tlate)
G4ThreeVector InverseTransformAxis(const G4ThreeVector &axis) const
G4AffineTransform & operator+=(const G4ThreeVector &tlate)
G4double operator[](const G4int n) const
G4AffineTransform & Invert()
void ApplyAxisTransform(G4ThreeVector &axis) const
G4bool IsTranslated() const
G4AffineTransform & operator=(const G4AffineTransform &rhs)
G4RotationMatrix NetRotation() const
G4AffineTransform(const G4AffineTransform &rhs)=default
G4AffineTransform & InverseProduct(const G4AffineTransform &tf1, const G4AffineTransform &tf2)
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4bool operator==(const G4AffineTransform &tf) const
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
G4AffineTransform(const G4RotationMatrix &rot)
G4AffineTransform & operator-=(const G4ThreeVector &tlate)
G4ThreeVector InverseTransformPoint(const G4ThreeVector &vec) const
G4AffineTransform operator*(const G4AffineTransform &tf) const
void ApplyPointTransform(G4ThreeVector &vec) const
G4AffineTransform(const G4ThreeVector &tlate)
G4AffineTransform & operator*=(const G4AffineTransform &tf)
G4AffineTransform(G4AffineTransform &&rhs)=default
void SetNetTranslation(const G4ThreeVector &tlate)
G4bool operator!=(const G4AffineTransform &tf) const
G4RotationMatrix InverseNetRotation() const
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668