Geant4-11
Public Types | Public Member Functions | Protected Attributes | Related Functions
HepGeom::Normal3D< float > Class Reference

#include <Normal3D.h>

Inheritance diagram for HepGeom::Normal3D< float >:
HepGeom::BasicVector3D< float >

Public Types

enum  
 

Public Member Functions

double angle (const BasicVector3D< double > &v) const
 
float angle (const BasicVector3D< float > &v) const
 
float angle (const BasicVector3D< float > &v) const
 
float cosTheta () const
 
BasicVector3D< float > cross (const BasicVector3D< float > &v) const
 
float dot (const BasicVector3D< float > &v) const
 
float eta () const
 
float getEta () const
 
float getPhi () const
 
float getR () const
 
float getTheta () const
 
float mag () const
 
float mag2 () const
 
 Normal3D ()=default
 
 Normal3D (const BasicVector3D< float > &v)
 
 Normal3D (const float *a)
 
 Normal3D (const Normal3D< float > &)=default
 
 Normal3D (float x1, float y1, float z1)
 
 Normal3D (Normal3D< float > &&)=default
 
 operator CLHEP::Hep3Vector () const
 
 operator const float * () const
 
 operator float * ()
 
float & operator() (int i)
 
float operator() (int i) const
 
BasicVector3D< float > & operator*= (double a)
 
BasicVector3D< float > & operator+= (const BasicVector3D< float > &v)
 
BasicVector3D< float > & operator-= (const BasicVector3D< float > &v)
 
BasicVector3D< float > & operator/= (double a)
 
Normal3D< float > & operator= (const BasicVector3D< float > &v)
 
Normal3D< float > & operator= (const Normal3D< float > &)=default
 
Normal3D< float > & operator= (Normal3D< float > &&)=default
 
float & operator[] (int i)
 
float operator[] (int i) const
 
BasicVector3D< float > orthogonal () const
 
float perp () const
 
float perp (const BasicVector3D< float > &v) const
 
float perp2 () const
 
float perp2 (const BasicVector3D< float > &v) const
 
float phi () const
 
float pseudoRapidity () const
 
float pseudoRapidity () const
 
double pseudoRapidity () const
 
float r () const
 
float rho () const
 
BasicVector3D< double > & rotate (double a, const BasicVector3D< double > &v)
 
BasicVector3D< float > & rotate (float a, const BasicVector3D< float > &v)
 
BasicVector3D< float > & rotate (float a, const BasicVector3D< float > &v)
 
BasicVector3D< double > & rotateX (double a)
 
BasicVector3D< float > & rotateX (float a)
 
BasicVector3D< float > & rotateX (float a)
 
BasicVector3D< double > & rotateY (double a)
 
BasicVector3D< float > & rotateY (float a)
 
BasicVector3D< float > & rotateY (float a)
 
BasicVector3D< double > & rotateZ (double a)
 
BasicVector3D< float > & rotateZ (float a)
 
BasicVector3D< float > & rotateZ (float a)
 
void set (float x1, float y1, float z1)
 
void setEta (double a)
 
void setEta (float a)
 
void setEta (float a)
 
void setMag (float ma)
 
void setPerp (float rh)
 
void setPhi (float ph)
 
void setR (float ma)
 
void setTheta (float th)
 
void setX (float a)
 
void setY (float a)
 
void setZ (float a)
 
float theta () const
 
Normal3D< float > & transform (const Transform3D &m)
 
BasicVector3D< float > unit () const
 
float x () const
 
float y () const
 
float z () const
 
 ~Normal3D ()=default
 

Protected Attributes

float v_ [3]
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
 
