Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Related Functions
HepGeom::BasicVector3D< T > Class Template Reference

#include <BasicVector3D.h>

Inheritance diagram for HepGeom::BasicVector3D< T >:
HepGeom::Normal3D< T > HepGeom::Point3D< T > HepGeom::Vector3D< 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

index for x-component

index for y-component

index for z-component

NUM_COORDINATES 

number of components

SIZE 

number of components

Definition at line 41 of file BasicVector3D.h.

41  {
42  X = 0, /**< index for x-component */
43  Y = 1, /**< index for y-component */
44  Z = 2, /**< index for z-component */
45  NUM_COORDINATES = 3, /**< number of components */
46  SIZE = NUM_COORDINATES /**< number of components */
47  };

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.

References HepGeom::BasicVector3D< T >::mag().

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
template<>
double HepGeom::BasicVector3D< double >::angle ( const BasicVector3D< double > &  v) const

Definition at line 192 of file BasicVector3D.cc.

References HepGeom::BasicVector3D< T >::mag().

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
template<class T>
T HepGeom::BasicVector3D< T >::angle ( const BasicVector3D< T > &  v) const

Returns angle w.r.t. another vector.

Referenced by phobo3(), phodo(), phoro2(), and phoro3().

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
template<class T>
T HepGeom::BasicVector3D< T >::dot ( const BasicVector3D< T > &  v) const
inline

Scalar product.

Definition at line 269 of file BasicVector3D.h.

Referenced by G4VSceneHandler::CreateSectionSolid(), HepGeom::BasicVector3D< T >::operator*(), HepGeom::BasicVector3D< G4double >::perp2(), and pyqqbh().

269  {
270  return x()*v.x()+y()*v.y()+z()*v.z();
271  }
template<class T>
T HepGeom::BasicVector3D< T >::eta ( ) const
inline

Gets pseudo-rapidity.

Definition at line 254 of file BasicVector3D.h.

Referenced by betrej(), dbetar(), dgamrn(), drcmu(), hisout(), lucell(), pycell(), and pyxtot().

254 { return pseudoRapidity(); }
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
template<class T>
T HepGeom::BasicVector3D< T >::mag2 ( ) const
inline
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.

References HepGeom::BasicVector3D< T >::v_.

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.

References HepGeom::BasicVector3D< T >::v_.

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  }
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  }
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  }
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  }
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  }
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
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  }
template<class T>
T HepGeom::BasicVector3D< T >::perp2 ( ) const
inline

Gets transverse component squared.

Definition at line 169 of file BasicVector3D.h.

Referenced by HepGeom::BasicVector3D< G4double >::perp().

169 { return x()*x()+y()*y(); }
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
T dot(const BasicVector3D< T > &v) const
template<class T>
T HepGeom::BasicVector3D< T >::phi ( ) const
inline
template<>
float HepGeom::BasicVector3D< float >::pseudoRapidity ( ) const

Definition at line 13 of file BasicVector3D.cc.

References FLT_MAX, and z.

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.

References DBL_MAX, and z.

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))

Referenced by HepGeom::BasicVector3D< G4double >::eta(), and HepGeom::BasicVector3D< G4double >::getEta().

template<class T>
T HepGeom::BasicVector3D< T >::r ( ) const
inline
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.

Referenced by berttp(), dthrep(), energy(), enrg(), lmsimp(), and pyxtot().

175 { return perp(); }
template<>
BasicVector3D< float > & HepGeom::BasicVector3D< float >::rotate ( float  a,
const BasicVector3D< float > &  v 
)

Definition at line 77 of file BasicVector3D.cc.

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

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)
template<>
BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotate ( double  a,
const BasicVector3D< double > &  v 
)

Definition at line 233 of file BasicVector3D.cc.

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

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)
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.

References z.

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  }
template<>
BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateX ( double  a)

Definition at line 205 of file BasicVector3D.cc.

References z.

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  }
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.

References test::x, and z.

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  }
template<>
BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateY ( double  a)

Definition at line 214 of file BasicVector3D.cc.

References test::x, and z.

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  }
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.

References test::x.

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  }
template<>
BasicVector3D< double > & HepGeom::BasicVector3D< double >::rotateZ ( double  a)

Definition at line 223 of file BasicVector3D.cc.

References test::x.

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  }
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
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)
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)
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.

Referenced by HepGeom::BasicVector3D< G4double >::setR().

225  {
226  T factor = mag();
227  if (factor > 0) {
228  factor = ma/factor; v_[0] *= factor; v_[1] *= factor; v_[2] *= factor;
229  }
230  }
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
template<class T>
void HepGeom::BasicVector3D< T >::setY ( a)
inline
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.

