Geant4 Cross Reference |
1 // -*- C++ -*- 1 // -*- C++ -*- 2 // ------------------------------------------- 2 // --------------------------------------------------------------------------- 3 // 3 // 4 // This file is a part of the CLHEP - a Class 4 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 5 // 5 // 6 // History: 6 // History: 7 // 09.09.96 E.Chernyaev - initial version 7 // 09.09.96 E.Chernyaev - initial version 8 // 12.06.01 E.Chernyaev - CLHEP-1.7: introduct 8 // 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple 9 // the functionality fr 9 // the functionality from CLHEP::Hep3Vector 10 // 01.04.03 E.Chernyaev - CLHEP-1.9: template 10 // 01.04.03 E.Chernyaev - CLHEP-1.9: template version 11 // 11 // 12 12 13 #ifndef HEP_NORMAL3D_H 13 #ifndef HEP_NORMAL3D_H 14 #define HEP_NORMAL3D_H 14 #define HEP_NORMAL3D_H 15 15 16 #include <iosfwd> 16 #include <iosfwd> 17 #include "CLHEP/Vector/ThreeVector.h" 17 #include "CLHEP/Vector/ThreeVector.h" 18 #include "CLHEP/Geometry/BasicVector3D.h" 18 #include "CLHEP/Geometry/BasicVector3D.h" 19 19 20 namespace HepGeom { 20 namespace HepGeom { 21 21 22 class Transform3D; 22 class Transform3D; 23 23 24 /** 24 /** 25 * Geometrical 3D Normal. 25 * Geometrical 3D Normal. 26 * This is just a declaration of the class n 26 * This is just a declaration of the class needed to define 27 * specializations Normal3D<float> and Norma 27 * specializations Normal3D<float> and Normal3D<double>. 28 * 28 * 29 * @ingroup geometry 29 * @ingroup geometry 30 * @author Evgeni Chernyaev <Evgueni.Tcherni 30 * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch> 31 */ 31 */ 32 template<class T> 32 template<class T> 33 class Normal3D : public BasicVector3D<T> {}; 33 class Normal3D : public BasicVector3D<T> {}; 34 34 35 /** 35 /** 36 * Geometrical 3D Normal with components of 36 * Geometrical 3D Normal with components of float type. 37 * 37 * 38 * @author Evgeni Chernyaev <Evgueni.Tcherni 38 * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch> 39 * @ingroup geometry 39 * @ingroup geometry 40 */ 40 */ 41 template<> 41 template<> 42 class Normal3D<float> : public BasicVector3D 42 class Normal3D<float> : public BasicVector3D<float> { 43 public: 43 public: 44 /** 44 /** 45 * Default constructor. */ 45 * Default constructor. */ 46 Normal3D() = default; 46 Normal3D() = default; 47 47 48 /** 48 /** 49 * Constructor from three numbers. */ 49 * Constructor from three numbers. */ 50 Normal3D(float x1, float y1, float z1) : B 50 Normal3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {} 51 51 52 /** 52 /** 53 * Constructor from array of floats. */ 53 * Constructor from array of floats. */ 54 explicit Normal3D(const float * a) 54 explicit Normal3D(const float * a) 55 : BasicVector3D<float>(a[0],a[1],a[2]) { 55 : BasicVector3D<float>(a[0],a[1],a[2]) {} 56 56 57 /** 57 /** 58 * Copy constructor. */ 58 * Copy constructor. */ 59 Normal3D(const Normal3D<float> &) = defaul 59 Normal3D(const Normal3D<float> &) = default; 60 60 61 /** 61 /** 62 * Move constructor. */ 62 * Move constructor. */ 63 Normal3D(Normal3D<float> &&) = default; 63 Normal3D(Normal3D<float> &&) = default; 64 64 65 /** 65 /** 66 * Constructor from BasicVector3D<float>. 66 * Constructor from BasicVector3D<float>. */ 67 Normal3D(const BasicVector3D<float> & v) : 67 Normal3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {} 68 68 69 /** 69 /** 70 * Destructor. */ 70 * Destructor. */ 71 ~Normal3D() = default; 71 ~Normal3D() = default; 72 72 73 /** 73 /** 74 * Assignment. */ 74 * Assignment. */ 75 Normal3D<float> & operator=(const Normal3D 75 Normal3D<float> & operator=(const Normal3D<float> &) = default; 76 76 77 /** 77 /** 78 * Assignment from BasicVector3D<float>. * 78 * Assignment from BasicVector3D<float>. */ 79 Normal3D<float> & operator=(const BasicVec 79 Normal3D<float> & operator=(const BasicVector3D<float> & v) { 80 this->BasicVector3D<float>::operator=(v) 80 this->BasicVector3D<float>::operator=(v); 81 return *this; 81 return *this; 82 } 82 } 83 83 84 /** 84 /** 85 * Move assignment. */ 85 * Move assignment. */ 86 Normal3D<float> & operator=(Normal3D<float 86 Normal3D<float> & operator=(Normal3D<float> &&) = default; 87 87 88 /** 88 /** 89 * Transformation by Transform3D. */ 89 * Transformation by Transform3D. */ 90 Normal3D<float> & transform(const Transfor 90 Normal3D<float> & transform(const Transform3D & m); 91 }; 91 }; 92 92 93 /** 93 /** 94 * Transformation of Normal<float> by Transf 94 * Transformation of Normal<float> by Transform3D. 95 * @relates Normal3D 95 * @relates Normal3D 96 */ 96 */ 97 Normal3D<float> 97 Normal3D<float> 98 operator*(const Transform3D & m, const Norma 98 operator*(const Transform3D & m, const Normal3D<float> & n); 99 99 100 /** 100 /** 101 * Geometrical 3D Normal with components of 101 * Geometrical 3D Normal with components of double type. 102 * 102 * 103 * @author Evgeni Chernyaev <Evgueni.Tcherni 103 * @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch> 104 * @ingroup geometry 104 * @ingroup geometry 105 */ 105 */ 106 template<> 106 template<> 107 class Normal3D<double> : public BasicVector3 107 class Normal3D<double> : public BasicVector3D<double> { 108 public: 108 public: 109 /** 109 /** 110 * Default constructor. */ 110 * Default constructor. */ 111 Normal3D() = default; 111 Normal3D() = default; 112 112 113 /** 113 /** 114 * Constructor from three numbers. */ 114 * Constructor from three numbers. */ 115 Normal3D(double x1, double y1, double z1) 115 Normal3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {} 116 116 117 /** 117 /** 118 * Constructor from array of floats. */ 118 * Constructor from array of floats. */ 119 explicit Normal3D(const float * a) 119 explicit Normal3D(const float * a) 120 : BasicVector3D<double>(a[0],a[1],a[2]) 120 : BasicVector3D<double>(a[0],a[1],a[2]) {} 121 121 122 /** 122 /** 123 * Constructor from array of doubles. */ 123 * Constructor from array of doubles. */ 124 explicit Normal3D(const double * a) 124 explicit Normal3D(const double * a) 125 : BasicVector3D<double>(a[0],a[1],a[2]) 125 : BasicVector3D<double>(a[0],a[1],a[2]) {} 126 126 127 /** 127 /** 128 * Copy constructor. */ 128 * Copy constructor. */ 129 Normal3D(const Normal3D<double> &) = defau 129 Normal3D(const Normal3D<double> &) = default; 130 130 131 /** 131 /** 132 * Move constructor. */ 132 * Move constructor. */ 133 Normal3D(Normal3D<double> &&) = default; 133 Normal3D(Normal3D<double> &&) = default; 134 134 135 /** 135 /** 136 * Constructor from BasicVector3D<float>. 136 * Constructor from BasicVector3D<float>. */ 137 Normal3D(const BasicVector3D<float> & v) : 137 Normal3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {} 138 138 139 /** 139 /** 140 * Constructor from BasicVector3D<double>. 140 * Constructor from BasicVector3D<double>. */ 141 Normal3D(const BasicVector3D<double> & v) 141 Normal3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {} 142 142 143 /** 143 /** 144 * Destructor. */ 144 * Destructor. */ 145 ~Normal3D() = default; 145 ~Normal3D() = default; 146 146 147 /** 147 /** 148 * Constructor from CLHEP::Hep3Vector. 148 * Constructor from CLHEP::Hep3Vector. 149 * This constructor is needed only for bac 149 * This constructor is needed only for backward compatibility and 150 * in principle should be absent. 150 * in principle should be absent. 151 */ 151 */ 152 Normal3D(const CLHEP::Hep3Vector & v) 152 Normal3D(const CLHEP::Hep3Vector & v) 153 : BasicVector3D<double>(v.x(),v.y(),v.z( 153 : BasicVector3D<double>(v.x(),v.y(),v.z()) {} 154 154 155 /** 155 /** 156 * Conversion (cast) to CLHEP::Hep3Vector. 156 * Conversion (cast) to CLHEP::Hep3Vector. 157 * This operator is needed only for backwa 157 * This operator is needed only for backward compatibility and 158 * in principle should not exit. 158 * in principle should not exit. 159 */ 159 */ 160 operator CLHEP::Hep3Vector () const { retu 160 operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); } 161 161 162 /** 162 /** 163 * Assignment. */ 163 * Assignment. */ 164 Normal3D<double> & operator=(const Normal3 164 Normal3D<double> & operator=(const Normal3D<double> &) = default; 165 165 166 /** 166 /** 167 * Assignment from BasicVector3D<float>. * 167 * Assignment from BasicVector3D<float>. */ 168 Normal3D<double> & operator=(const BasicVe 168 Normal3D<double> & operator=(const BasicVector3D<float> & v) { 169 this->BasicVector3D<double>::operator=(v 169 this->BasicVector3D<double>::operator=(v); 170 return *this; 170 return *this; 171 } 171 } 172 172 173 /** 173 /** 174 * Assignment from BasicVector3D<double>. 174 * Assignment from BasicVector3D<double>. */ 175 Normal3D<double> & operator=(const BasicVe 175 Normal3D<double> & operator=(const BasicVector3D<double> & v) { 176 this->BasicVector3D<double>::operator=(v 176 this->BasicVector3D<double>::operator=(v); 177 return *this; 177 return *this; 178 } 178 } 179 179 180 /** 180 /** 181 * Move assignment. */ 181 * Move assignment. */ 182 Normal3D<double> & operator=(Normal3D<doub 182 Normal3D<double> & operator=(Normal3D<double> &&) = default; 183 183 184 /** 184 /** 185 * Transformation by Transform3D. */ 185 * Transformation by Transform3D. */ 186 Normal3D<double> & transform(const Transfo 186 Normal3D<double> & transform(const Transform3D & m); 187 }; 187 }; 188 188 189 /** 189 /** 190 * Transformation of Normal<double> by Trans 190 * Transformation of Normal<double> by Transform3D. 191 * @relates Normal3D 191 * @relates Normal3D 192 */ 192 */ 193 Normal3D<double> 193 Normal3D<double> 194 operator*(const Transform3D & m, const Norma 194 operator*(const Transform3D & m, const Normal3D<double> & n); 195 195 196 } /* namespace HepGeom */ 196 } /* namespace HepGeom */ 197 197 198 #endif /* HEP_NORMAL3D_H */ 198 #endif /* HEP_NORMAL3D_H */ 199 199