Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
HepGeom::BasicVector3D< T > Class Template Reference

#include <BasicVector3D.h>

+ Inheritance 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)
 
float pseudoRapidity () const
 
void setEta (float a)
 
float angle (const BasicVector3D< float > &v) const
 
BasicVector3D< float > & rotateX (float a)
 
BasicVector3D< float > & rotateY (float a)
 
BasicVector3D< float > & rotateZ (float a)
 
BasicVector3D< float > & rotate (float a, const BasicVector3D< float > &v)
 
double pseudoRapidity () const
 
void setEta (double a)
 
double angle (const BasicVector3D< double > &v) const
 
BasicVector3D< double > & rotateX (double a)
 
BasicVector3D< double > & rotateY (double a)
 
BasicVector3D< double > & rotateZ (double a)
 
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

◆ anonymous enum

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

◆ BasicVector3D() [1/3]

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

◆ BasicVector3D() [2/3]

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

◆ BasicVector3D() [3/3]

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 }

◆ ~BasicVector3D()

template<class T >
virtual HepGeom::BasicVector3D< T >::~BasicVector3D ( )
inlinevirtual

Destructor.

Definition at line 66 of file BasicVector3D.h.

66{}

Member Function Documentation

◆ angle() [1/3]

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

◆ angle() [2/3]

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 }

◆ angle() [3/3]

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

Returns angle w.r.t. another vector.

◆ cosTheta()

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

◆ cross()

◆ dot()

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 }

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

◆ eta()

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

Gets pseudo-rapidity.

Definition at line 254 of file BasicVector3D.h.

254{ return pseudoRapidity(); }

◆ getEta()

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

Gets pseudo-rapidity.

Definition at line 257 of file BasicVector3D.h.

257{ return pseudoRapidity(); }

◆ getPhi()

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(); }

◆ getR()

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(); }

◆ getTheta()

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(); }

◆ mag()

◆ mag2()

◆ operator CLHEP::Hep3Vector()

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.

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

◆ operator const T *()

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_; }

◆ operator T*()

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_; }

◆ operator()() [1/2]

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]; }

◆ operator()() [2/2]

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]; }

◆ operator*=()

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 }

◆ operator+=()

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 }

◆ operator-=()

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 }

◆ operator/=()

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 }

◆ operator=()

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 }

◆ operator[]() [1/2]

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]; }

◆ operator[]() [2/2]

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]; }

◆ orthogonal()

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 }

◆ perp() [1/2]

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

◆ perp() [2/2]

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 }

◆ perp2() [1/2]

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(); }

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

◆ perp2() [2/2]

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 }

◆ phi()

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 }

Referenced by G4ArrowModel::G4ArrowModel(), HepGeom::BasicVector3D< T >::getPhi(), G4ErrorFreeTrajParam::SetParameters(), and HepGeom::BasicVector3D< T >::setTheta().

◆ pseudoRapidity() [1/3]

template<class T >
T HepGeom::BasicVector3D< T >::pseudoRapidity ( ) const

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

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

◆ pseudoRapidity() [2/3]

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

◆ pseudoRapidity() [3/3]

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

◆ r()

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(); }

Referenced by HepGeom::BasicVector3D< T >::getR().

◆ rho()

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(); }

◆ rotate() [1/3]

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)

◆ rotate() [2/3]

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 }

◆ rotate() [3/3]

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

Rotates around the axis specified by another vector.

◆ rotateX() [1/3]

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 }

◆ rotateX() [2/3]

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 }

◆ rotateX() [3/3]

template<class T >
BasicVector3D< T > & HepGeom::BasicVector3D< T >::rotateX ( a)

Rotates around x-axis.

◆ rotateY() [1/3]

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 }

◆ rotateY() [2/3]

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 }

◆ rotateY() [3/3]

template<class T >
BasicVector3D< T > & HepGeom::BasicVector3D< T >::rotateY ( a)

Rotates around y-axis.

◆ rotateZ() [1/3]

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 }

