Belle II Software development
TwoVector Class Reference

Public Member Functions

 TwoVector (double x_, double y_)
 
double getX () const
 
double getY () const
 
double getMag2 () const
 
double getMag () const
 
double getPhi () const
 
double getComponent (int i) const
 
TwoVectorsetValues (double x_, double y_)
 
TwoVectoroperator+= (const TwoVector &rhs)
 
TwoVectoroperator-= (const TwoVector &rhs)
 
TwoVectoroperator*= (double rhs)
 

Private Attributes

double x
 
double y
 

Detailed Description

Definition at line 31 of file TwoVector.h.

Constructor & Destructor Documentation

◆ TwoVector() [1/2]

TwoVector ( )
inline

Definition at line 57 of file TwoVector.h.

58 : x(0), y(0)
59 {}

◆ TwoVector() [2/2]

TwoVector ( double  x_,
double  y_ 
)
inline

Definition at line 61 of file TwoVector.h.

62 : x(x_), y(y_)
63 {}

Member Function Documentation

◆ getComponent()

double getComponent ( int  i) const
inline

Definition at line 73 of file TwoVector.h.

74 {
75 switch (i) {
76 case 0: return getX();
77 case 1: return getY();
78 }
79 return NAN; // not-a-number, defined in cmath
80 }

◆ getMag()

double getMag ( ) const
inline

Definition at line 69 of file TwoVector.h.

69{ return std::sqrt(getMag2()); }

◆ getMag2()

double getMag2 ( ) const
inline

Definition at line 68 of file TwoVector.h.

68{ return x * x + y * y; }

◆ getPhi()

double getPhi ( ) const
inline

Definition at line 71 of file TwoVector.h.

71{ return std::atan2(y, x); }

◆ getX()

double getX ( ) const
inline

Definition at line 65 of file TwoVector.h.

65{ return x; }

◆ getY()

double getY ( ) const
inline

Definition at line 66 of file TwoVector.h.

66{ return y; }

◆ operator*=()

TwoVector & operator*= ( double  rhs)
inline

Definition at line 104 of file TwoVector.h.

105 {
106 x *= rhs;
107 y *= rhs;
108 return *this;
109 }

◆ operator+=()

TwoVector & operator+= ( const TwoVector rhs)
inline

Definition at line 90 of file TwoVector.h.

91 {
92 x += rhs.x;
93 y += rhs.y;
94 return *this;
95 }

◆ operator-=()

TwoVector & operator-= ( const TwoVector rhs)
inline

Definition at line 97 of file TwoVector.h.

98 {
99 x -= rhs.x;
100 y -= rhs.y;
101 return *this;
102 }

◆ setValues()

TwoVector & setValues ( double  x_,
double  y_ 
)
inline

Definition at line 82 of file TwoVector.h.

83 {
84 x = x_;
85 y = y_;
86 return *this;
87 }

Member Data Documentation

◆ x

double x
private

Definition at line 54 of file TwoVector.h.

◆ y

double y
private

Definition at line 54 of file TwoVector.h.


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