00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // class G4AffineTransform 00031 // 00032 // Class description: 00033 // 00034 // A class for geometric affine transformations [see, eg. Foley & Van Dam] 00035 // Supports efficient arbitrary rotation & transformation of vectors and the 00036 // computation of compound & inverse transformations. A `rotation flag' is 00037 // maintained internally for greater computational efficiency for transforms 00038 // that do not involve rotation. 00039 // 00040 // Interfaces to the CLHEP classes G4ThreeVector & G4RotationMatrix 00041 // 00042 // For member function descriptions, see comments by declarations. For 00043 // additional clarification, also check the `const' declarations for 00044 // functions & their parameters. 00045 // 00046 // Member data: 00047 // 00048 // G4double rxx,rxy,rxz; 00049 // G4double ryx,ryy,ryz; A 3x3 rotation matrix - net rotation 00050 // G4double rzx,rzy,rzz; 00051 // G4double tx,ty,tz; Net translation 00052 00053 // History: 00054 // Paul R C Kent 6 Aug 1996 - initial version 00055 // 00056 // 19.09.96 E.Chernyaev: 00057 // - direct access to the protected members of the G4RotationMatrix class 00058 // replaced by access via public access functions 00059 // - conversion of the rotation matrix to angle & axis used to get 00060 // a possibility to remove "friend" from the G4RotationMatrix class 00061 // -------------------------------------------------------------------- 00062 #ifndef G4AFFINETRANSFORM_HH 00063 #define G4AFFINETRANSFORM_HH 00064 00065 #include "G4Types.hh" 00066 #include "G4ThreeVector.hh" 00067 #include "G4RotationMatrix.hh" 00068 00069 class G4AffineTransform 00070 { 00071 00072 public: 00073 00074 G4AffineTransform(); 00075 00076 public: // with description 00077 00078 G4AffineTransform(const G4ThreeVector &tlate); 00079 // Translation only: under t'form translate point at origin by tlate 00080 00081 G4AffineTransform(const G4RotationMatrix &rot); 00082 // Rotation only: under t'form rotate by rot 00083 00084 G4AffineTransform(const G4RotationMatrix &rot, 00085 const G4ThreeVector &tlate); 00086 // Under t'form: rotate by rot then translate by tlate 00087 00088 G4AffineTransform(const G4RotationMatrix *rot, 00089 const G4ThreeVector &tlate); 00090 // Optionally rotate by *rot then translate by tlate - rot may be null 00091 00092 G4AffineTransform operator * (const G4AffineTransform &tf) const; 00093 // Compound Transforms: 00094 // tf2=tf2*tf1 equivalent to tf2*=tf1 00095 // Returns compound transformation of self*tf 00096 00097 G4AffineTransform& operator *= (const G4AffineTransform &tf); 00098 // (Modifying) Multiplies self by tf; Returns self reference 00099 // ie. A=AB for a*=b 00100 00101 00102 G4AffineTransform& Product(const G4AffineTransform &tf1, 00103 const G4AffineTransform &tf2); 00104 // 'Products' for avoiding (potential) temporaries: 00105 // c.Product(a,b) equivalent to c=a*b 00106 // c.InverseProduct(a*b,b ) equivalent to c=a 00107 // (Modifying) Sets self=tf1*tf2; Returns self reference 00108 00109 G4AffineTransform& InverseProduct(const G4AffineTransform &tf1, 00110 const G4AffineTransform &tf2); 00111 // (Modifying) Sets self=tf1*(tf2^-1); Returns self reference 00112 00113 G4ThreeVector TransformPoint(const G4ThreeVector &vec) const; 00114 // Transform the specified point: returns vec*rot+tlate 00115 00116 G4ThreeVector TransformAxis(const G4ThreeVector &axis) const; 00117 // Transform the specified axis: returns 00118 00119 void ApplyPointTransform(G4ThreeVector &vec) const; 00120 // Transform the specified point (in place): sets vec=vec*rot+tlate 00121 00122 void ApplyAxisTransform(G4ThreeVector &axis) const; 00123 // Transform the specified axis (in place): sets axis=axis*rot; 00124 00125 G4AffineTransform Inverse() const; 00126 // Return inverse of current transform 00127 00128 G4AffineTransform& Invert(); 00129 // (Modifying) Sets self=inverse of self; Returns self reference 00130 00131 G4AffineTransform& operator +=(const G4ThreeVector &tlate); 00132 G4AffineTransform& operator -=(const G4ThreeVector &tlate); 00133 // (Modifying) Adjust net translation by given vector; 00134 // Returns self reference 00135 00136 G4bool operator == (const G4AffineTransform &tf) const; 00137 G4bool operator != (const G4AffineTransform &tf) const; 00138 00139 G4double operator [] (const G4int n) const; 00140 00141 G4bool IsRotated() const; 00142 // True if transform includes rotation 00143 00144 G4bool IsTranslated() const; 00145 // True if transform includes translation 00146 00147 G4RotationMatrix NetRotation() const; 00148 00149 G4ThreeVector NetTranslation() const; 00150 00151 void SetNetRotation(const G4RotationMatrix &rot); 00152 00153 void SetNetTranslation(const G4ThreeVector &tlate); 00154 00155 private: 00156 00157 G4AffineTransform(const G4double prxx,const G4double prxy,const G4double prxz, 00158 const G4double pryx,const G4double pryy,const G4double pryz, 00159 const G4double przx,const G4double przy,const G4double przz, 00160 const G4double ptx, const G4double pty, const G4double ptz ); 00161 00162 G4double rxx,rxy,rxz; 00163 G4double ryx,ryy,ryz; 00164 G4double rzx,rzy,rzz; 00165 G4double tx,ty,tz; 00166 }; 00167 00168 #include "G4AffineTransform.icc" 00169 00170 #endif