Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HepGeom::BasicVector3D< T > Class Template Reference

#include <BasicVector3D.h>

Inheritance diagram for HepGeom::BasicVector3D< T >:
Collaboration diagram for HepGeom::BasicVector3D< T >:

Public Types

enum  {
  X = 0, Y = 1, Z = 2, NUM_COORDINATES = 3,
  SIZE = NUM_COORDINATES
}
 

Public Member Functions

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

Protected Member Functions

 BasicVector3D ()
 

Protected Attributes

v_ [3]
 

Related Functions

(Note that these are not member functions.)

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

Detailed Description

template<class T>
class HepGeom::BasicVector3D< T >

Base class for Point3D<T>, Vector3D<T> and Normal3D<T>. It defines only common functionality for those classes and should not be used as separate class.

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

Definition at line 27 of file BasicVector3D.h.

Member Enumeration Documentation

template<class T>
anonymous enum

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

Enumerator
X 

index for x-component

Y 

index for y-component

Z 

index for z-component

NUM_COORDINATES 

number of components

SIZE 

number of components

Definition at line 41 of file BasicVector3D.h.

Constructor & Destructor Documentation

template<class T>
HepGeom::BasicVector3D< T >::BasicVector3D ( )
inlineprotected

Default constructor. It is protected - this class should not be instantiated directly.

Definition at line 35 of file BasicVector3D.h.

35 { v_[0] = 0; v_[1] = 0; v_[2] = 0; }
template<class T>
HepGeom::BasicVector3D< T >::BasicVector3D ( x1,
y1,
z1 
)
inline

Constructor from three numbers.

Definition at line 51 of file BasicVector3D.h.

51 { v_[0] = x1; v_[1] = y1; v_[2] = z1; }
template<class T>
HepGeom::BasicVector3D< T >::BasicVector3D ( const BasicVector3D< float > &  v)
inline

Copy constructor. Note: BasicVector3D<double> has constructors from BasicVector3D<double> (provided by compiler) and from BasicVector3D<float> (defined in this file); BasicVector3D<float> has only the last one.

Definition at line 60 of file BasicVector3D.h.

60  {
61  v_[0] = v.x(); v_[1] = v.y(); v_[2] = v.z();
62  }
template<class T>
virtual HepGeom::BasicVector3D< T >::~BasicVector3D ( )
inlinevirtual

Destructor.

Definition at line 66 of file BasicVector3D.h.

66 {}

Member Function Documentation

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

Definition at line 36 of file BasicVector3D.cc.

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

Here is the call graph for this function:

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

Definition at line 192 of file BasicVector3D.cc.

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

Here is the call graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::angle ( const BasicVector3D< T > &  v) const

Returns angle w.r.t. another vector.

template<class T>
T HepGeom::BasicVector3D< T >::cosTheta ( ) const
inline

Gets cosine of polar angle.

Definition at line 211 of file BasicVector3D.h.

211 { T ma = mag(); return ma == 0 ? 1 : z()/ma; }
template<class T>
BasicVector3D<T> HepGeom::BasicVector3D< T >::cross ( const BasicVector3D< T > &  v) const
inline

Vector product.

Definition at line 275 of file BasicVector3D.h.

275  {
276  return BasicVector3D<T>(y()*v.z()-v.y()*z(),
277  z()*v.x()-v.z()*x(),
278  x()*v.y()-v.x()*y());
279  }
tuple v
Definition: test.py:18

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::dot ( const BasicVector3D< T > &  v) const
inline

Scalar product.

Definition at line 269 of file BasicVector3D.h.

269  {
270  return x()*v.x()+y()*v.y()+z()*v.z();
271  }
tuple v
Definition: test.py:18

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::eta ( ) const
inline

Gets pseudo-rapidity.

Definition at line 254 of file BasicVector3D.h.

254 { return pseudoRapidity(); }

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::getEta ( ) const
inline

Gets pseudo-rapidity.

