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