CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 //---------------XF::Function (transformation field)--------------------// 00002 // // 00003 // XF::Function, class of function objects which evaluate to a // 00004 // evaluate to a HepTransform, and a class XF::Pow which can be // 00005 // used to exponentiate any transform. The transformations fields // 00006 // can be multiplied together or multiplied with a fixed global // 00007 // transformation. These can be used to build arbitrary // 00008 // HepTransform3D-valued-fields which are very compact. Chief // 00009 // application so far is in geometry modelling where it is a // 00010 // powerful technique for parameterization. // 00011 // // 00012 // Example: // 00013 // // 00014 // // Define some constants: // 00015 // int N; // 00016 // double c1, c2, r, z; // 00017 // // 00018 // // Construct a simple linear function of a variable i: // 00019 // // 00020 // Variable i; // 00021 // // 00022 // GENFUNCTION g = c1+c2*i; // 00023 // // 00024 // // Create a transfunction // 00025 // // 00026 // TRANSFUNCTION xf = Pow(HepRotateZ3D(1),g)* // 00027 // HepTranslateX3D(r)* // 00028 // HepTranslateZ3D(z); // 00029 // // 00030 // // Evaluation of TRANSFUNCTION // 00031 // // 00032 // HepTransform3D x = xf(33.2); // 00033 // // 00034 // // 00035 // ... // 00036 // Similar techniques may be used to create a transformation field of // 00037 // more than one variable. // 00038 // // 00039 // // 00040 //----------------------------------------------------------------------// 00041 #ifndef TransformFunction_h 00042 #define TransformFunction_h 1 00043 #include "CLHEP/GenericFunctions/AbsFunction.hh" 00044 #include "CLHEP/GenericFunctions/Argument.hh" 00045 #include "CLHEP/Geometry/Transform3D.h" 00046 00047 //-----------------------------------------------------------------------// 00048 // Exact return type of arithmentic operations. To the user, the return // 00049 // type is TRANSFUNCTION, or const XF::Function &. // 00050 //-----------------------------------------------------------------------// 00051 00052 namespace XF 00053 { 00054 00055 class Product; 00056 class PreMult; 00057 class PostMult; 00058 class Pow; 00059 00060 00061 class Function 00062 { 00063 00064 public: 00065 00066 // Default Constructor 00067 Function (); 00068 00069 // Destructor 00070 virtual ~ Function (); 00071 00072 // Function value: N-dimensional functions must override these: 00073 virtual unsigned int dimensionality () const; //returns 1; 00074 00075 // Function value 00076 virtual HepGeom::Transform3D operator () (double argument) const = 0; 00077 virtual HepGeom::Transform3D operator () (const Genfun:: 00078 Argument & argument) const = 00079 0; 00080 00081 // Every function must override this: 00082 virtual Function *clone () const = 0; 00083 00084 // Copy constructor 00085 Function (const Function & right); 00086 00087 private: 00088 00089 // Assignment operator 00090 const Function & operator = (const Function & right); 00091 00092 }; 00093 00094 00095 00096 00097 00098 00099 class Pow:public Function 00100 { 00101 00102 public: 00103 00104 Pow (const HepGeom::Transform3D &, Genfun::GENFUNCTION f); 00105 00106 virtual ~ Pow (); 00107 00108 virtual HepGeom::Transform3D operator () (double argument) const; 00109 virtual HepGeom::Transform3D operator () (const Genfun:: 00110 Argument & argument) const; 00111 00112 // Every function must override this: 00113 Pow *clone () const; 00114 00115 // Copy constructor: 00116 Pow (const Pow & right); 00117 00118 private: 00119 00120 // Assignment operator 00121 const Pow & operator = (const Pow & right); 00122 00123 const HepGeom::Transform3D xf; 00124 const Genfun::AbsFunction * function; 00125 00126 }; 00127 00128 00129 00130 00131 00132 Product operator * (const Function & op1, const Function & op2); 00133 PreMult operator * (const HepGeom::Transform3D & xf, const Function & op2); 00134 PostMult operator * (const Function & op2, const HepGeom::Transform3D & xf); 00135 00136 00137 // Internally used class:: Product: 00138 00139 class Product:public Function 00140 { 00141 00142 public: 00143 00144 00145 Product (const Function * arg1, const Function * arg2); 00146 00147 virtual ~ Product (); 00148 00149 virtual unsigned int dimensionality () const; 00150 00151 virtual HepGeom::Transform3D operator () (double argument) const; 00152 virtual HepGeom::Transform3D operator () (const Genfun:: 00153 Argument & argument) const; 00154 00155 // Every function must override this: 00156 virtual Product *clone () const; 00157 00158 // Copy constructor: 00159 Product (const Product & right); 00160 00161 private: 00162 00163 const Function *_arg1; 00164 const Function *_arg2; 00165 00166 }; 00167 00168 // Internally used class:: PreMult : 00169 00170 class PreMult:public Function 00171 { 00172 00173 public: 00174 00175 00176 PreMult (const HepGeom::Transform3D & arg1, const Function * arg2); 00177 00178 virtual ~ PreMult (); 00179 00180 virtual unsigned int dimensionality () const; 00181 00182 virtual HepGeom::Transform3D operator () (double argument) const; 00183 virtual HepGeom::Transform3D operator () (const Genfun:: 00184 Argument & argument) const; 00185 00186 // Every function must override this: 00187 virtual PreMult *clone () const; 00188 00189 // Copy constructor: 00190 PreMult (const PreMult & right); 00191 00192 private: 00193 00194 const HepGeom::Transform3D _arg1; 00195 const Function *_arg2; 00196 00197 }; 00198 00199 // Internally used class:: PostMult : 00200 00201 class PostMult:public Function 00202 { 00203 00204 public: 00205 00206 00207 PostMult (const Function * arg1, const HepGeom::Transform3D & arg2); 00208 00209 virtual ~ PostMult (); 00210 00211 virtual unsigned int dimensionality () const; 00212 00213 virtual HepGeom::Transform3D operator () (double argument) const; 00214 virtual HepGeom::Transform3D operator () (const Genfun:: 00215 Argument & argument) const; 00216 00217 // Every function must override this: 00218 virtual PostMult *clone () const; 00219 00220 // Copy constructor: 00221 PostMult (const PostMult & right); 00222 00223 private: 00224 00225 const Function *_arg1; 00226 const HepGeom::Transform3D _arg2; 00227 00228 }; 00229 00230 typedef const Function & TRANSFUNCTION; 00231 00232 00233 00234 } 00235 00236 #endif