◆ rotateZ() [2/3]

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 }

◆ rotateZ() [3/3]

template<class T >
BasicVector3D< T > & HepGeom::BasicVector3D< T >::rotateZ ( a)

Rotates around z-axis.

◆ set()

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

◆ setEta() [1/3]

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 }

◆ setEta() [2/3]

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 }

◆ setEta() [3/3]

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

Sets pseudo-rapidity, keeping magnitude and phi fixed.

◆ setMag()

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 }

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

◆ setPerp()

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 }

◆ setPhi()

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

◆ setR()

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

◆ setTheta()

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 }

◆ setX()

◆ setY()

◆ setZ()

◆ theta()

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 }

Referenced by G4ArrowModel::G4ArrowModel(), HepGeom::BasicVector3D< T >::getTheta(), G4ErrorFreeTrajState::PropagateError(), and G4ErrorFreeTrajParam::SetParameters().

◆ unit()

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

◆ x()

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]; }

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepFileSceneHandler::AddPrimitive(), G4HepRepSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), G4HepRepSceneHandler::AddSolid(), HepGeom::BasicVector3D< T >::BasicVector3D(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4BezierSurface::CalcBBox(), G4BSplineSurface::CalcBBox(), G4ProjectedSurface::CalcBBox(), G4SphericalSurface::CalcBBox(), G4ToroidalSurface::CalcBBox(), G4BREPSolid::CalcBBoxes(), G4ReflectedSolid::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4ControlPoints::CalcValues(), G4ViewParameters::CameraAndLightingCommands(), G4BREPSolid::CheckSurfaceNormals(), G4BezierSurface::ClipSurface(), G4FPlane::ClosestDistanceToPoint(), G4Surface::ClosestDistanceToPoint(), G4BREPSolid::CreateNURBS(), G4Ray::CreatePlanes(), G4BREPSolid::CreatePolyhedron(), G4CutTubs::CreatePolyhedron(), G4BREPSolid::CreateRotatedVertices(), HepGeom::BasicVector3D< T >::cross(), HepGeom::Plane3D< T >::distance(), HepGeom::Point3D< double >::distance2(), HepGeom::Point3D< float >::distance2(), G4ReflectedSolid::DistanceToIn(), G4ReflectedSolid::DistanceToOut(), HepGeom::BasicVector3D< T >::dot(), G4BoundingBox3D::Extend(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4PlacedSolid::G4PlacedSolid(), G4VisExtent::G4VisExtent(), G4ReflectedSolid::GetPointOnSurface(), G4CircularCurve::GetPPoint(), HepPolyhedronEllipsoid::HepPolyhedronEllipsoid(), HepPolyhedronEllipticalCone::HepPolyhedronEllipticalCone(), G4FConicalSurface::HowNear(), G4FCylindricalSurface::HowNear(), G4FPlane::HowNear(), G4BoundingBox3D::Init(), G4BoundingBox3D::Inside(), G4ReflectedSolid::Inside(), G4BREPSolidBox::Inside(), G4ToroidalSurface::Intersect(), G4FPlane::Intersect(), G4BREPSolid::IsConvex(), HepGeom::BasicVector3D< T >::mag2(), G4Ray::MatVecOrtho(), G4ViewParameters::MultiplyScaleFactor(), HepGeom::BasicVector3D< T >::operator CLHEP::Hep3Vector(), HepGeom::Normal3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Point3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Vector3D< double >::operator CLHEP::Hep3Vector(), HepGeom::BasicVector3D< T >::operator!=(), HepGeom::BasicVector3D< T >::operator*(), HepGeom::Normal3D< T >::operator*(), HepGeom::Point3D< T >::operator*(), HepGeom::Vector3D< T >::operator*(), HepGeom::BasicVector3D< T >::operator+(), HepGeom::BasicVector3D< T >::operator-(), HepGeom::BasicVector3D< T >::operator/(), HepGeom::BasicVector3D< T >::operator<<(), HepGeom::Normal3D< double >::operator=(), HepGeom::Normal3D< float >::operator=(), HepGeom::Point3D< double >::operator=(), HepGeom::Point3D< float >::operator=(), HepGeom::Vector3D< double >::operator=(), HepGeom::Vector3D< float >::operator=(), HepGeom::BasicVector3D< T >::operator==(), HepGeom::BasicVector3D< T >::orthogonal(), HepGeom::BasicVector3D< T >::perp2(), HepGeom::BasicVector3D< T >::phi(), HepGeom::Plane3D< T >::point(), G4Line::Project(), G4Surface::Project(), G4ErrorFreeTrajState::PropagateError(), HepGeom::BasicVector3D< T >::rotate(), HepGeom::Rotate3D::Rotate3D(), G4BREPSolid::Scope(), G4DAWNFILEViewer::SendViewParameters(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddScale::SetNewValue(), G4ErrorFreeTrajParam::SetParameters(), G4ViewParameters::SetViewAndLights(), G4ConicalSurface::SurfaceNormal(), G4FConicalSurface::SurfaceNormal(), G4ReflectedSolid::SurfaceNormal(), G4CircularCurve::Tangent(), G4Ellipse::Tangent(), G4Hyperbola::Tangent(), G4BoundingBox3D::Test(), HepGeom::BasicVector3D< T >::theta(), HepGeom::Transform3D::Transform3D(), HepGeom::BasicVector3D< T >::unit(), G4Ray::Vadd2(), G4Ray::Vcross(), G4Ray::Vdot(), G4Ray::Vmove(), and G4Ray::Vsub2().

◆ y()

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]; }

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepFileSceneHandler::AddPrimitive(), G4HepRepSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), G4HepRepSceneHandler::AddSolid(), HepGeom::BasicVector3D< T >::BasicVector3D(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4BezierSurface::CalcBBox(), G4BSplineSurface::CalcBBox(), G4ProjectedSurface::CalcBBox(), G4SphericalSurface::CalcBBox(), G4ToroidalSurface::CalcBBox(), G4BREPSolid::CalcBBoxes(), G4ReflectedSolid::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4ControlPoints::CalcValues(), G4ViewParameters::CameraAndLightingCommands(), G4BREPSolid::CheckSurfaceNormals(), G4BezierSurface::ClipSurface(), G4FPlane::ClosestDistanceToPoint(), G4Surface::ClosestDistanceToPoint(), G4BREPSolid::CreateNURBS(), G4Ray::CreatePlanes(), G4BREPSolid::CreatePolyhedron(), G4CutTubs::CreatePolyhedron(), G4BREPSolid::CreateRotatedVertices(), HepGeom::BasicVector3D< T >::cross(), HepGeom::Plane3D< T >::distance(), HepGeom::Point3D< double >::distance2(), HepGeom::Point3D< float >::distance2(), G4ReflectedSolid::DistanceToIn(), G4ReflectedSolid::DistanceToOut(), HepGeom::BasicVector3D< T >::dot(), G4BoundingBox3D::Extend(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4PlacedSolid::G4PlacedSolid(), G4VisExtent::G4VisExtent(), G4ReflectedSolid::GetPointOnSurface(), G4CircularCurve::GetPPoint(), HepPolyhedronEllipsoid::HepPolyhedronEllipsoid(), HepPolyhedronEllipticalCone::HepPolyhedronEllipticalCone(), G4FConicalSurface::HowNear(), G4FCylindricalSurface::HowNear(), G4FPlane::HowNear(), G4BoundingBox3D::Init(), G4BoundingBox3D::Inside(), G4ReflectedSolid::Inside(), G4BREPSolidBox::Inside(), G4ToroidalSurface::Intersect(), G4FPlane::Intersect(), G4BREPSolid::IsConvex(), HepGeom::BasicVector3D< T >::mag2(), G4Ray::MatVecOrtho(), G4ViewParameters::MultiplyScaleFactor(), HepGeom::BasicVector3D< T >::operator CLHEP::Hep3Vector(), HepGeom::Normal3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Point3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Vector3D< double >::operator CLHEP::Hep3Vector(), HepGeom::BasicVector3D< T >::operator!=(), HepGeom::BasicVector3D< T >::operator*(), HepGeom::Normal3D< T >::operator*(), HepGeom::Point3D< T >::operator*(), HepGeom::Vector3D< T >::operator*(), HepGeom::BasicVector3D< T >::operator+(), HepGeom::BasicVector3D< T >::operator-(), HepGeom::BasicVector3D< T >::operator/(), HepGeom::BasicVector3D< T >::operator<<(), HepGeom::Normal3D< double >::operator=(), HepGeom::Normal3D< float >::operator=(), HepGeom::Point3D< double >::operator=(), HepGeom::Point3D< float >::operator=(), HepGeom::Vector3D< double >::operator=(), HepGeom::Vector3D< float >::operator=(), HepGeom::BasicVector3D< T >::operator==(), HepGeom::BasicVector3D< T >::orthogonal(), HepGeom::BasicVector3D< T >::perp2(), HepGeom::BasicVector3D< T >::phi(), HepGeom::Plane3D< T >::point(), G4Line::Project(), G4Surface::Project(), G4ErrorFreeTrajState::PropagateError(), HepGeom::BasicVector3D< T >::rotate(), HepGeom::Rotate3D::Rotate3D(), G4BREPSolid::Scope(), G4DAWNFILEViewer::SendViewParameters(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddScale::SetNewValue(), G4ErrorFreeTrajParam::SetParameters(), G4ViewParameters::SetViewAndLights(), G4ConicalSurface::SurfaceNormal(), G4FConicalSurface::SurfaceNormal(), G4ReflectedSolid::SurfaceNormal(), G4CircularCurve::Tangent(), G4Ellipse::Tangent(), G4Hyperbola::Tangent(), G4Parabola::Tangent(), G4BoundingBox3D::Test(), HepGeom::BasicVector3D< T >::theta(), HepGeom::Transform3D::Transform3D(), HepGeom::BasicVector3D< T >::unit(), G4Ray::Vadd2(), G4Ray::Vcross(), G4Ray::Vdot(), G4Ray::Vmove(), and G4Ray::Vsub2().

◆ z()

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]; }

Referenced by G4HepRepFileSceneHandler::AddCompound(), G4HepRepFileSceneHandler::AddPrimitive(), G4HepRepSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), G4HepRepSceneHandler::AddSolid(), HepGeom::BasicVector3D< T >::BasicVector3D(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4BSplineSurface::CalcBBox(), G4SphericalSurface::CalcBBox(), G4ToroidalSurface::CalcBBox(), G4BREPSolid::CalcBBoxes(), G4ReflectedSolid::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4ControlPoints::CalcValues(), G4ViewParameters::CameraAndLightingCommands(), G4BREPSolid::CheckSurfaceNormals(), G4FPlane::ClosestDistanceToPoint(), G4Surface::ClosestDistanceToPoint(), HepGeom::BasicVector3D< T >::cosTheta(), G4BREPSolid::CreateNURBS(), G4Ray::CreatePlanes(), G4BREPSolid::CreatePolyhedron(), G4CutTubs::CreatePolyhedron(), G4BREPSolid::CreateRotatedVertices(), HepGeom::BasicVector3D< T >::cross(), HepGeom::Plane3D< T >::distance(), HepGeom::Point3D< double >::distance2(), HepGeom::Point3D< float >::distance2(), G4ReflectedSolid::DistanceToIn(), G4ReflectedSolid::DistanceToOut(), HepGeom::BasicVector3D< T >::dot(), G4BoundingBox3D::Extend(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4PlacedSolid::G4PlacedSolid(), G4VisExtent::G4VisExtent(), G4ReflectedSolid::GetPointOnSurface(), G4FConicalSurface::HowNear(), G4FCylindricalSurface::HowNear(), G4FPlane::HowNear(), G4BoundingBox3D::Init(), G4BoundingBox3D::Inside(), G4ReflectedSolid::Inside(), G4BREPSolidBox::Inside(), G4ToroidalSurface::Intersect(), G4FPlane::Intersect(), G4BREPSolid::IsConvex(), HepGeom::BasicVector3D< T >::mag2(), G4Ray::MatVecOrtho(), G4ViewParameters::MultiplyScaleFactor(), HepGeom::BasicVector3D< T >::operator CLHEP::Hep3Vector(), HepGeom::Normal3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Point3D< double >::operator CLHEP::Hep3Vector(), HepGeom::Vector3D< double >::operator CLHEP::Hep3Vector(), HepGeom::BasicVector3D< T >::operator!=(), HepGeom::BasicVector3D< T >::operator*(), HepGeom::Normal3D< T >::operator*(), HepGeom::Point3D< T >::operator*(), HepGeom::Vector3D< T >::operator*(), HepGeom::BasicVector3D< T >::operator+(), HepGeom::BasicVector3D< T >::operator-(), HepGeom::BasicVector3D< T >::operator/(), HepGeom::BasicVector3D< T >::operator<<(), HepGeom::Normal3D< double >::operator=(), HepGeom::Normal3D< float >::operator=(), HepGeom::Point3D< double >::operator=(), HepGeom::Point3D< float >::operator=(), HepGeom::Vector3D< double >::operator=(), HepGeom::Vector3D< float >::operator=(), HepGeom::BasicVector3D< T >::operator==(), HepGeom::BasicVector3D< T >::orthogonal(), HepGeom::Plane3D< T >::point(), G4Surface::Project(), G4ErrorFreeTrajState::PropagateError(), HepGeom::BasicVector3D< T >::rotate(), HepGeom::Rotate3D::Rotate3D(), G4BREPSolid::Scope(), G4DAWNFILEViewer::SendViewParameters(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddScale::SetNewValue(), G4FConicalSurface::SurfaceNormal(), G4ReflectedSolid::SurfaceNormal(), G4BoundingBox3D::Test(), HepGeom::BasicVector3D< T >::theta(), HepGeom::Transform3D::Transform3D(), HepGeom::BasicVector3D< T >::unit(), G4Ray::Vadd2(), G4Ray::Vcross(), G4Ray::Vdot(), G4Ray::Vmove(), and G4Ray::Vsub2().

Friends And Related Function Documentation

◆ operator!=() [1/2]

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 }

◆ operator!=() [2/2]

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 }

◆ operator*() [1/6]

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 }

◆ operator*() [2/6]

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 }

◆ operator*() [3/6]

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 }

◆ operator*() [4/6]

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 }

◆ operator*() [5/6]

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 }

◆ operator*() [6/6]

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 }

◆ operator+() [1/4]

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 }

◆ operator+() [2/4]

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

Unary plus.

Definition at line 476 of file BasicVector3D.h.

476{ return v; }

◆ operator+() [3/4]

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 }

◆ operator+() [4/4]

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

Unary plus.

Definition at line 368 of file BasicVector3D.h.

368{ return v; }

◆ operator-() [1/4]

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 }

◆ operator-() [2/4]

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 }

◆ operator-() [3/4]

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 }

◆ operator-() [4/4]

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 }

◆ operator/() [1/2]

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 }

◆ operator/() [2/2]

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 }

◆ operator<<() [1/2]

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

Output to stream.

Definition at line 262 of file BasicVector3D.cc.

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

◆ operator<<() [2/2]

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

Output to stream.

Definition at line 106 of file BasicVector3D.cc.

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

◆ operator==() [1/2]

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 }

◆ operator==() [2/2]

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 }

◆ operator>>() [1/2]

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 }

◆ operator>>() [2/2]

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 }

Member Data Documentation

◆ v_


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