bool operator!= (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
 
double operator* (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
 
BasicVector3D< double > operator* (const BasicVector3D< double > &v, double a)
 
float operator* (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
 
BasicVector3D< float > operator* (const BasicVector3D< float > &v, double a)
 
BasicVector3D< double > operator* (double a, const BasicVector3D< double > &v)
 
BasicVector3D< float > operator* (double a, const BasicVector3D< float > &v)
 
BasicVector3D< double > operator+ (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
 
BasicVector3D< double > operator+ (const BasicVector3D< double > &v)
 
BasicVector3D< float > operator+ (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
 
BasicVector3D< float > operator+ (const BasicVector3D< float > &v)
 
BasicVector3D< double > operator- (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
 
BasicVector3D< double > operator- (const BasicVector3D< double > &v)
 
BasicVector3D< float > operator- (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
 
BasicVector3D< float > operator- (const BasicVector3D< float > &v)
 
BasicVector3D< double > operator/ (const BasicVector3D< double > &v, double a)
 
BasicVector3D< float > operator/ (const BasicVector3D< float > &v, double a)
 
std::ostream & operator<< (std::ostream &, const BasicVector3D< double > &)
 
std::ostream & operator<< (std::ostream &, const BasicVector3D< float > &)
 
bool operator== (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
 
bool operator== (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
 
std::istream & operator>> (std::istream &, BasicVector3D< double > &)
 
std::istream & operator>> (std::istream &, BasicVector3D< float > &)
 

Detailed Description

Geometrical 3D Normal with components of float type.

Author
Evgeni Chernyaev Evgue.nosp@m.ni.T.nosp@m.chern.nosp@m.iaev.nosp@m.@cern.nosp@m..ch

Definition at line 42 of file Normal3D.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Safe indexing of the coordinates when using with matrices, arrays, etc.

Definition at line 41 of file BasicVector3D.h.

Constructor & Destructor Documentation

◆ Normal3D() [1/6]

HepGeom::Normal3D< float >::Normal3D ( )
default

Default constructor.

◆ Normal3D() [2/6]

HepGeom::Normal3D< float >::Normal3D ( float  x1,
float  y1,
float  z1 
)
inline

Constructor from three numbers.

Definition at line 50 of file Normal3D.h.

50: BasicVector3D<float>(x1,y1,z1) {}

◆ Normal3D() [3/6]

HepGeom::Normal3D< float >::Normal3D ( const float *  a)
inlineexplicit

Constructor from array of floats.

Definition at line 54 of file Normal3D.h.

55 : BasicVector3D<float>(a[0],a[1],a[2]) {}

◆ Normal3D() [4/6]

HepGeom::Normal3D< float >::Normal3D ( const Normal3D< float > &  )
default

Copy constructor.

◆ Normal3D() [5/6]

HepGeom::Normal3D< float >::Normal3D ( Normal3D< float > &&  )
default

Move constructor.

◆ Normal3D() [6/6]

HepGeom::Normal3D< float >::Normal3D ( const BasicVector3D< float > &  v)
inline

Constructor from BasicVector3D<float>.

Definition at line 67 of file Normal3D.h.

67: BasicVector3D<float>(v) {}

◆ ~Normal3D()

HepGeom::Normal3D< float >::~Normal3D ( )
default

Destructor.

Member Function Documentation

◆ angle() [1/3]

double HepGeom::BasicVector3D< double >::angle ( const BasicVector3D< double > &  v) const
inherited

Definition at line 191 of file BasicVector3D.cc.

191 {
192 double cosa = 0;
193 double ptot = mag()*v.mag();
194 if(ptot > 0) {
195 cosa = dot(v)/ptot;
196 if(cosa > 1) cosa = 1;
197 if(cosa < -1) cosa = -1;
198 }
199 return std::acos(cosa);
200 }
float dot(const BasicVector3D< float > &v) const

◆ angle() [2/3]

float HepGeom::BasicVector3D< float >::angle ( const BasicVector3D< float > &  v) const
inherited

Returns angle w.r.t. another vector.

◆ angle() [3/3]

float HepGeom::BasicVector3D< float >::angle ( const BasicVector3D< float > &  v) const
inherited

Definition at line 35 of file BasicVector3D.cc.

35 {
36 double cosa = 0;
37 double ptot = mag()*v.mag();
38 if(ptot > 0) {
39 cosa = dot(v)/ptot;
40 if(cosa > 1) cosa = 1;
41 if(cosa < -1) cosa = -1;
42 }
43 return std::acos(cosa);
44 }

◆ cosTheta()

float HepGeom::BasicVector3D< float >::cosTheta ( ) const
inlineinherited

Gets cosine of polar angle.

Definition at line 217 of file BasicVector3D.h.

217{ T ma = mag(); return ma == 0 ? 1 : z()/ma; }

◆ cross()

BasicVector3D< float > HepGeom::BasicVector3D< float >::cross ( const BasicVector3D< float > &  v) const
inlineinherited

Vector product.

Definition at line 281 of file BasicVector3D.h.

281 {
282 return BasicVector3D<T>(y()*v.z()-v.y()*z(),
283 z()*v.x()-v.z()*x(),
284 x()*v.y()-v.x()*y());
285 }

◆ dot()

float HepGeom::BasicVector3D< float >::dot ( const BasicVector3D< float > &  v) const
inlineinherited

Scalar product.

Definition at line 275 of file BasicVector3D.h.

275 {
276 return x()*v.x()+y()*v.y()+z()*v.z();
277 }

◆ eta()

float HepGeom::BasicVector3D< float >::eta ( ) const
inlineinherited

Gets pseudo-rapidity.

Definition at line 260 of file BasicVector3D.h.

260{ return pseudoRapidity(); }

◆ getEta()

float HepGeom::BasicVector3D< float >::getEta ( ) const
inlineinherited

Gets pseudo-rapidity.

Definition at line 263 of file BasicVector3D.h.

263{ return pseudoRapidity(); }

◆ getPhi()

float HepGeom::BasicVector3D< float >::getPhi ( ) const
inlineinherited

Gets phi-component in spherical coordinate system

Definition at line 224 of file BasicVector3D.h.

224{ return phi(); }

◆ getR()

float HepGeom::BasicVector3D< float >::getR ( ) const
inlineinherited

Gets r-component in spherical coordinate system

Definition at line 221 of file BasicVector3D.h.

221{ return r(); }

◆ getTheta()

float HepGeom::BasicVector3D< float >::getTheta ( ) const
inlineinherited

Gets theta-component in spherical coordinate system

Definition at line 227 of file BasicVector3D.h.

227{ return theta(); }

◆ mag()

float HepGeom::BasicVector3D< float >::mag ( ) const
inlineinherited

Gets magnitude of the vector.

Definition at line 201 of file BasicVector3D.h.

201{ return std::sqrt(mag2()); }

◆ mag2()

float HepGeom::BasicVector3D< float >::mag2 ( ) const
inlineinherited

Gets magnitude squared of the vector.

Definition at line 198 of file BasicVector3D.h.

198{ return x()*x()+y()*y()+z()*z(); }

◆ operator CLHEP::Hep3Vector()

HepGeom::BasicVector3D< float >::operator CLHEP::Hep3Vector ( ) const
inlineinherited

Conversion (cast) to CLHEP::Hep3Vector. This operator is needed only for backward compatibility and in principle should not exit.

Definition at line 90 of file BasicVector3D.h.

90{ return CLHEP::Hep3Vector(x(),y(),z()); }

◆ operator const float *()

HepGeom::BasicVector3D< float >::operator const float * ( ) const
inlineinherited

Conversion (cast) to ordinary const array.

Definition at line 83 of file BasicVector3D.h.

83{ return v_; }

◆ operator float *()

HepGeom::BasicVector3D< float >::operator float * ( )
inlineinherited

Conversion (cast) to ordinary array.

Definition at line 79 of file BasicVector3D.h.

79{ return v_; }

◆ operator()() [1/2]

float & HepGeom::BasicVector3D< float >::operator() ( int  i)
inlineinherited

Sets components by index.

Definition at line 136 of file BasicVector3D.h.

136{ return v_[i]; }

◆ operator()() [2/2]

float HepGeom::BasicVector3D< float >::operator() ( int  i) const
inlineinherited

Gets components by index.

Definition at line 129 of file BasicVector3D.h.

129{ return v_[i]; }

◆ operator*=()

BasicVector3D< float > & HepGeom::BasicVector3D< float >::operator*= ( double  a)
inlineinherited

Multiplication by scalar.

Definition at line 114 of file BasicVector3D.h.

114 {
115 v_[0] *= a; v_[1] *= a; v_[2] *= a; return *this;
116 }

◆ operator+=()

BasicVector3D< float > & HepGeom::BasicVector3D< float >::operator+= ( const BasicVector3D< float > &  v)
inlineinherited

Addition.

Definition at line 104 of file BasicVector3D.h.

104 {
105 v_[0] += v.v_[0]; v_[1] += v.v_[1]; v_[2] += v.v_[2]; return *this;
106 }

◆ operator-=()

BasicVector3D< float > & HepGeom::BasicVector3D< float >::operator-= ( const BasicVector3D< float > &  v)
inlineinherited

Subtraction.

Definition at line 109 of file BasicVector3D.h.

109 {
110 v_[0] -= v.v_[0]; v_[1] -= v.v_[1]; v_[2] -= v.v_[2]; return *this;
111 }

◆ operator/=()

BasicVector3D< float > & HepGeom::BasicVector3D< float >::operator/= ( double  a)
inlineinherited

Division by scalar.

Definition at line 119 of file BasicVector3D.h.

119 {
120 v_[0] /= a; v_[1] /= a; v_[2] /= a; return *this;
121 }

◆ operator=() [1/3]

Normal3D< float > & HepGeom::Normal3D< float >::operator= ( const BasicVector3D< float > &  v)
inline

Assignment from BasicVector3D<float>.

Definition at line 79 of file Normal3D.h.

79 {
81 return *this;
82 }
BasicVector3D< T > & operator=(const BasicVector3D< T > &)=default

References HepGeom::BasicVector3D< T >::operator=().

◆ operator=() [2/3]

Normal3D< float > & HepGeom::Normal3D< float >::operator= ( const Normal3D< float > &  )
default

Assignment.

◆ operator=() [3/3]

Normal3D< float > & HepGeom::Normal3D< float >::operator= ( Normal3D< float > &&  )
default

Move assignment.

◆ operator[]() [1/2]

float & HepGeom::BasicVector3D< float >::operator[] ( int  i)
inlineinherited

Sets components by index.

Definition at line 139 of file BasicVector3D.h.

139{ return v_[i]; }

◆ operator[]() [2/2]

float HepGeom::BasicVector3D< float >::operator[] ( int  i) const
inlineinherited

Gets components by index.

Definition at line 132 of file BasicVector3D.h.

132{ return v_[i]; }

◆ orthogonal()

BasicVector3D< float > HepGeom::BasicVector3D< float >::orthogonal ( ) const
inlineinherited

Returns orthogonal vector.

Definition at line 318 of file BasicVector3D.h.

318 {
319 T dx = x() < 0 ? -x() : x();
320 T dy = y() < 0 ? -y() : y();
321 T dz = z() < 0 ? -z() : z();
322 if (dx < dy) {
323 return dx < dz ?
324 BasicVector3D<T>(0,z(),-y()) : BasicVector3D<T>(y(),-x(),0);
325 }else{
326 return dy < dz ?
327 BasicVector3D<T>(-z(),0,x()) : BasicVector3D<T>(y(),-x(),0);
328 }
329 }

◆ perp() [1/2]

float HepGeom::BasicVector3D< float >::perp ( ) const
inlineinherited

Gets transverse component.

Definition at line 178 of file BasicVector3D.h.

178{ return std::sqrt(perp2()); }

◆ perp() [2/2]

float HepGeom::BasicVector3D< float >::perp ( const BasicVector3D< float > &  v) const
inlineinherited

Returns transverse component w.r.t. given axis.

Definition at line 296 of file BasicVector3D.h.

296 {
297 return std::sqrt(perp2(v));
298 }

◆ perp2() [1/2]

float HepGeom::BasicVector3D< float >::perp2 ( ) const
inlineinherited

Gets transverse component squared.

Definition at line 175 of file BasicVector3D.h.

175{ return x()*x()+y()*y(); }

◆ perp2() [2/2]

float HepGeom::BasicVector3D< float >::perp2 ( const BasicVector3D< float > &  v) const
inlineinherited

Returns transverse component w.r.t. given axis squared.

Definition at line 289 of file BasicVector3D.h.

289 {
290 T tot = v.mag2(), s = dot(v);
291 return tot > 0 ? mag2()-s*s/tot : mag2();
292 }
static constexpr double s
Definition: G4SIunits.hh:154

◆ phi()

float HepGeom::BasicVector3D< float >::phi ( ) const
inlineinherited

Gets azimuth angle.

Definition at line 207 of file BasicVector3D.h.

207 {
208 return x() == 0 && y() == 0 ? 0 : std::atan2(y(),x());
209 }

◆ pseudoRapidity() [1/3]

float HepGeom::BasicVector3D< float >::pseudoRapidity ( ) const
inherited

Gets pseudo-rapidity: -ln(tan(theta/2))

◆ pseudoRapidity() [2/3]

float HepGeom::BasicVector3D< float >::pseudoRapidity ( ) const
inherited

Definition at line 12 of file BasicVector3D.cc.

12 {
13 float ma = mag(), dz = z();
14 if (ma == 0) return 0;
15 if (ma == dz) return FLT_MAX;
16 if (ma == -dz) return -FLT_MAX;
17 return 0.5*std::log((ma+dz)/(ma-dz));
18 }
#define FLT_MAX
Definition: templates.hh:78

◆ pseudoRapidity() [3/3]

double HepGeom::BasicVector3D< double >::pseudoRapidity ( ) const
inherited

Definition at line 168 of file BasicVector3D.cc.

168 {
169 double ma = mag(), dz = z();
170 if (ma == 0) return 0;
171 if (ma == dz) return DBL_MAX;
172 if (ma == -dz) return -DBL_MAX;
173 return 0.5*std::log((ma+dz)/(ma-dz));
174 }
#define DBL_MAX
Definition: templates.hh:62

◆ r()

float HepGeom::BasicVector3D< float >::r ( ) const
inlineinherited

Gets r-component in spherical coordinate system

Definition at line 204 of file BasicVector3D.h.

204{ return mag(); }

◆ rho()

float HepGeom::BasicVector3D< float >::rho ( ) const
inlineinherited

Gets rho-component in cylindrical coordinate system

Definition at line 181 of file BasicVector3D.h.

181{ return perp(); }

◆ rotate() [1/3]

BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotate ( double  a,
const BasicVector3D< double > &  v 
)
inherited

Definition at line 232 of file BasicVector3D.cc.

232 {
233 if (a == 0) return *this;
234 double cx = v.x(), cy = v.y(), cz = v.z();
235 double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
236 if (ll == 0) {
237 std::cerr << "BasicVector<double>::rotate() : zero axis" << std::endl;
238 return *this;
239 }
240 double cosa = std::cos(a), sina = std::sin(a);
241 cx /= ll; cy /= ll; cz /= ll;
242
243 double xx = cosa + (1-cosa)*cx*cx;
244 double xy = (1-cosa)*cx*cy - sina*cz;
245 double xz = (1-cosa)*cx*cz + sina*cy;
246
247 double yx = (1-cosa)*cy*cx + sina*cz;
248 double yy = cosa + (1-cosa)*cy*cy;
249 double yz = (1-cosa)*cy*cz - sina*cx;
250
251 double zx = (1-cosa)*cz*cx - sina*cy;
252 double zy = (1-cosa)*cz*cy + sina*cx;
253 double zz = cosa + (1-cosa)*cz*cz;
254
255 cx = x(); cy = y(); cz = z();
256 set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
257 return *this;
258 }

◆ rotate() [2/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotate ( float  a,
const BasicVector3D< float > &  v 
)
inherited

Rotates around the axis specified by another vector.

◆ rotate() [3/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotate ( float  a,
const BasicVector3D< float > &  v 
)
inherited

Definition at line 76 of file BasicVector3D.cc.

76 {
77 if (a == 0) return *this;
78 double cx = v.x(), cy = v.y(), cz = v.z();
79 double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
80 if (ll == 0) {
81 std::cerr << "BasicVector<float>::rotate() : zero axis" << std::endl;
82 return *this;
83 }
84 double cosa = std::cos(a), sina = std::sin(a);
85 cx /= ll; cy /= ll; cz /= ll;
86
87 double xx = cosa + (1-cosa)*cx*cx;
88 double xy = (1-cosa)*cx*cy - sina*cz;
89 double xz = (1-cosa)*cx*cz + sina*cy;
90
91 double yx = (1-cosa)*cy*cx + sina*cz;
92 double yy = cosa + (1-cosa)*cy*cy;
93 double yz = (1-cosa)*cy*cz - sina*cx;
94
95 double zx = (1-cosa)*cz*cx - sina*cy;
96 double zy = (1-cosa)*cz*cy + sina*cx;
97 double zz = cosa + (1-cosa)*cz*cz;
98
99 cx = x(); cy = y(); cz = z();
100 set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
101 return *this;
102 }

◆ rotateX() [1/3]

BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateX ( double  a)
inherited

Definition at line 204 of file BasicVector3D.cc.

204 {
205 double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = z();
206 setY(dy*cosa-dz*sina);
207 setZ(dz*cosa+dy*sina);
208 return *this;
209 }

◆ rotateX() [2/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotateX ( float  a)
inherited

Rotates around x-axis.

◆ rotateX() [3/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotateX ( float  a)
inherited

Definition at line 48 of file BasicVector3D.cc.

48 {
49 double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = z();
50 setY(dy*cosa-dz*sina);
51 setZ(dz*cosa+dy*sina);
52 return *this;
53 }

◆ rotateY() [1/3]

BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateY ( double  a)
inherited

Definition at line 213 of file BasicVector3D.cc.

213 {
214 double sina = std::sin(a), cosa = std::cos(a), dz = z(), dx = x();
215 setZ(dz*cosa-dx*sina);
216 setX(dx*cosa+dz*sina);
217 return *this;
218 }

◆ rotateY() [2/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotateY ( float  a)
inherited

Rotates around y-axis.

◆ rotateY() [3/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotateY ( float  a)
inherited

Definition at line 57 of file BasicVector3D.cc.

57 {
58 double sina = std::sin(a), cosa = std::cos(a), dz = z(), dx = x();
59 setZ(dz*cosa-dx*sina);
60 setX(dx*cosa+dz*sina);
61 return *this;
62 }

◆ rotateZ() [1/3]

BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateZ ( double  a)
inherited

Definition at line 222 of file BasicVector3D.cc.

222 {
223 double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
224 setX(dx*cosa-dy*sina);
225 setY(dy*cosa+dx*sina);
226 return *this;
227 }

◆ rotateZ() [2/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotateZ ( float  a)
inherited

Rotates around z-axis.

◆ rotateZ() [3/3]

BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotateZ ( float  a)
inherited

Definition at line 66 of file BasicVector3D.cc.

66 {
67 double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
68 setX(dx*cosa-dy*sina);
69 setY(dy*cosa+dx*sina);
70 return *this;
71 }

◆ set()

void HepGeom::BasicVector3D< float >::set ( float  x1,
float  y1,
float  z1 
)
inlineinherited

Sets components in cartesian coordinate system.

Definition at line 167 of file BasicVector3D.h.

167{ v_[0] = x1; v_[1] = y1; v_[2] = z1; }

◆ setEta() [1/3]

void HepGeom::BasicVector3D< double >::setEta ( double  a)
inherited

Definition at line 178 of file BasicVector3D.cc.

178 {
179 double ma = mag();
180 if (ma == 0) return;
181 double tanHalfTheta = std::exp(-a);
182 double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
183 double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
184 double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
185 double ph = phi();
186 set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
187 }

◆ setEta() [2/3]

void HepGeom::BasicVector3D< float >::setEta ( float  a)
inherited

Sets pseudo-rapidity, keeping magnitude and phi fixed.

◆ setEta() [3/3]

void HepGeom::BasicVector3D< float >::setEta ( float  a)
inherited

Definition at line 22 of file BasicVector3D.cc.

22 {
23 double ma = mag();
24 if (ma == 0) return;
25 double tanHalfTheta = std::exp(-a);
26 double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
27 double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
28 double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
29 double ph = phi();
30 set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
31 }

◆ setMag()

void HepGeom::BasicVector3D< float >::setMag ( float  ma)
inlineinherited

Sets magnitude.

Definition at line 231 of file BasicVector3D.h.

231 {
232 T factor = mag();
233 if (factor > 0) {
234 factor = ma/factor; v_[0] *= factor; v_[1] *= factor; v_[2] *= factor;
235 }
236 }

◆ setPerp()

void HepGeom::BasicVector3D< float >::setPerp ( float  rh)
inlineinherited

Sets transverse component keeping phi and z constant.

Definition at line 185 of file BasicVector3D.h.

185 {
186 T factor = perp();
187 if (factor > 0) {
188 factor = rh/factor; v_[0] *= factor; v_[1] *= factor;
189 }
190 }

◆ setPhi()

void HepGeom::BasicVector3D< float >::setPhi ( float  ph)
inlineinherited

Sets phi-component in spherical coordinate system.

Definition at line 242 of file BasicVector3D.h.

242{ T xy = perp(); setX(xy*std::cos(ph)); setY(xy*std::sin(ph)); }

◆ setR()

void HepGeom::BasicVector3D< float >::setR ( float  ma)
inlineinherited

Sets r-component in spherical coordinate system.

Definition at line 239 of file BasicVector3D.h.

239{ setMag(ma); }

◆ setTheta()

void HepGeom::BasicVector3D< float >::setTheta ( float  th)
inlineinherited

Sets theta-component in spherical coordinate system.

Definition at line 245 of file BasicVector3D.h.

245 {
246 T ma = mag();
247 T ph = phi();
248 set(ma*std::sin(th)*std::cos(ph), ma*std::sin(th)*std::sin(ph), ma*std::cos(th));
249 }

◆ setX()

void HepGeom::BasicVector3D< float >::setX ( float  a)
inlineinherited

Sets x-component in cartesian coordinate system.

Definition at line 157 of file BasicVector3D.h.

157{ v_[0] = a; }

◆ setY()

void HepGeom::BasicVector3D< float >::setY ( float  a)
inlineinherited

Sets y-component in cartesian coordinate system.

Definition at line 160 of file BasicVector3D.h.

160{ v_[1] = a; }

◆ setZ()

void HepGeom::BasicVector3D< float >::setZ ( float  a)
inlineinherited

Sets z-component in cartesian coordinate system.

Definition at line 163 of file BasicVector3D.h.

163{ v_[2] = a; }

◆ theta()

float HepGeom::BasicVector3D< float >::theta ( ) const
inlineinherited

Gets polar angle.

Definition at line 212 of file BasicVector3D.h.

212 {
213 return x() == 0 && y() == 0 && z() == 0 ? 0 : std::atan2(perp(),z());
214 }

◆ transform()

Normal3D< float > & HepGeom::Normal3D< float >::transform ( const Transform3D m)

Transformation by Transform3D.

Definition at line 10 of file Normal3D.cc.

10 {
11 double vx = x(), vy = y(), vz = z();
12 double xx = m.xx(), xy = m.xy(), xz = m.xz();
13 double yx = m.yx(), yy = m.yy(), yz = m.yz();
14 double zx = m.zx(), zy = m.zy(), zz = m.zz();
15 set((yy*zz-yz*zy)*vx+(yz*zx-yx*zz)*vy+(yx*zy-yy*zx)*vz,
16 (zy*xz-zz*xy)*vx+(zz*xx-zx*xz)*vy+(zx*xy-zy*xx)*vz,
17 (xy*yz-xz*yy)*vx+(xz*yx-xx*yz)*vy+(xx*yy-xy*yx)*vz);
18 return *this;
19 }
static constexpr double m
Definition: G4SIunits.hh:109
void set(float x1, float y1, float z1)

References m, HepGeom::BasicVector3D< T >::set(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

◆ unit()

BasicVector3D< float > HepGeom::BasicVector3D< float >::unit ( ) const
inlineinherited

Returns unit vector parallel to this.

Definition at line 310 of file BasicVector3D.h.

310 {
311 T len = mag();
312 return (len > 0) ?
313 BasicVector3D<T>(x()/len, y()/len, z()/len) : BasicVector3D<T>();
314 }

◆ x()

float HepGeom::BasicVector3D< float >::x ( ) const
inlineinherited

Gets x-component in cartesian coordinate system.

Definition at line 147 of file BasicVector3D.h.

147{ return v_[0]; }

◆ y()

float HepGeom::BasicVector3D< float >::y ( ) const
inlineinherited

Gets y-component in cartesian coordinate system.

Definition at line 150 of file BasicVector3D.h.

150{ return v_[1]; }

◆ z()

float HepGeom::BasicVector3D< float >::z ( ) const
inlineinherited

Gets z-component in cartesian coordinate system.

Definition at line 153 of file BasicVector3D.h.

153{ return v_[2]; }

Friends And Related Function Documentation

◆ operator!=() [1/2]

bool operator!= ( const BasicVector3D< double > &  a,
const BasicVector3D< double > &  b 
)
related

Comparison of two vectors for inequality.

Definition at line 562 of file BasicVector3D.h.

563 {
564 return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
565 }

◆ operator!=() [2/2]

bool operator!= ( const BasicVector3D< float > &  a,
const BasicVector3D< float > &  b 
)
related

Comparison of two vectors for inequality.

Definition at line 453 of file BasicVector3D.h.

453 {
454 return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
455 }

◆ operator*() [1/6]

double operator* ( const BasicVector3D< double > &  a,
const BasicVector3D< double > &  b 
)
related

Scalar product of two vectors.

Definition at line 525 of file BasicVector3D.h.

525 {
526 return a.dot(b);
527 }

◆ operator*() [2/6]

BasicVector3D< double > operator* ( const BasicVector3D< double > &  v,
double  a 
)
related

Multiplication vector by scalar.

Definition at line 516 of file BasicVector3D.h.

516 {
517 return BasicVector3D<double>(v.x()*a, v.y()*a, v.z()*a);
518 }

◆ operator*() [3/6]

float operator* ( const BasicVector3D< float > &  a,
const BasicVector3D< float > &  b 
)
related

Scalar product of two vectors.

Definition at line 417 of file BasicVector3D.h.

417 {
418 return a.dot(b);
419 }

◆ operator*() [4/6]

BasicVector3D< float > operator* ( const BasicVector3D< float > &  v,
double  a 
)
related

Multiplication vector by scalar.

Definition at line 408 of file BasicVector3D.h.

408 {
409 return BasicVector3D<float>(v.x()*static_cast<float>(a), v.y()*static_cast<float>(a), v.z()*static_cast<float>(a));
410 }

◆ operator*() [5/6]

BasicVector3D< double > operator* ( double  a,
const BasicVector3D< double > &  v 
)
related

Multiplication scalar by vector.

Definition at line 534 of file BasicVector3D.h.

534 {
535 return BasicVector3D<double>(a*v.x(), a*v.y(), a*v.z());
536 }

◆ operator*() [6/6]

BasicVector3D< float > operator* ( double  a,
const BasicVector3D< float > &  v 
)
related

Multiplication scalar by vector.

Definition at line 426 of file BasicVector3D.h.

426 {
427 return BasicVector3D<float>(static_cast<float>(a)*v.x(), static_cast<float>(a)*v.y(), static_cast<float>(a)*v.z());
428 }

◆ operator+() [1/4]

BasicVector3D< double > operator+ ( const BasicVector3D< double > &  a,
const BasicVector3D< double > &  b 
)
related

Addition of two vectors.

Definition at line 489 of file BasicVector3D.h.

489 {
490 return BasicVector3D<double>(a.x()+b.x(), a.y()+b.y(), a.z()+b.z());
491 }

◆ operator+() [2/4]

BasicVector3D< double > operator+ ( const BasicVector3D< double > &  v)
related

Unary plus.

Definition at line 482 of file BasicVector3D.h.

482{ return v; }

◆ operator+() [3/4]

BasicVector3D< float > operator+ ( const BasicVector3D< float > &  a,
const BasicVector3D< float > &  b 
)
related

Addition of two vectors.

Definition at line 381 of file BasicVector3D.h.

381 {
382 return BasicVector3D<float>(a.x()+b.x(), a.y()+b.y(), a.z()+b.z());
383 }

◆ operator+() [4/4]

BasicVector3D< float > operator+ ( const BasicVector3D< float > &  v)
related

Unary plus.

Definition at line 374 of file BasicVector3D.h.

374{ return v; }

◆ operator-() [1/4]

BasicVector3D< double > operator- ( const BasicVector3D< double > &  a,
const BasicVector3D< double > &  b 
)
related

Subtraction of two vectors.

Definition at line 507 of file BasicVector3D.h.

507 {
508 return BasicVector3D<double>(a.x()-b.x(), a.y()-b.y(), a.z()-b.z());
509 }

◆ operator-() [2/4]

BasicVector3D< double > operator- ( const BasicVector3D< double > &  v)
related

Unary minus.

Definition at line 498 of file BasicVector3D.h.

498 {
499 return BasicVector3D<double>(-v.x(), -v.y(), -v.z());
500 }

◆ operator-() [3/4]

BasicVector3D< float > operator- ( const BasicVector3D< float > &  a,
const BasicVector3D< float > &  b 
)
related

Subtraction of two vectors.

Definition at line 399 of file BasicVector3D.h.

399 {
400 return BasicVector3D<float>(a.x()-b.x(), a.y()-b.y(), a.z()-b.z());
401 }

◆ operator-() [4/4]

BasicVector3D< float > operator- ( const BasicVector3D< float > &  v)
related

Unary minus.

Definition at line 390 of file BasicVector3D.h.

390 {
391 return BasicVector3D<float>(-v.x(), -v.y(), -v.z());
392 }

◆ operator/() [1/2]

BasicVector3D< double > operator/ ( const BasicVector3D< double > &  v,
double  a 
)
related

Division vector by scalar.

Definition at line 543 of file BasicVector3D.h.

543 {
544 return BasicVector3D<double>(v.x()/a, v.y()/a, v.z()/a);
545 }

◆ operator/() [2/2]

BasicVector3D< float > operator/ ( const BasicVector3D< float > &  v,
double  a 
)
related

Division vector by scalar.

Definition at line 435 of file BasicVector3D.h.

435 {
436 return BasicVector3D<float>(v.x()/static_cast<float>(a), v.y()/static_cast<float>(a), v.z()/static_cast<float>(a));
437 }

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  ,
const BasicVector3D< double > &   
)
related

Output to stream.

Definition at line 467 of file BasicVector3D.cc.

263 {
264 return os << "(" << a.x() << "," << a.y() << "," << a.z() << ")";
265 }

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  ,
const BasicVector3D< float > &   
)
related

Output to stream.

Definition at line 359 of file BasicVector3D.cc.

107 {
108 return os << "(" << a.x() << "," << a.y() << "," << a.z() << ")";
109 }

◆ operator==() [1/2]

bool operator== ( const BasicVector3D< double > &  a,
const BasicVector3D< double > &  b 
)
related

Comparison of two vectors for equality.

Definition at line 552 of file BasicVector3D.h.

553 {
554 return (a.x()==b.x() && a.y()==b.y() && a.z()==b.z());
555 }

◆ operator==() [2/2]

bool operator== ( const BasicVector3D< float > &  a,
const BasicVector3D< float > &  b 
)
related

Comparison of two vectors for equality.

Definition at line 444 of file BasicVector3D.h.

444 {
445 return (a.x()==b.x() && a.y()==b.y() && a.z()==b.z());
446 }

◆ operator>>() [1/2]

std::istream & operator>> ( std::istream &  ,
BasicVector3D< double > &   
)
related

Input from stream.

Definition at line 475 of file BasicVector3D.cc.

270 {
271 // Required format is ( a, b, c ) that is, three numbers, preceded by
272 // (, followed by ), and separated by commas. The three numbers are
273 // taken as x, y, z.
274
275 double x, y, z;
276 char c;
277
278 is >> std::ws >> c;
279 // ws is defined to invoke eatwhite(istream & )
280 // see (Stroustrup gray book) page 333 and 345.
281 if (is.fail() || c != '(' ) {
282 std::cerr
283 << "Could not find required opening parenthesis "
284 << "in input of a BasicVector3D<double>"
285 << std::endl;
286 return is;
287 }
288
289 is >> x >> std::ws >> c;
290 if (is.fail() || c != ',' ) {
291 std::cerr
292 << "Could not find x value and required trailing comma "
293 << "in input of a BasicVector3D<double>"
294 << std::endl;
295 return is;
296 }
297
298 is >> y >> std::ws >> c;
299 if (is.fail() || c != ',' ) {
300 std::cerr
301 << "Could not find y value and required trailing comma "
302 << "in input of a BasicVector3D<double>"
303 << std::endl;
304 return is;
305 }
306
307 is >> z >> std::ws >> c;
308 if (is.fail() || c != ')' ) {
309 std::cerr
310 << "Could not find z value and required close parenthesis "
311 << "in input of a BasicVector3D<double>"
312 << std::endl;
313 return is;
314 }
315
316 a.setX(x);
317 a.setY(y);
318 a.setZ(z);
319 return is;
320 }

◆ operator>>() [2/2]

std::istream & operator>> ( std::istream &  ,
BasicVector3D< float > &   
)
related

Input from stream.

Definition at line 367 of file BasicVector3D.cc.

114 {
115 // Required format is ( a, b, c ) that is, three numbers, preceded by
116 // (, followed by ), and separated by commas. The three numbers are
117 // taken as x, y, z.
118
119 float x, y, z;
120 char c;
121
122 is >> std::ws >> c;
123 // ws is defined to invoke eatwhite(istream & )
124 // see (Stroustrup gray book) page 333 and 345.
125 if (is.fail() || c != '(' ) {
126 std::cerr
127 << "Could not find required opening parenthesis "
128 << "in input of a BasicVector3D<float>"
129 << std::endl;
130 return is;
131 }
132
133 is >> x >> std::ws >> c;
134 if (is.fail() || c != ',' ) {
135 std::cerr
136 << "Could not find x value and required trailing comma "
137 << "in input of a BasicVector3D<float>"
138 << std::endl;
139 return is;
140 }
141
142 is >> y >> std::ws >> c;
143 if (is.fail() || c != ',' ) {
144 std::cerr
145 << "Could not find y value and required trailing comma "
146 << "in input of a BasicVector3D<float>"
147 << std::endl;
148 return is;
149 }
150
151 is >> z >> std::ws >> c;
152 if (is.fail() || c != ')' ) {
153 std::cerr
154 << "Could not find z value and required close parenthesis "
155 << "in input of a BasicVector3D<float>"
156 << std::endl;
157 return is;
158 }
159
160 a.setX(x);
161 a.setY(y);
162 a.setZ(z);
163 return is;
164 }

Field Documentation

◆ v_

float HepGeom::BasicVector3D< float >::v_[3]
protectedinherited

Definition at line 29 of file BasicVector3D.h.


The documentation for this class was generated from the following files: