Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
CLHEP::Hep2Vector Class Reference

#include <TwoVector.h>

Public Types

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

Public Member Functions

 Hep2Vector (double x=0.0, double y=0.0)
 
 Hep2Vector (const Hep2Vector &p)
 
 Hep2Vector (Hep2Vector &&p)=default
 
 Hep2Vector (const Hep3Vector &)
 
 ~Hep2Vector ()
 
double x () const
 
double y () const
 
double operator() (int i) const
 
double operator[] (int i) const
 
double & operator() (int i)
 
double & operator[] (int i)
 
void setX (double x)
 
void setY (double y)
 
void set (double x, double y)
 
double phi () const
 
double mag2 () const
 
double mag () const
 
double r () const
 
void setPhi (double phi)
 
void setMag (double r)
 
void setR (double r)
 
void setPolar (double r, double phi)
 
Hep2Vectoroperator= (const Hep2Vector &p)
 
Hep2Vectoroperator= (Hep2Vector &&p)=default
 
bool operator== (const Hep2Vector &v) const
 
bool operator!= (const Hep2Vector &v) const
 
int compare (const Hep2Vector &v) const
 
bool operator> (const Hep2Vector &v) const
 
bool operator< (const Hep2Vector &v) const
 
bool operator>= (const Hep2Vector &v) const
 
bool operator<= (const Hep2Vector &v) const
 
double howNear (const Hep2Vector &p) const
 
bool isNear (const Hep2Vector &p, double epsilon=tolerance) const
 
double howParallel (const Hep2Vector &p) const
 
bool isParallel (const Hep2Vector &p, double epsilon=tolerance) const
 
double howOrthogonal (const Hep2Vector &p) const
 
bool isOrthogonal (const Hep2Vector &p, double epsilon=tolerance) const
 
Hep2Vectoroperator+= (const Hep2Vector &p)
 
Hep2Vectoroperator-= (const Hep2Vector &p)
 
Hep2Vector operator- () const
 
Hep2Vectoroperator*= (double a)
 
Hep2Vector unit () const
 
Hep2Vector orthogonal () const
 
double dot (const Hep2Vector &p) const
 
double angle (const Hep2Vector &) const
 
void rotate (double)
 
 operator Hep3Vector () const
 

Static Public Member Functions

static double getTolerance ()
 
static double setTolerance (double tol)
 

Static Public Attributes

static const int ZMpvToleranceTicks = 100
 

Friends

std::ostream & operator<< (std::ostream &os, const Hep2Vector &q)
 
double operator* (const Hep2Vector &a, const Hep2Vector &b)
 
Hep2Vector operator* (const Hep2Vector &p, double a)
 
Hep2Vector operator* (double a, const Hep2Vector &p)
 
Hep2Vector operator/ (const Hep2Vector &p, double a)
 
Hep2Vector operator+ (const Hep2Vector &a, const Hep2Vector &b)
 
Hep2Vector operator- (const Hep2Vector &a, const Hep2Vector &b)
 

Detailed Description

Author

Definition at line 44 of file TwoVector.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
NUM_COORDINATES 
SIZE 

Definition at line 48 of file TwoVector.h.

Constructor & Destructor Documentation

◆ Hep2Vector() [1/4]

CLHEP::Hep2Vector::Hep2Vector ( double x = 0.0,
double y = 0.0 )
inline

◆ Hep2Vector() [2/4]

CLHEP::Hep2Vector::Hep2Vector ( const Hep2Vector & p)
inline

◆ Hep2Vector() [3/4]

CLHEP::Hep2Vector::Hep2Vector ( Hep2Vector && p)
inlinedefault

◆ Hep2Vector() [4/4]

CLHEP::Hep2Vector::Hep2Vector ( const Hep3Vector & )
explicit

◆ ~Hep2Vector()

CLHEP::Hep2Vector::~Hep2Vector ( )
inline

Member Function Documentation

◆ angle()

double CLHEP::Hep2Vector::angle ( const Hep2Vector & ) const
inline

◆ compare()

int CLHEP::Hep2Vector::compare ( const Hep2Vector & v) const

Definition at line 88 of file TwoVector.cc.

88 {
89 if ( dy > v.dy ) {
90 return 1;
91 } else if ( dy < v.dy ) {
92 return -1;
93 } else if ( dx > v.dx ) {
94 return 1;
95 } else if ( dx < v.dx ) {
96 return -1;
97 } else {
98 return 0;
99 }
100} /* Compare */

Referenced by operator<(), operator<=(), operator>(), and operator>=().

◆ dot()

◆ getTolerance()

static double CLHEP::Hep2Vector::getTolerance ( )
inlinestatic

◆ howNear()

double CLHEP::Hep2Vector::howNear ( const Hep2Vector & p) const

Definition at line 121 of file TwoVector.cc.

121 {
122 double d = (*this - p).mag2();
123 double pdp = dot(p);
124 if ( (pdp > 0) && (d < pdp) ) {
125 return std::sqrt (d/pdp);
126 } else if ( (pdp == 0) && (d == 0) ) {
127 return 0;
128 } else {
129 return 1;
130 }
131} /* howNear */
double mag2() const
double dot(const Hep2Vector &p) const

◆ howOrthogonal()

double CLHEP::Hep2Vector::howOrthogonal ( const Hep2Vector & p) const

Definition at line 162 of file TwoVector.cc.

162 {
163 // | V1 dot V2 | / | V1 x V2 |
164 // Of course, the "cross product" is fictitious but the math is valid
165 double v1v2 = std::fabs(dot(v));
166 if ( v1v2 == 0 ) {
167 return 0; // Even if one or both are 0, they are considered orthogonal
168 }
169 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
170 if ( v1v2 >= abscross ) {
171 return 1;
172 } else {
173 return v1v2/abscross;
174 }
175} /* howOrthogonal() */

◆ howParallel()

double CLHEP::Hep2Vector::howParallel ( const Hep2Vector & p) const

Definition at line 133 of file TwoVector.cc.

133 {
134 // | V1 x V2 | / | V1 dot V2 |
135 // Of course, the "cross product" is fictitious but the math is valid
136 double v1v2 = std::fabs(dot(v));
137 if ( v1v2 == 0 ) {
138 // Zero is parallel to no other vector except for zero.
139 return ( (mag2() == 0) && (v.mag2() == 0) ) ? 0 : 1;
140 }
141 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
142 if ( abscross >= v1v2 ) {
143 return 1;
144 } else {
145 return abscross/v1v2;
146 }
147} /* howParallel() */

◆ isNear()

bool CLHEP::Hep2Vector::isNear ( const Hep2Vector & p,
double epsilon = tolerance ) const

Definition at line 116 of file TwoVector.cc.

116 {
117 double limit = dot(p)*epsilon*epsilon;
118 return ( (*this - p).mag2() <= limit );
119} /* isNear() */
G4double epsilon(G4double density, G4double temperature)

◆ isOrthogonal()

bool CLHEP::Hep2Vector::isOrthogonal ( const Hep2Vector & p,
double epsilon = tolerance ) const

Definition at line 177 of file TwoVector.cc.

178 {
179 // | V1 dot V2 | <= epsilon * | V1 x V2 |
180 // Of course, the "cross product" is fictitious but the math is valid
181 double v1v2 = std::fabs(dot(v));
182 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
183 return ( v1v2 <= epsilon * abscross );
184} /* isOrthogonal() */

◆ isParallel()

bool CLHEP::Hep2Vector::isParallel ( const Hep2Vector & p,
double epsilon = tolerance ) const

Definition at line 149 of file TwoVector.cc.

150 {
151 // | V1 x V2 | <= epsilon * | V1 dot V2 |
152 // Of course, the "cross product" is fictitious but the math is valid
153 double v1v2 = std::fabs(dot(v));
154 if ( v1v2 == 0 ) {
155 // Zero is parallel to no other vector except for zero.
156 return ( (mag2() == 0) && (v.mag2() == 0) );
157 }
158 double abscross = std::fabs ( dx * v.y() - dy - v.x() );
159 return ( abscross <= epsilon * v1v2 );
160} /* isParallel() */

◆ mag()

double CLHEP::Hep2Vector::mag ( ) const
inline

◆ mag2()

◆ operator Hep3Vector()

CLHEP::Hep2Vector::operator Hep3Vector ( ) const

Definition at line 84 of file TwoVector.cc.

84 {
85 return Hep3Vector ( dx, dy, 0.0 );
86}

◆ operator!=()

bool CLHEP::Hep2Vector::operator!= ( const Hep2Vector & v) const
inline

◆ operator()() [1/2]

double & CLHEP::Hep2Vector::operator() ( int i)

Definition at line 39 of file TwoVector.cc.

39 {
40 static double dummy;
41 switch(i) {
42 case X:
43 return dx;
44 case Y:
45 return dy;
46 default:
47// std::cerr << "Hep2Vector::operator () - "
48// << "Hep2Vector::operator() : bad index" << std::endl;
49 return dummy;
50 }
51}

◆ operator()() [2/2]

double CLHEP::Hep2Vector::operator() ( int i) const

Definition at line 27 of file TwoVector.cc.

27 {
28 if (i == 0) {
29 return x();
30 }else if (i == 1) {
31 return y();
32 }else{
33// std::cerr << "Hep2Vector::operator () - "
34// << "Hep2Vector::operator(): bad index" << std::endl;
35 return 0.0;
36 }
37}
double x() const
double y() const

◆ operator*=()

Hep2Vector & CLHEP::Hep2Vector::operator*= ( double a)
inline

◆ operator+=()

Hep2Vector & CLHEP::Hep2Vector::operator+= ( const Hep2Vector & p)
inline

◆ operator-()

Hep2Vector CLHEP::Hep2Vector::operator- ( ) const
inline

◆ operator-=()

Hep2Vector & CLHEP::Hep2Vector::operator-= ( const Hep2Vector & p)
inline

◆ operator<()

bool CLHEP::Hep2Vector::operator< ( const Hep2Vector & v) const

Definition at line 106 of file TwoVector.cc.

106 {
107 return (compare(v) < 0);
108}
int compare(const Hep2Vector &v) const
Definition TwoVector.cc:88

◆ operator<=()

bool CLHEP::Hep2Vector::operator<= ( const Hep2Vector & v) const

Definition at line 112 of file TwoVector.cc.

112 {
113 return (compare(v) <= 0);
114}

◆ operator=() [1/2]

Hep2Vector & CLHEP::Hep2Vector::operator= ( const Hep2Vector & p)
inline

◆ operator=() [2/2]

Hep2Vector & CLHEP::Hep2Vector::operator= ( Hep2Vector && p)
inlinedefault

◆ operator==()

bool CLHEP::Hep2Vector::operator== ( const Hep2Vector & v) const
inline

◆ operator>()

bool CLHEP::Hep2Vector::operator> ( const Hep2Vector & v) const

Definition at line 103 of file TwoVector.cc.

103 {
104 return (compare(v) > 0);
105}

◆ operator>=()

bool CLHEP::Hep2Vector::operator>= ( const Hep2Vector & v) const

Definition at line 109 of file TwoVector.cc.

109 {
110 return (compare(v) >= 0);
111}

◆ operator[]() [1/2]

double & CLHEP::Hep2Vector::operator[] ( int i)
inline

◆ operator[]() [2/2]

double CLHEP::Hep2Vector::operator[] ( int i) const
inline

◆ orthogonal()

Hep2Vector CLHEP::Hep2Vector::orthogonal ( ) const
inline

◆ phi()

double CLHEP::Hep2Vector::phi ( ) const
inline

◆ r()

double CLHEP::Hep2Vector::r ( ) const
inline

◆ rotate()

void CLHEP::Hep2Vector::rotate ( double aangle)

Definition at line 53 of file TwoVector.cc.

53 {
54 double ss = std::sin(aangle);
55 double cc = std::cos(aangle);
56 double xx = dx;
57 dx = cc*xx - ss*dy;
58 dy = ss*xx + cc*dy;
59}

◆ set()

void CLHEP::Hep2Vector::set ( double x,
double y )
inline

◆ setMag()

void CLHEP::Hep2Vector::setMag ( double r)
inline

◆ setPhi()

void CLHEP::Hep2Vector::setPhi ( double phi)
inline

◆ setPolar()

void CLHEP::Hep2Vector::setPolar ( double r,
double phi )
inline

◆ setR()

void CLHEP::Hep2Vector::setR ( double r)
inline

◆ setTolerance()

double CLHEP::Hep2Vector::setTolerance ( double tol)
static

Definition at line 20 of file TwoVector.cc.

20 {
21// Set the tolerance for Hep2Vectors to be considered near one another
22 double oldTolerance (tolerance);
23 tolerance = tol;
24 return oldTolerance;
25}

◆ setX()

void CLHEP::Hep2Vector::setX ( double x)
inline

◆ setY()

void CLHEP::Hep2Vector::setY ( double y)
inline

◆ unit()

Hep2Vector CLHEP::Hep2Vector::unit ( ) const
inline

◆ x()

◆ y()

Friends And Related Symbol Documentation

◆ operator* [1/3]

double operator* ( const Hep2Vector & a,
const Hep2Vector & b )
friend

◆ operator* [2/3]

Hep2Vector operator* ( const Hep2Vector & p,
double a )
friend

◆ operator* [3/3]

Hep2Vector operator* ( double a,
const Hep2Vector & p )
friend

◆ operator+

Hep2Vector operator+ ( const Hep2Vector & a,
const Hep2Vector & b )
friend

◆ operator-

Hep2Vector operator- ( const Hep2Vector & a,
const Hep2Vector & b )
friend

◆ operator/

Hep2Vector operator/ ( const Hep2Vector & p,
double a )
friend

Definition at line 61 of file TwoVector.cc.

61 {
62// if (a==0) {
63// std::cerr << "Hep2Vector operator/ () - "
64// << "Division of Hep2Vector by zero" << std::endl;
65// }
66 return Hep2Vector(p.x()/a, p.y()/a);
67}
Hep2Vector(double x=0.0, double y=0.0)

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Hep2Vector & q )
friend

Definition at line 69 of file TwoVector.cc.

69 {
70 os << "(" << q.x() << ", " << q.y() << ")";
71 return os;
72}

Member Data Documentation

◆ ZMpvToleranceTicks

const int CLHEP::Hep2Vector::ZMpvToleranceTicks = 100
static

Definition at line 193 of file TwoVector.h.


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