Definition at line 257 of file BasicVector3D.h.

257 { return pseudoRapidity(); }
template<class T>
T HepGeom::BasicVector3D< T >::getPhi ( ) const
inline

Gets phi-component in spherical coordinate system

Definition at line 218 of file BasicVector3D.h.

218 { return phi(); }
template<class T>
T HepGeom::BasicVector3D< T >::getR ( ) const
inline

Gets r-component in spherical coordinate system

Definition at line 215 of file BasicVector3D.h.

215 { return r(); }
template<class T>
T HepGeom::BasicVector3D< T >::getTheta ( ) const
inline

Gets theta-component in spherical coordinate system

Definition at line 221 of file BasicVector3D.h.

221 { return theta(); }
template<class T>
T HepGeom::BasicVector3D< T >::mag ( ) const
inline

Gets magnitude of the vector.

Definition at line 195 of file BasicVector3D.h.

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

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::mag2 ( ) const
inline

Gets magnitude squared of the vector.

Definition at line 192 of file BasicVector3D.h.

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

Here is the caller graph for this function:

template<class T>
HepGeom::BasicVector3D< T >::operator CLHEP::Hep3Vector ( ) const
inline

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

Definition at line 85 of file BasicVector3D.h.

template<class T>
HepGeom::BasicVector3D< T >::operator const T * ( ) const
inline

Conversion (cast) to ordinary const array.

Definition at line 78 of file BasicVector3D.h.

78 { return v_; }
template<class T>
HepGeom::BasicVector3D< T >::operator T * ( )
inline

Conversion (cast) to ordinary array.

Definition at line 74 of file BasicVector3D.h.

74 { return v_; }
template<class T>
T HepGeom::BasicVector3D< T >::operator() ( int  i) const
inline

Gets components by index.

Definition at line 123 of file BasicVector3D.h.

123 { return v_[i]; }
template<class T>
T& HepGeom::BasicVector3D< T >::operator() ( int  i)
inline

Sets components by index.

Definition at line 130 of file BasicVector3D.h.

130 { return v_[i]; }
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::operator*= ( double  a)
inline

Multiplication by scalar.

Definition at line 108 of file BasicVector3D.h.

108  {
109  v_[0] *= a; v_[1] *= a; v_[2] *= a; return *this;
110  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::operator+= ( const BasicVector3D< T > &  v)
inline

Addition.

Definition at line 98 of file BasicVector3D.h.

98  {
99  v_[0] += v.v_[0]; v_[1] += v.v_[1]; v_[2] += v.v_[2]; return *this;
100  }
tuple v
Definition: test.py:18
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::operator-= ( const BasicVector3D< T > &  v)
inline

Subtraction.

Definition at line 103 of file BasicVector3D.h.

103  {
104  v_[0] -= v.v_[0]; v_[1] -= v.v_[1]; v_[2] -= v.v_[2]; return *this;
105  }
tuple v
Definition: test.py:18
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::operator/= ( double  a)
inline

Division by scalar.

Definition at line 113 of file BasicVector3D.h.

113  {
114  v_[0] /= a; v_[1] /= a; v_[2] /= a; return *this;
115  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::operator= ( const BasicVector3D< T > &  v)
inline

Assignment.

Definition at line 93 of file BasicVector3D.h.

93  {
94  v_[0] = v.v_[0]; v_[1] = v.v_[1]; v_[2] = v.v_[2]; return *this;
95  }
tuple v
Definition: test.py:18
template<class T>
T HepGeom::BasicVector3D< T >::operator[] ( int  i) const
inline

Gets components by index.

Definition at line 126 of file BasicVector3D.h.

126 { return v_[i]; }
template<class T>
T& HepGeom::BasicVector3D< T >::operator[] ( int  i)
inline

Sets components by index.

Definition at line 133 of file BasicVector3D.h.

133 { return v_[i]; }
template<class T>
BasicVector3D<T> HepGeom::BasicVector3D< T >::orthogonal ( ) const
inline

Returns orthogonal vector.

Definition at line 312 of file BasicVector3D.h.

312  {
313  T dx = x() < 0 ? -x() : x();
314  T dy = y() < 0 ? -y() : y();
315  T dz = z() < 0 ? -z() : z();
316  if (dx < dy) {
317  return dx < dz ?
318  BasicVector3D<T>(0,z(),-y()) : BasicVector3D<T>(y(),-x(),0);
319  }else{
320  return dy < dz ?
321  BasicVector3D<T>(-z(),0,x()) : BasicVector3D<T>(y(),-x(),0);
322  }
323  }
template<class T>
T HepGeom::BasicVector3D< T >::perp ( ) const
inline

Gets transverse component.

Definition at line 172 of file BasicVector3D.h.

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

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::perp ( const BasicVector3D< T > &  v) const
inline

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

Definition at line 290 of file BasicVector3D.h.

290  {
291  return std::sqrt(perp2(v));
292  }
tuple v
Definition: test.py:18
template<class T>
T HepGeom::BasicVector3D< T >::perp2 ( ) const
inline

Gets transverse component squared.

Definition at line 169 of file BasicVector3D.h.

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

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::perp2 ( const BasicVector3D< T > &  v) const
inline

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

Definition at line 283 of file BasicVector3D.h.

283  {
284  T tot = v.mag2(), s = dot(v);
285  return tot > 0 ? mag2()-s*s/tot : mag2();
286  }
const XML_Char * s
Definition: expat.h:262
tuple v
Definition: test.py:18
T dot(const BasicVector3D< T > &v) const
template<class T>
T HepGeom::BasicVector3D< T >::phi ( ) const
inline

Gets azimuth angle.

Definition at line 201 of file BasicVector3D.h.

201  {
202  return x() == 0 && y() == 0 ? 0 : std::atan2(y(),x());
203  }

Here is the caller graph for this function:

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

Definition at line 13 of file BasicVector3D.cc.

13  {
14  float ma = mag(), dz = z();
15  if (ma == 0) return 0;
16  if (ma == dz) return FLT_MAX;
17  if (ma == -dz) return -FLT_MAX;
18  return 0.5*std::log((ma+dz)/(ma-dz));
19  }
#define FLT_MAX
Definition: templates.hh:99
template<>
double HepGeom::BasicVector3D< double >::pseudoRapidity ( ) const

Definition at line 169 of file BasicVector3D.cc.

169  {
170  double ma = mag(), dz = z();
171  if (ma == 0) return 0;
172  if (ma == dz) return DBL_MAX;
173  if (ma == -dz) return -DBL_MAX;
174  return 0.5*std::log((ma+dz)/(ma-dz));
175  }
#define DBL_MAX
Definition: templates.hh:83
template<class T>
T HepGeom::BasicVector3D< T >::pseudoRapidity ( ) const

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

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::r ( ) const
inline

Gets r-component in spherical coordinate system

Definition at line 198 of file BasicVector3D.h.

198 { return mag(); }

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::rho ( ) const
inline

Gets rho-component in cylindrical coordinate system

Definition at line 175 of file BasicVector3D.h.

175 { return perp(); }

Here is the caller graph for this function:

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

Definition at line 77 of file BasicVector3D.cc.

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

Here is the call graph for this function:

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

Definition at line 233 of file BasicVector3D.cc.

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

Here is the call graph for this function:

template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::rotate ( a,
const BasicVector3D< T > &  v 
)

Rotates around the axis specified by another vector.

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

Definition at line 49 of file BasicVector3D.cc.

49  {
50  double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = z();
51  setY(dy*cosa-dz*sina);
52  setZ(dz*cosa+dy*sina);
53  return *this;
54  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<>
BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateX ( double  a)

Definition at line 205 of file BasicVector3D.cc.

205  {
206  double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = z();
207  setY(dy*cosa-dz*sina);
208  setZ(dz*cosa+dy*sina);
209  return *this;
210  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::rotateX ( a)

Rotates around x-axis.

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

Definition at line 58 of file BasicVector3D.cc.

58  {
59  double sina = std::sin(a), cosa = std::cos(a), dz = z(), dx = x();
60  setZ(dz*cosa-dx*sina);
61  setX(dx*cosa+dz*sina);
62  return *this;
63  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<>
BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateY ( double  a)

Definition at line 214 of file BasicVector3D.cc.

214  {
215  double sina = std::sin(a), cosa = std::cos(a), dz = z(), dx = x();
216  setZ(dz*cosa-dx*sina);
217  setX(dx*cosa+dz*sina);
218  return *this;
219  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::rotateY ( a)

Rotates around y-axis.

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

Definition at line 67 of file BasicVector3D.cc.

67  {
68  double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
69  setX(dx*cosa-dy*sina);
70  setY(dy*cosa+dx*sina);
71  return *this;
72  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<>
BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateZ ( double  a)

Definition at line 223 of file BasicVector3D.cc.

223  {
224  double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
225  setX(dx*cosa-dy*sina);
226  setY(dy*cosa+dx*sina);
227  return *this;
228  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
BasicVector3D<T>& HepGeom::BasicVector3D< T >::rotateZ ( a)

Rotates around z-axis.

template<class T>
void HepGeom::BasicVector3D< T >::set ( x1,
y1,
z1 
)
inline

Sets components in cartesian coordinate system.

Definition at line 161 of file BasicVector3D.h.

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

Here is the caller graph for this function:

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

Definition at line 23 of file BasicVector3D.cc.

23  {
24  double ma = mag();
25  if (ma == 0) return;
26  double tanHalfTheta = std::exp(-a);
27  double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
28  double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
29  double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
30  double ph = phi();
31  set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
32  }
void set(T x1, T y1, T z1)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<>
void HepGeom::BasicVector3D< double >::setEta ( double  a)

Definition at line 179 of file BasicVector3D.cc.

179  {
180  double ma = mag();
181  if (ma == 0) return;
182  double tanHalfTheta = std::exp(-a);
183  double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
184  double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
185  double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
186  double ph = phi();
187  set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
188  }
void set(T x1, T y1, T z1)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
void HepGeom::BasicVector3D< T >::setEta ( a)

Sets pseudo-rapidity, keeping magnitude and phi fixed.

template<class T>
void HepGeom::BasicVector3D< T >::setMag ( ma)
inline

Sets magnitude.

Definition at line 225 of file BasicVector3D.h.

225  {
226  T factor = mag();
227  if (factor > 0) {
228  factor = ma/factor; v_[0] *= factor; v_[1] *= factor; v_[2] *= factor;
229  }
230  }

Here is the caller graph for this function:

template<class T>
void HepGeom::BasicVector3D< T >::setPerp ( rh)
inline

Sets transverse component keeping phi and z constant.

Definition at line 179 of file BasicVector3D.h.

179  {
180  T factor = perp();
181  if (factor > 0) {
182  factor = rh/factor; v_[0] *= factor; v_[1] *= factor;
183  }
184  }
template<class T>
void HepGeom::BasicVector3D< T >::setPhi ( ph)
inline

Sets phi-component in spherical coordinate system.

Definition at line 236 of file BasicVector3D.h.

236 { T xy = perp(); setX(xy*std::cos(ph)); setY(xy*std::sin(ph)); }
template<class T>
void HepGeom::BasicVector3D< T >::setR ( ma)
inline

Sets r-component in spherical coordinate system.

Definition at line 233 of file BasicVector3D.h.

233 { setMag(ma); }
template<class T>
void HepGeom::BasicVector3D< T >::setTheta ( th)
inline

Sets theta-component in spherical coordinate system.

Definition at line 239 of file BasicVector3D.h.

239  {
240  T ma = mag();
241  T ph = phi();
242  set(ma*std::sin(th)*std::cos(ph), ma*std::sin(th)*std::sin(ph), ma*std::cos(th));
243  }
void set(T x1, T y1, T z1)
template<class T>
void HepGeom::BasicVector3D< T >::setX ( a)
inline

Sets x-component in cartesian coordinate system.

Definition at line 151 of file BasicVector3D.h.

151 { v_[0] = a; }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the caller graph for this function:

template<class T>
void HepGeom::BasicVector3D< T >::setY ( a)
inline

Sets y-component in cartesian coordinate system.

Definition at line 154 of file BasicVector3D.h.

154 { v_[1] = a; }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the caller graph for this function:

template<class T>
void HepGeom::BasicVector3D< T >::setZ ( a)
inline

Sets z-component in cartesian coordinate system.

Definition at line 157 of file BasicVector3D.h.

157 { v_[2] = a; }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::theta ( ) const
inline

Gets polar angle.

Definition at line 206 of file BasicVector3D.h.

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

Here is the caller graph for this function:

template<class T>
BasicVector3D<T> HepGeom::BasicVector3D< T >::unit ( ) const
inline

Returns unit vector parallel to this.

Definition at line 304 of file BasicVector3D.h.

304  {
305  T len = mag();
306  return (len > 0) ?
307  BasicVector3D<T>(x()/len, y()/len, z()/len) : BasicVector3D<T>();
308  }
const XML_Char int len
Definition: expat.h:262

Here is the caller graph for this function:

template<class T>
T HepGeom::BasicVector3D< T >::x ( ) const
inline

Gets x-component in cartesian coordinate system.

Definition at line 141 of file BasicVector3D.h.

141 { return v_[0]; }
template<class T>
T HepGeom::BasicVector3D< T >::y ( ) const
inline

Gets y-component in cartesian coordinate system.

Definition at line 144 of file BasicVector3D.h.

144 { return v_[1]; }
template<class T>
T HepGeom::BasicVector3D< T >::z ( ) const
inline

Gets z-component in cartesian coordinate system.

Definition at line 147 of file BasicVector3D.h.

147 { return v_[2]; }

Friends And Related Function Documentation

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

Comparison of two vectors for inequality.

Definition at line 447 of file BasicVector3D.h.

447  {
448  return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
449  }

Here is the call graph for this function:

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

Comparison of two vectors for inequality.

Definition at line 556 of file BasicVector3D.h.

557  {
558  return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
559  }

Here is the call graph for this function:

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

Multiplication vector by scalar.

Definition at line 402 of file BasicVector3D.h.

402  {
403  return BasicVector3D<float>(v.x()*static_cast<float>(a), v.y()*static_cast<float>(a), v.z()*static_cast<float>(a));
404  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the call graph for this function:

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

Scalar product of two vectors.

Definition at line 411 of file BasicVector3D.h.

411  {
412  return a.dot(b);
413  }
T dot(const BasicVector3D< T > &v) const

Here is the call graph for this function:

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

Multiplication scalar by vector.

Definition at line 420 of file BasicVector3D.h.

420  {
421  return BasicVector3D<float>(static_cast<float>(a)*v.x(), static_cast<float>(a)*v.y(), static_cast<float>(a)*v.z());
422  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the call graph for this function:

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

Multiplication vector by scalar.

Definition at line 510 of file BasicVector3D.h.

510  {
511  return BasicVector3D<double>(v.x()*a, v.y()*a, v.z()*a);
512  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the call graph for this function:

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

Scalar product of two vectors.

Definition at line 519 of file BasicVector3D.h.

519  {
520  return a.dot(b);
521  }
T dot(const BasicVector3D< T > &v) const

Here is the call graph for this function:

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

Multiplication scalar by vector.

Definition at line 528 of file BasicVector3D.h.

528  {
529  return BasicVector3D<double>(a*v.x(), a*v.y(), a*v.z());
530  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the call graph for this function:

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

Unary plus.

Definition at line 368 of file BasicVector3D.h.

368 { return v; }
tuple v
Definition: test.py:18
template<class T>
BasicVector3D< float > operator+ ( const BasicVector3D< float > &  a,
const BasicVector3D< float > &  b 
)
related

Addition of two vectors.

Definition at line 375 of file BasicVector3D.h.

375  {
376  return BasicVector3D<float>(a.x()+b.x(), a.y()+b.y(), a.z()+b.z());
377  }

Here is the call graph for this function:

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

Unary plus.

Definition at line 476 of file BasicVector3D.h.

476 { return v; }
tuple v
Definition: test.py:18
template<class T>
BasicVector3D< double > operator+ ( const BasicVector3D< double > &  a,
const BasicVector3D< double > &  b 
)
related

Addition of two vectors.

Definition at line 483 of file BasicVector3D.h.

483  {
484  return BasicVector3D<double>(a.x()+b.x(), a.y()+b.y(), a.z()+b.z());
485  }

Here is the call graph for this function:

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

Unary minus.

Definition at line 384 of file BasicVector3D.h.

384  {
385  return BasicVector3D<float>(-v.x(), -v.y(), -v.z());
386  }

Here is the call graph for this function:

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

Subtraction of two vectors.

Definition at line 393 of file BasicVector3D.h.

393  {
394  return BasicVector3D<float>(a.x()-b.x(), a.y()-b.y(), a.z()-b.z());
395  }

Here is the call graph for this function:

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

Unary minus.

Definition at line 492 of file BasicVector3D.h.

492  {
493  return BasicVector3D<double>(-v.x(), -v.y(), -v.z());
494  }

Here is the call graph for this function:

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

Subtraction of two vectors.

Definition at line 501 of file BasicVector3D.h.

501  {
502  return BasicVector3D<double>(a.x()-b.x(), a.y()-b.y(), a.z()-b.z());
503  }

Here is the call graph for this function:

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

Division vector by scalar.

Definition at line 429 of file BasicVector3D.h.

429  {
430  return BasicVector3D<float>(v.x()/static_cast<float>(a), v.y()/static_cast<float>(a), v.z()/static_cast<float>(a));
431  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the call graph for this function:

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

Division vector by scalar.

Definition at line 537 of file BasicVector3D.h.

537  {
538  return BasicVector3D<double>(v.x()/a, v.y()/a, v.z()/a);
539  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33

Here is the call graph for this function:

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

Output to stream.

Definition at line 107 of file BasicVector3D.cc.

108  {
109  return os << "(" << a.x() << "," << a.y() << "," << a.z() << ")";
110  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
std::ostream & operator<< ( std::ostream &  ,
const BasicVector3D< double > &   
)
related

Output to stream.

Definition at line 263 of file BasicVector3D.cc.

264  {
265  return os << "(" << a.x() << "," << a.y() << "," << a.z() << ")";
266  }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
template<class T>
bool operator== ( const BasicVector3D< float > &  a,
const BasicVector3D< float > &  b 
)
related

Comparison of two vectors for equality.

Definition at line 438 of file BasicVector3D.h.

438  {
439  return (a.x()==b.x() && a.y()==b.y() && a.z()==b.z());
440  }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Comparison of two vectors for equality.

Definition at line 546 of file BasicVector3D.h.

547  {
548  return (a.x()==b.x() && a.y()==b.y() && a.z()==b.z());
549  }

Here is the call graph for this function:

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

Input from stream.

Definition at line 114 of file BasicVector3D.cc.

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

Input from stream.

Definition at line 270 of file BasicVector3D.cc.

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

Member Data Documentation

template<class T>
T HepGeom::BasicVector3D< T >::v_[3]
protected

Definition at line 29 of file BasicVector3D.h.


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