Referenced by HepGeom::operator>>().

157 { v_[2] = a; }
template<class T>
T HepGeom::BasicVector3D< T >::theta ( ) const
inline
template<class T>
BasicVector3D<T> HepGeom::BasicVector3D< T >::unit ( ) const
inline
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.

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4HepRepSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), HepGeom::BasicVector3D< G4double >::BasicVector3D(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4ReflectedSolid::CalculateExtent(), G4CutTubs::CreatePolyhedron(), HepGeom::BasicVector3D< G4double >::cross(), HepGeom::Plane3D< G4double >::distance(), HepGeom::Point3D< float >::distance2(), HepGeom::Point3D< double >::distance2(), G4ReflectedSolid::DistanceToIn(), G4ReflectedSolid::DistanceToOut(), HepGeom::BasicVector3D< G4double >::dot(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4VisExtent::G4VisExtent(), G4ReflectedSolid::GetPointOnSurface(), HepPolyhedronEllipsoid::HepPolyhedronEllipsoid(), HepPolyhedronEllipticalCone::HepPolyhedronEllipticalCone(), G4ReflectedSolid::Inside(), HepGeom::BasicVector3D< G4double >::mag2(), G4ViewParameters::MultiplyScaleFactor(), HepGeom::BasicVector3D< G4double >::operator CLHEP::Hep3Vector(), HepGeom::Vector3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Normal3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Point3D< double >::operator CLHEP::Hep3Vector(), HepGeom::BasicVector3D< T >::operator!=(), HepGeom::operator*(), HepGeom::BasicVector3D< T >::operator*(), HepGeom::BasicVector3D< T >::operator+(), HepGeom::BasicVector3D< T >::operator-(), HepGeom::BasicVector3D< T >::operator/(), operator<<(), HepGeom::Vector3D< float >::operator=(), HepGeom::Normal3D< float >::operator=(), HepGeom::Point3D< float >::operator=(), HepGeom::Normal3D< double >::operator=(), HepGeom::Vector3D< double >::operator=(), HepGeom::Point3D< double >::operator=(), HepGeom::BasicVector3D< T >::operator==(), HepGeom::BasicVector3D< G4double >::orthogonal(), HepGeom::BasicVector3D< G4double >::perp2(), HepGeom::BasicVector3D< G4double >::phi(), HepGeom::Plane3D< G4double >::Plane3D(), HepGeom::Plane3D< G4double >::point(), G4ErrorFreeTrajState::PropagateError(), HepGeom::BasicVector3D< T >::rotate(), HepGeom::Rotate3D::Rotate3D(), G4DAWNFILEViewer::SendViewParameters(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddScale::SetNewValue(), G4ErrorFreeTrajParam::SetParameters(), G4ViewParameters::SetViewAndLights(), G4ReflectedSolid::SurfaceNormal(), HepGeom::BasicVector3D< G4double >::theta(), HepGeom::Normal3D< float >::transform(), HepGeom::Vector3D< float >::transform(), HepGeom::Point3D< float >::transform(), HepGeom::Plane3D< G4double >::transform(), HepGeom::Normal3D< double >::transform(), HepGeom::Vector3D< double >::transform(), HepGeom::Point3D< double >::transform(), HepGeom::Transform3D::Transform3D(), and HepGeom::BasicVector3D< G4double >::unit().

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.

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4HepRepSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), angfi(), angxy(), ar3jet(), HepGeom::BasicVector3D< G4double >::BasicVector3D(), bsofpt(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4ReflectedSolid::CalculateExtent(), cats(), G4CutTubs::CreatePolyhedron(), HepGeom::BasicVector3D< G4double >::cross(), d106bd(), dbetar(), dcosi(), dcross(), ddrela(), dgamrn(), diffpt(), dilog(), HepGeom::Plane3D< G4double >::distance(), HepGeom::Point3D< float >::distance2(), HepGeom::Point3D< double >::distance2(), G4ReflectedSolid::DistanceToIn(), G4ReflectedSolid::DistanceToOut(), distrr(), dlower(), HepGeom::BasicVector3D< G4double >::dot(), dph4pi(), dphtre(), dqcd(), drcmu(), drtran(), dsfecf(), dsigma(), dthrep(), dtrans(), dupper(), dxlamb(), flgint(), flintg(), flipol(), flqint(), fltabl(), fltint(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4VisExtent::G4VisExtent(), gauss1(), gauss2(), gauss3(), gauss4(), gentable(), G4ReflectedSolid::GetPointOnSurface(), hatest(), hax1x2(), HepPolyhedronEllipsoid::HepPolyhedronEllipsoid(), HepPolyhedronEllipticalCone::HepPolyhedronEllipticalCone(), hiboost(), hijsrt(), G4ReflectedSolid::Inside(), jetta(), jettarun(), jettout(), kkevle(), lazimu(), lepto(), leptox(), lflav(), lframe(), linit(), lkinem(), lmcmnd(), lmeps(), lmidat(), lminew(), lminto(), lmpint(), lmprin(), lmrazz(), lmsimp(), lprwts(), lqcdpr(), lqev(), lqgev(), lqmcut(), lqqbev(), lremh(), lscale(), lshowr(), lsigmx(), lweits(), lxp(), lxsect(), lzp(), HepGeom::BasicVector3D< G4double >::mag2(), modb(), G4ViewParameters::MultiplyScaleFactor(), mytran(), HepGeom::BasicVector3D< G4double >::operator CLHEP::Hep3Vector(), HepGeom::Vector3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Normal3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Point3D< double >::operator CLHEP::Hep3Vector(), HepGeom::BasicVector3D< T >::operator!=(), HepGeom::operator*(), HepGeom::BasicVector3D< T >::operator*(), HepGeom::BasicVector3D< T >::operator+(), HepGeom::BasicVector3D< T >::operator-(), HepGeom::BasicVector3D< T >::operator/(), operator<<(), HepGeom::Normal3D< float >::operator=(), HepGeom::Point3D< float >::operator=(), HepGeom::Vector3D< float >::operator=(), HepGeom::Vector3D< double >::operator=(), HepGeom::Normal3D< double >::operator=(), HepGeom::Point3D< double >::operator=(), HepGeom::BasicVector3D< T >::operator==(), HepGeom::BasicVector3D< G4double >::orthogonal(), parupd(), HepGeom::BasicVector3D< G4double >::perp2(), HepGeom::BasicVector3D< G4double >::phi(), phoan1(), phoan2(), HepGeom::Plane3D< G4double >::Plane3D(), plot(), HepGeom::Plane3D< G4double >::point(), G4ErrorFreeTrajState::PropagateError(), pyangl(), pygfxx(), pylamf(), pypdpi(), pyreco(), pysimp(), pystfu(), pystpr(), pyxxw5(), pyxxz2(), pyxxz5(), qinnuc(), raco(), rannor(), riwfun(), HepGeom::BasicVector3D< T >::rotate(), HepGeom::Rotate3D::Rotate3D(), saptre(), G4DAWNFILEViewer::SendViewParameters(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddScale::SetNewValue(), G4ErrorFreeTrajParam::SetParameters(), G4ViewParameters::SetViewAndLights(), sttran(), G4ReflectedSolid::SurfaceNormal(), thb(), HepGeom::BasicVector3D< G4double >::theta(), HepGeom::Normal3D< float >::transform(), HepGeom::Vector3D< float >::transform(), HepGeom::Point3D< float >::transform(), HepGeom::Plane3D< G4double >::transform(), HepGeom::Vector3D< double >::transform(), HepGeom::Normal3D< double >::transform(), HepGeom::Point3D< double >::transform(), HepGeom::Transform3D::Transform3D(), ulangl(), HepGeom::BasicVector3D< G4double >::unit(), and ylamb().

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.

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4HepRepSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), HepGeom::BasicVector3D< G4double >::BasicVector3D(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4ReflectedSolid::CalculateExtent(), HepGeom::BasicVector3D< G4double >::cosTheta(), G4CutTubs::CreatePolyhedron(), HepGeom::BasicVector3D< G4double >::cross(), HepGeom::Plane3D< G4double >::distance(), HepGeom::Point3D< float >::distance2(), HepGeom::Point3D< double >::distance2(), G4ReflectedSolid::DistanceToIn(), G4ReflectedSolid::DistanceToOut(), HepGeom::BasicVector3D< G4double >::dot(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4VisExtent::G4VisExtent(), G4ReflectedSolid::GetPointOnSurface(), G4ReflectedSolid::Inside(), HepGeom::BasicVector3D< G4double >::mag2(), G4ViewParameters::MultiplyScaleFactor(), HepGeom::BasicVector3D< G4double >::operator CLHEP::Hep3Vector(), HepGeom::Normal3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Vector3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Point3D< double >::operator CLHEP::Hep3Vector(), HepGeom::BasicVector3D< T >::operator!=(), HepGeom::operator*(), HepGeom::BasicVector3D< T >::operator*(), HepGeom::BasicVector3D< T >::operator+(), HepGeom::BasicVector3D< T >::operator-(), HepGeom::BasicVector3D< T >::operator/(), operator<<(), HepGeom::Vector3D< float >::operator=(), HepGeom::Normal3D< float >::operator=(), HepGeom::Point3D< float >::operator=(), HepGeom::Normal3D< double >::operator=(), HepGeom::Vector3D< double >::operator=(), HepGeom::Point3D< double >::operator=(), HepGeom::BasicVector3D< T >::operator==(), HepGeom::BasicVector3D< G4double >::orthogonal(), HepGeom::Plane3D< G4double >::Plane3D(), HepGeom::Plane3D< G4double >::point(), G4ErrorFreeTrajState::PropagateError(), HepGeom::BasicVector3D< T >::rotate(), HepGeom::Rotate3D::Rotate3D(), G4DAWNFILEViewer::SendViewParameters(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddScale::SetNewValue(), G4ReflectedSolid::SurfaceNormal(), HepGeom::BasicVector3D< G4double >::theta(), HepGeom::Vector3D< float >::transform(), HepGeom::Normal3D< float >::transform(), HepGeom::Point3D< float >::transform(), HepGeom::Plane3D< G4double >::transform(), HepGeom::Vector3D< double >::transform(), HepGeom::Normal3D< double >::transform(), HepGeom::Point3D< double >::transform(), HepGeom::Transform3D::Transform3D(), and HepGeom::BasicVector3D< G4double >::unit().

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.

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

447  {
448  return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
449  }
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.

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

557  {
558  return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
559  }
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.

References test::a, HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

402  {
403  return BasicVector3D<float>(v.x()*static_cast<float>(a), v.y()*static_cast<float>(a), v.z()*static_cast<float>(a));
404  }
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.

References HepGeom::BasicVector3D< T >::dot().

411  {
412  return a.dot(b);
413  }
T dot(const BasicVector3D< T > &v) const
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.

References test::a, HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

420  {
421  return BasicVector3D<float>(static_cast<float>(a)*v.x(), static_cast<float>(a)*v.y(), static_cast<float>(a)*v.z());
422  }
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.

References test::a, HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

510  {
511  return BasicVector3D<double>(v.x()*a, v.y()*a, v.z()*a);
512  }
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.

References HepGeom::BasicVector3D< T >::dot().

519  {
520  return a.dot(b);
521  }
T dot(const BasicVector3D< T > &v) const
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.

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

528  {
529  return BasicVector3D<double>(a*v.x(), a*v.y(), a*v.z());
530  }
template<class T>
BasicVector3D< float > operator+ ( const BasicVector3D< float > &  v)
related

Unary plus.

Definition at line 368 of file BasicVector3D.h.

References test::v.

368 { return v; }
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.

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

375  {
376  return BasicVector3D<float>(a.x()+b.x(), a.y()+b.y(), a.z()+b.z());
377  }
template<class T>
BasicVector3D< double > operator+ ( const BasicVector3D< double > &  v)
related

Unary plus.

Definition at line 476 of file BasicVector3D.h.

References test::v.

476 { return v; }
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.

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

483  {
484  return BasicVector3D<double>(a.x()+b.x(), a.y()+b.y(), a.z()+b.z());
485  }
template<class T>
BasicVector3D< float > operator- ( const BasicVector3D< float > &  v)
related

Unary minus.

Definition at line 384 of file BasicVector3D.h.

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

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

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

393  {
394  return BasicVector3D<float>(a.x()-b.x(), a.y()-b.y(), a.z()-b.z());
395  }
template<class T>
BasicVector3D< double > operator- ( const BasicVector3D< double > &  v)
related

Unary minus.

Definition at line 492 of file BasicVector3D.h.

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

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

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

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

References test::a, HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

429  {
430  return BasicVector3D<float>(v.x()/static_cast<float>(a), v.y()/static_cast<float>(a), v.z()/static_cast<float>(a));
431  }
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.

References test::a, HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

537  {
538  return BasicVector3D<double>(v.x()/a, v.y()/a, v.z()/a);
539  }
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  }
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  }
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.

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

Referenced by G4Solver< Function >::operator!=().

438  {
439  return (a.x()==b.x() && a.y()==b.y() && a.z()==b.z());
440  }
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.

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

547  {
548  return (a.x()==b.x() && a.y()==b.y() && a.z()==b.z());
549  }
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  }
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  }

Field Documentation

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

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