Belle II Software development
Vector3D Class Reference

A three dimensional vector. More...

#include <Vector3D.h>

Public Member Functions

 Vector3D ()
 Default constructor for ROOT compatibility.
 
 Vector3D (const TVector3 &tVector3)
 Constructor translating from a TVector3 instance.
 
 Vector3D (const B2Vector3D &b2Vector3)
 Constructor translating from a B2Vector3 instance.
 
 Vector3D (const ROOT::Math::XYZVector &xyzVector3)
 Constructor translating from a B2Vector3 instance.
 
 Vector3D (double x, double y, double z)
 Constructor from three coordinates.
 
 Vector3D (const Vector2D &xy)
 Constructor augmeting a Vector2D to a Vector3D setting z to zero.
 
 Vector3D (const Vector2D &xy, double z)
 Constructor augmeting a Vector2D to a Vector3D setting z explicitly.
 
Vector3Doperator= (const TVector3 &tVector3)
 Assignment translating from a TVector3 instance.
 
Vector3Doperator= (const B2Vector3D &b2Vector3)
 Assignment translating from a B2Vector3 instance.
 
Vector3Doperator= (const ROOT::Math::XYZVector &xyzVector3)
 Assignment translating from a B2Vector3 instance.
 
 operator const TVector3 () const
 Casting the back to TVector3 seamlessly.
 
 operator const B2Vector3D () const
 Casting the back to B2Vector3 seamlessly.
 
 operator const ROOT::Math::XYZVector () const
 Casting the back to B2Vector3 seamlessly.
 
bool operator== (const Vector3D &rhs) const
 Equality comparison with all three coordinates.
 
bool operator< (const Vector3D &rhs) const
 Total ordering based on cylindrical radius first the z component second and azimuth angle third.
 
bool isNull () const
 Checks if the vector is the null vector.
 
bool hasNAN () const
 Checks if one of the coordinates is NAN.
 
std::string __str__ () const
 Output operator for python.
 
double dot (const Vector3D &rhs) const
 Calculates the three dimensional dot product.
 
double dotXY (const Vector3D &rhs) const
 Calculates the two dimensional dot product in xy projection.
 
Vector3D cross (const Vector3D &rhs) const
 Calculated the three dimensional cross product.
 
double crossXY (const Vector3D &rhs) const
 Calculates the two dimensional cross product in xy projection.
 
double crossXY (const Vector2D &rhs) const
 Calculates the two dimensional cross product in xy projection.
 
double normSquared () const
 Calculates the squared length of the vector.
 
double norm () const
 Calculates the length of the vector.
 
double distance (const Vector3D &rhs=Vector3D(0.0, 0.0, 0.0)) const
 Calculates the distance of this point to the rhs.
 
Vector3Dscale (const double factor)
 Scales the vector in place by the given factor.
 
Vector3Doperator*= (const double factor)
 Same as scale()
 
Vector3D scaled (const double factor) const
 Returns a scaled copy of the vector.
 
Vector3D operator* (const double factor) const
 Same as scaled()
 
Vector3Ddivide (const double denominator)
 Divides all coordinates by a common denominator in place.
 
Vector3Doperator/= (const double denominator)
 Same as divide()
 
Vector3D divided (const double denominator) const
 Returns a copy where all coordinates got divided by a common denominator.
 
Vector3D operator/ (const double denominator) const
 Same as divided()
 
Vector3Dadd (const Vector3D &rhs)
 Adds a vector to this in place.
 
Vector3Dadd (const Vector2D &rhs)
 Adds a two dimensional vector to this in place taking z of the given vector as zero.
 
Vector3Doperator+= (const Vector3D &rhs)
 Same as add()
 
Vector3Doperator+= (const Vector2D &rhs)
 Same as add()
 
Vector3Dsubtract (const Vector3D &rhs)
 Subtracts a vector to this in place.
 
Vector3Dsubtract (const Vector2D &rhs)
 Subtracts a two dimensional vector from this in place taking z of the given vector as zero.
 
Vector3Doperator-= (const Vector3D &rhs)
 Same as subtract()
 
Vector3Doperator-= (const Vector2D &rhs)
 Same as subtract()
 
Vector3D unit () const
 Returns a unit vector colaligned with this.
 
double normalize ()
 Normalizes the vector to unit length.
 
double normalizeTo (const double toLength)
 Normalizes the vector to the given length.
 
Vector3Dreverse ()
 Reverses the direction of the vector in place.
 
Vector3D reversed () const
 Returns a vector pointing in the opposite direction.
 
Vector3D operator- () const
 Same as reversed()
 
Vector3D operator+ (const Vector3D &rhs) const
 Returns a new vector as sum of this and rhs.
 
Vector3D operator- (const Vector3D &rhs) const
 Returns a new vector as difference of this and rhs.
 
double parallelComp (const Vector3D &relativTo) const
 Calculates the component parallel to the given vector.
 
Vector3D parallelVector (const Vector3D &relativTo) const
 Calculates the part of this vector that is parallel to the given vector.
 
double unnormalizedParallelComp (const Vector3D &relativTo) const
 Same as parallelComp() but assumes the given vector to be of unit length.
 
double orthogonalComp (const Vector3D &relativTo) const
 Calculates the component orthogonal to the given vector.
 
Vector3D orthogonalVector (const Vector3D &relativTo) const
 Calculates the part of this vector that is parallel to the given vector.
 
double unnormalizedOrthogonalComp (const Vector3D &relativTo) const
 Same as orthogonalComp() but assumes the given vector to be of unit length.
 
void passiveMoveBy (const Vector3D &by)
 Passively moves the vector inplace by the given vector.
 
Vector3D passiveMovedBy (const Vector3D &by)
 Passively moves the vector inplace by the given vector.
 
double x () const
 Getter for the x coordinate.
 
void setX (const double x)
 Setter for the x coordinate.
 
double y () const
 Getter for the y coordinate.
 
void setY (const double y)
 Setter for the y coordinate.
 
double z () const
 Getter for the z coordinate.
 
void setZ (const double z)
 Setter for the z coordinate.
 
const Vector2Dxy () const
 Getter for the xy projected vector ( reference ! )
 
void setXY (const Vector2D &xy)
 Setter for the xy projected vector.
 
void set (const double first, const double second, const double third)
 Setter for all three coordinates.
 
double cylindricalRSquared () const
 Getter for the squared cylindrical radius ( xy projected squared norm )
 
double cylindricalR () const
 Getter for the cylindrical radius ( xy projected norm )
 
double phi () const
 Getter for the azimuth angle.
 
double theta () const
 Getter for the polar angle.
 
double lambda () const
 Getter for lambda.
 
double cotTheta () const
 Getter for the cotangent of the polar angle.
 
double tanLambda () const
 Getter for the tangent of lambda equivalent to cotTheta()
 
Angle functions

These functions measure the angle between two vectors from this to rhs.


Because the three dimensional space does not have a unique orientation available,
the sign of the angle is not well defined. Therefore angles between three dimensional
vectors are always positive and so is the sine of the angle. The angle is bound by M_PI.

double cosWith (const Vector3D &rhs) const
 
double sinWith (const Vector3D &rhs) const
 Sine of the angle between this and rhs.
 
double angleWith (const Vector3D &rhs) const
 The angle between this and rhs.
 

Static Public Member Functions

static Vector3D average (const Vector3D &one, const Vector3D &two)
 Constructs the average of two vectors.
 
static Vector3D average (const Vector3D &one, const Vector3D &two, const Vector3D &three)
 Constructs the average of three vectors.
 
static Vector3D getLowest ()
 Getter for the lowest possible vector.
 

Private Attributes

Vector2D m_xy
 Memory for the first and second coordinate available as a vector.
 
double m_z
 Memory for the third coordinate.
 

Detailed Description

A three dimensional vector.

A three dimensional vector which is equipped with the expected vector methods.
Also this vector can be passed to functions where a TVector3 is expected syntactically.

Definition at line 33 of file Vector3D.h.

Constructor & Destructor Documentation

◆ Vector3D() [1/7]

Vector3D ( )
inline

Default constructor for ROOT compatibility.

Definition at line 37 of file Vector3D.h.

38 : m_xy(0.0, 0.0)
39 , m_z(0.0)
40 {
41 }
Vector2D m_xy
Memory for the first and second coordinate available as a vector.
Definition: Vector3D.h:571
double m_z
Memory for the third coordinate.
Definition: Vector3D.h:574

◆ Vector3D() [2/7]

Vector3D ( const TVector3 &  tVector3)
explicit

Constructor translating from a TVector3 instance.

Definition at line 20 of file Vector3D.cc.

21 : m_xy(tVector3.X(), tVector3.Y())
22 , m_z(tVector3.Z())
23{
24}

◆ Vector3D() [3/7]

Vector3D ( const B2Vector3D b2Vector3)
explicit

Constructor translating from a B2Vector3 instance.

Definition at line 26 of file Vector3D.cc.

27 : m_xy(b2Vector3.X(), b2Vector3.Y())
28 , m_z(b2Vector3.Z())
29{
30}
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433

◆ Vector3D() [4/7]

Vector3D ( const ROOT::Math::XYZVector &  xyzVector3)
explicit

Constructor translating from a B2Vector3 instance.

Definition at line 32 of file Vector3D.cc.

33 : m_xy(xyzVector3.X(), xyzVector3.Y())
34 , m_z(xyzVector3.Z())
35{
36}

◆ Vector3D() [5/7]

Vector3D ( double  x,
double  y,
double  z 
)
inline

Constructor from three coordinates.

Definition at line 53 of file Vector3D.h.

54 : m_xy(x, y)
55 , m_z(z)
56 {
57 }
double x() const
Getter for the x coordinate.
Definition: Vector3D.h:472
double y() const
Getter for the y coordinate.
Definition: Vector3D.h:484
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496

◆ Vector3D() [6/7]

Vector3D ( const Vector2D xy)
inlineexplicit

Constructor augmeting a Vector2D to a Vector3D setting z to zero.

Definition at line 60 of file Vector3D.h.

61 : m_xy(xy)
62 , m_z(0.0)
63 {
64 }
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:508

◆ Vector3D() [7/7]

Vector3D ( const Vector2D xy,
double  z 
)
inline

Constructor augmeting a Vector2D to a Vector3D setting z explicitly.

Definition at line 67 of file Vector3D.h.

68 : m_xy(xy)
69 , m_z(z)
70 {
71 }

Member Function Documentation

◆ __str__()

std::string __str__ ( ) const

Output operator for python.

Definition at line 82 of file Vector3D.cc.

83{
84 std::stringstream sstream;
85 sstream << *this;
86 return sstream.str();
87}

◆ add() [1/2]

Vector3D & add ( const Vector2D rhs)
inline

Adds a two dimensional vector to this in place taking z of the given vector as zero.

Definition at line 313 of file Vector3D.h.

314 {
315 m_xy.add(rhs);
316 return *this;
317 }
Vector2D & add(const Vector2D &rhs)
Adds a vector to this in place.
Definition: Vector2D.h:262

◆ add() [2/2]

Vector3D & add ( const Vector3D rhs)
inline

Adds a vector to this in place.

Definition at line 305 of file Vector3D.h.

306 {
307 m_xy.add(rhs.xy());
308 m_z += rhs.z();
309 return *this;
310 }

◆ angleWith()

double angleWith ( const Vector3D rhs) const
inline

The angle between this and rhs.

Definition at line 237 of file Vector3D.h.

238 {
239 return atan2(sinWith(rhs), cosWith(rhs));
240 }
double sinWith(const Vector3D &rhs) const
Sine of the angle between this and rhs.
Definition: Vector3D.h:231
double cosWith(const Vector3D &rhs) const
Definition: Vector3D.h:225

◆ average() [1/2]

static Vector3D average ( const Vector3D one,
const Vector3D two 
)
inlinestatic

Constructs the average of two vectors.

Computes the average of two vectors. If one vector contains NAN the average is the other vector, since the former is not considered a valid value.

Definition at line 87 of file Vector3D.h.

88 {
89 if (one.hasNAN()) {
90 return two;
91 } else if (two.hasNAN()) {
92 return one;
93 } else {
94 return Vector3D((one.x() + two.x()) / 2.0,
95 (one.y() + two.y()) / 2.0,
96 (one.z() + two.z()) / 2.0);
97 }
98 }
Vector3D()
Default constructor for ROOT compatibility.
Definition: Vector3D.h:37

◆ average() [2/2]

static Vector3D average ( const Vector3D one,
const Vector3D two,
const Vector3D three 
)
inlinestatic

Constructs the average of three vectors.

Computes the average of three vectors. In case one of the three dimensional vectors contains an NAN, it is not considered a valid value for the average and is therefore left out. The average() of the other two vectors is then returned.

Definition at line 106 of file Vector3D.h.

107 {
108
109 if (one.hasNAN()) {
110 return average(two, three);
111 } else if (two.hasNAN()) {
112 return average(one, three);
113 } else if (three.hasNAN()) {
114 return average(one, two);
115 } else {
116 return Vector3D((one.x() + two.x() + three.x()) / 3.0,
117 (one.y() + two.y() + three.y()) / 3.0,
118 (one.z() + two.z() + three.z()) / 3.0);
119 }
120 }
static Vector3D average(const Vector3D &one, const Vector3D &two)
Constructs the average of two vectors.
Definition: Vector3D.h:87

◆ cosWith()

double cosWith ( const Vector3D rhs) const
inline

Cosine of the angle between this and rhs

Definition at line 225 of file Vector3D.h.

226 {
227 return dot(rhs) / (norm() * rhs.norm());
228 }
double dot(const Vector3D &rhs) const
Calculates the three dimensional dot product.
Definition: Vector3D.h:174
double norm() const
Calculates the length of the vector.
Definition: Vector3D.h:212

◆ cotTheta()

double cotTheta ( ) const
inline

Getter for the cotangent of the polar angle.

Definition at line 558 of file Vector3D.h.

559 {
560 return z() / cylindricalR();
561 }
double cylindricalR() const
Getter for the cylindrical radius ( xy projected norm )
Definition: Vector3D.h:534

◆ cross()

Vector3D cross ( const Vector3D rhs) const
inline

Calculated the three dimensional cross product.

Definition at line 186 of file Vector3D.h.

187 {
188 return Vector3D(y() * rhs.z() - z() * rhs.y(),
189 z() * rhs.x() - x() * rhs.z(),
190 x() * rhs.y() - y() * rhs.x());
191 }

◆ crossXY() [1/2]

double crossXY ( const Vector2D rhs) const
inline

Calculates the two dimensional cross product in xy projection.

Definition at line 200 of file Vector3D.h.

201 {
202 return xy().cross(rhs);
203 }
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
Definition: Vector2D.h:163

◆ crossXY() [2/2]

double crossXY ( const Vector3D rhs) const
inline

Calculates the two dimensional cross product in xy projection.

Definition at line 194 of file Vector3D.h.

195 {
196 return xy().cross(rhs.xy());
197 }

◆ cylindricalR()

double cylindricalR ( ) const
inline

Getter for the cylindrical radius ( xy projected norm )

Definition at line 534 of file Vector3D.h.

535 {
536 return xy().norm();
537 }
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:175

◆ cylindricalRSquared()

double cylindricalRSquared ( ) const
inline

Getter for the squared cylindrical radius ( xy projected squared norm )

Definition at line 528 of file Vector3D.h.

529 {
530 return xy().normSquared();
531 }
double normSquared() const
Calculates .
Definition: Vector2D.h:169

◆ distance()

double distance ( const Vector3D rhs = Vector3D(0.0, 0.0, 0.0)) const
inline

Calculates the distance of this point to the rhs.

Definition at line 244 of file Vector3D.h.

245 {
246 double deltaX = x() - rhs.x();
247 double deltaY = y() - rhs.y();
248 double deltaZ = z() - rhs.z();
249 return hypot3(deltaX, deltaY, deltaZ);
250 }

◆ divide()

Vector3D & divide ( const double  denominator)
inline

Divides all coordinates by a common denominator in place.

Definition at line 279 of file Vector3D.h.

280 {
281 m_xy.divide(denominator);
282 m_z /= denominator;
283 return *this;
284 }
Vector2D & divide(const double denominator)
Divides all coordinates by a common denominator in place.
Definition: Vector2D.h:237

◆ divided()

Vector3D divided ( const double  denominator) const
inline

Returns a copy where all coordinates got divided by a common denominator.

Definition at line 293 of file Vector3D.h.

294 {
295 return Vector3D(xy().divided(denominator), z() / denominator);
296 }
Vector3D divided(const double denominator) const
Returns a copy where all coordinates got divided by a common denominator.
Definition: Vector3D.h:293

◆ dot()

double dot ( const Vector3D rhs) const
inline

Calculates the three dimensional dot product.

Definition at line 174 of file Vector3D.h.

175 {
176 return x() * rhs.x() + y() * rhs.y() + z() * rhs.z();
177 }

◆ dotXY()

double dotXY ( const Vector3D rhs) const
inline

Calculates the two dimensional dot product in xy projection.

Definition at line 180 of file Vector3D.h.

181 {
182 return x() * rhs.x() + y() * rhs.y();
183 }

◆ getLowest()

static Vector3D getLowest ( )
inlinestatic

Getter for the lowest possible vector.

The lowest possible vector according to the comparison is the null vector

Definition at line 153 of file Vector3D.h.

154 {
155 return Vector3D(0.0, 0.0, 0.0);
156 }

◆ hasNAN()

bool hasNAN ( ) const
inline

Checks if one of the coordinates is NAN.

Definition at line 165 of file Vector3D.h.

166 {
167 return std::isnan(x()) or std::isnan(y()) or std::isnan(z());
168 }
STL namespace.

◆ isNull()

bool isNull ( ) const
inline

Checks if the vector is the null vector.

Definition at line 159 of file Vector3D.h.

160 {
161 return x() == 0.0 and y() == 0.0 and z() == 0.0;
162 }

◆ lambda()

double lambda ( ) const
inline

Getter for lambda.

Definition at line 552 of file Vector3D.h.

553 {
554 return atan2(z(), cylindricalR());
555 }

◆ norm()

double norm ( ) const
inline

Calculates the length of the vector.

Definition at line 212 of file Vector3D.h.

213 {
214 return hypot3(x(), y(), z());
215 }

◆ normalize()

double normalize ( )
inline

Normalizes the vector to unit length.

Normalizes the vector to unit length and returns the length the vector had before.
The null vector is not transformed.

Definition at line 367 of file Vector3D.h.

368 {
369 double result = norm();
370 if (result != 0.0) divide(result);
371 return result;
372 }
Vector3D & divide(const double denominator)
Divides all coordinates by a common denominator in place.
Definition: Vector3D.h:279

◆ normalizeTo()

double normalizeTo ( const double  toLength)
inline

Normalizes the vector to the given length.

Normalizes the vector to the given length and returns the length the vector had before.
The null vector is not transformed.

Definition at line 377 of file Vector3D.h.

378 {
379 double result = norm();
380 if (result != 0.0) scale(toLength / result);
381 return result;
382 }
Vector3D & scale(const double factor)
Scales the vector in place by the given factor.
Definition: Vector3D.h:253

◆ normSquared()

double normSquared ( ) const
inline

Calculates the squared length of the vector.

Definition at line 206 of file Vector3D.h.

207 {
208 return x() * x() + y() * y() + z() * z();
209 }

◆ operator const B2Vector3D()

operator const B2Vector3D ( ) const

Casting the back to B2Vector3 seamlessly.

Definition at line 67 of file Vector3D.cc.

68{
69 return B2Vector3D(x(), y(), z());
70}
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516

◆ operator const ROOT::Math::XYZVector()

operator const ROOT::Math::XYZVector ( ) const

Casting the back to B2Vector3 seamlessly.

Definition at line 72 of file Vector3D.cc.

73{
74 return ROOT::Math::XYZVector(x(), y(), z());
75}

◆ operator const TVector3()

operator const TVector3 ( ) const

Casting the back to TVector3 seamlessly.

Definition at line 62 of file Vector3D.cc.

63{
64 return TVector3(x(), y(), z());
65}

◆ operator*()

Vector3D operator* ( const double  factor) const
inline

Same as scaled()

Definition at line 273 of file Vector3D.h.

274 {
275 return scaled(factor);
276 }
Vector3D scaled(const double factor) const
Returns a scaled copy of the vector.
Definition: Vector3D.h:267

◆ operator*=()

Vector3D & operator*= ( const double  factor)
inline

Same as scale()

Definition at line 261 of file Vector3D.h.

262 {
263 return scale(factor);
264 }

◆ operator+()

Vector3D operator+ ( const Vector3D rhs) const
inline

Returns a new vector as sum of this and rhs.

Definition at line 404 of file Vector3D.h.

405 {
406 return Vector3D(xy() + rhs.xy(), z() + rhs.z());
407 }

◆ operator+=() [1/2]

Vector3D & operator+= ( const Vector2D rhs)
inline

Same as add()

Definition at line 326 of file Vector3D.h.

327 {
328 return add(rhs);
329 }
Vector3D & add(const Vector3D &rhs)
Adds a vector to this in place.
Definition: Vector3D.h:305

◆ operator+=() [2/2]

Vector3D & operator+= ( const Vector3D rhs)
inline

Same as add()

Definition at line 320 of file Vector3D.h.

321 {
322 return add(rhs);
323 }

◆ operator-() [1/2]

Vector3D operator- ( ) const
inline

Same as reversed()

Definition at line 398 of file Vector3D.h.

399 {
400 return reversed();
401 }
Vector3D reversed() const
Returns a vector pointing in the opposite direction.
Definition: Vector3D.h:392

◆ operator-() [2/2]

Vector3D operator- ( const Vector3D rhs) const
inline

Returns a new vector as difference of this and rhs.

Definition at line 410 of file Vector3D.h.

411 {
412 return Vector3D(xy() - rhs.xy(), z() - rhs.z());
413 }

◆ operator-=() [1/2]

Vector3D & operator-= ( const Vector2D rhs)
inline

Same as subtract()

Definition at line 353 of file Vector3D.h.

354 {
355 return subtract(rhs);
356 }
Vector3D & subtract(const Vector3D &rhs)
Subtracts a vector to this in place.
Definition: Vector3D.h:332

◆ operator-=() [2/2]

Vector3D & operator-= ( const Vector3D rhs)
inline

Same as subtract()

Definition at line 347 of file Vector3D.h.

348 {
349 return subtract(rhs);
350 }

◆ operator/()

Vector3D operator/ ( const double  denominator) const
inline

Same as divided()

Definition at line 299 of file Vector3D.h.

300 {
301 return divided(denominator);
302 }

◆ operator/=()

Vector3D & operator/= ( const double  denominator)
inline

Same as divide()

Definition at line 287 of file Vector3D.h.

288 {
289 return divide(denominator);
290 }

◆ operator<()

bool operator< ( const Vector3D rhs) const
inline

Total ordering based on cylindrical radius first the z component second and azimuth angle third.

Total order achieving a lower bound Vector3D(0.0, 0.0, 0.0). By first taking the norm
for comparison the null vector is smaller than all other possible
vectors. Secondly the polar angle theta ( equivalently z ) and finally the azimuth
angle phi is considered to have a total ordering for all vectors.
Note does not commute with the projection to xy space.

Definition at line 145 of file Vector3D.h.

146 {
147 return norm() < rhs.norm() or (norm() == rhs.norm() and
148 (z() < rhs.z() or (z() == rhs.z() and (phi() < rhs.phi()))));
149 }
double phi() const
Getter for the azimuth angle.
Definition: Vector3D.h:540

◆ operator=() [1/3]

Vector3D & operator= ( const B2Vector3D b2Vector3)

Assignment translating from a B2Vector3 instance.

Definition at line 46 of file Vector3D.cc.

47{
48 m_xy.setX(b2Vector3.X());
49 m_xy.setY(b2Vector3.Y());
50 m_z = b2Vector3.Z();
51 return *this;
52}
void setY(const double y)
Setter for the y coordinate.
Definition: Vector2D.h:610
void setX(const double x)
Setter for the x coordinate.
Definition: Vector2D.h:600

◆ operator=() [2/3]

Vector3D & operator= ( const ROOT::Math::XYZVector &  xyzVector3)

Assignment translating from a B2Vector3 instance.

Definition at line 54 of file Vector3D.cc.

55{
56 m_xy.setX(xyzVector3.X());
57 m_xy.setY(xyzVector3.Y());
58 m_z = xyzVector3.Z();
59 return *this;
60}

◆ operator=() [3/3]

Vector3D & operator= ( const TVector3 &  tVector3)

Assignment translating from a TVector3 instance.

Definition at line 38 of file Vector3D.cc.

39{
40 m_xy.setX(tVector3.X());
41 m_xy.setY(tVector3.Y());
42 m_z = tVector3.Z();
43 return *this;
44}

◆ operator==()

bool operator== ( const Vector3D rhs) const
inline

Equality comparison with all three coordinates.

Definition at line 132 of file Vector3D.h.

133 {
134 return x() == rhs.x() and y() == rhs.y() and z() == rhs.z();
135 }

◆ orthogonalComp()

double orthogonalComp ( const Vector3D relativTo) const
inline

Calculates the component orthogonal to the given vector.

The orthogonal component is the rest of the vector not parallel to
relative to. Since the three dimensional space does not have a unique
orientation given by the vector relative to, the sign of the orthogonal
component is meaningless and is always set to positive

Definition at line 440 of file Vector3D.h.

441 {
442 return relativTo.cross(*this).norm() / relativTo.norm();
443 }

◆ orthogonalVector()

Vector3D orthogonalVector ( const Vector3D relativTo) const
inline

Calculates the part of this vector that is parallel to the given vector.

Definition at line 446 of file Vector3D.h.

447 {
448 return *this - parallelVector(relativTo);
449 }
Vector3D parallelVector(const Vector3D &relativTo) const
Calculates the part of this vector that is parallel to the given vector.
Definition: Vector3D.h:422

◆ parallelComp()

double parallelComp ( const Vector3D relativTo) const
inline

Calculates the component parallel to the given vector.

Definition at line 416 of file Vector3D.h.

417 {
418 return relativTo.dot(*this) / relativTo.norm();
419 }

◆ parallelVector()

Vector3D parallelVector ( const Vector3D relativTo) const
inline

Calculates the part of this vector that is parallel to the given vector.

Definition at line 422 of file Vector3D.h.

423 {
424 return relativTo.scaled(relativTo.dot(*this) / relativTo.normSquared());
425 }

◆ passiveMoveBy()

void passiveMoveBy ( const Vector3D by)
inline

Passively moves the vector inplace by the given vector.

Definition at line 460 of file Vector3D.h.

461 {
462 subtract(by);
463 }

◆ passiveMovedBy()

Vector3D passiveMovedBy ( const Vector3D by)
inline

Passively moves the vector inplace by the given vector.

Definition at line 466 of file Vector3D.h.

467 {
468 return *this - by;
469 }

◆ phi()

double phi ( ) const
inline

Getter for the azimuth angle.

Definition at line 540 of file Vector3D.h.

541 {
542 return xy().phi();
543 }
double phi() const
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
Definition: Vector2D.h:569

◆ reverse()

Vector3D & reverse ( )
inline

Reverses the direction of the vector in place.

Definition at line 385 of file Vector3D.h.

386 {
387 scale(-1.0);
388 return *this;
389 }

◆ reversed()

Vector3D reversed ( ) const
inline

Returns a vector pointing in the opposite direction.

Definition at line 392 of file Vector3D.h.

393 {
394 return scaled(-1.0);
395 }

◆ scale()

Vector3D & scale ( const double  factor)
inline

Scales the vector in place by the given factor.

Definition at line 253 of file Vector3D.h.

254 {
255 m_xy.scale(factor);
256 m_z *= factor;
257 return *this;
258 }
Vector2D & scale(const double factor)
Scales the vector in place by the given factor.
Definition: Vector2D.h:212

◆ scaled()

Vector3D scaled ( const double  factor) const
inline

Returns a scaled copy of the vector.

Definition at line 267 of file Vector3D.h.

268 {
269 return Vector3D(xy().scaled(factor), z() * factor);
270 }

◆ set()

void set ( const double  first,
const double  second,
const double  third 
)
inline

Setter for all three coordinates.

Definition at line 520 of file Vector3D.h.

521 {
522 setX(first);
523 setY(second);
524 setZ(third);
525 }
void setZ(const double z)
Setter for the z coordinate.
Definition: Vector3D.h:502
void setY(const double y)
Setter for the y coordinate.
Definition: Vector3D.h:490
void setX(const double x)
Setter for the x coordinate.
Definition: Vector3D.h:478

◆ setX()

void setX ( const double  x)
inline

Setter for the x coordinate.

Definition at line 478 of file Vector3D.h.

479 {
480 m_xy.setX(x);
481 }

◆ setXY()

void setXY ( const Vector2D xy)
inline

Setter for the xy projected vector.

Definition at line 514 of file Vector3D.h.

515 {
516 m_xy = xy;
517 }

◆ setY()

void setY ( const double  y)
inline

Setter for the y coordinate.

Definition at line 490 of file Vector3D.h.

491 {
492 m_xy.setY(y);
493 }

◆ setZ()

void setZ ( const double  z)
inline

Setter for the z coordinate.

Definition at line 502 of file Vector3D.h.

503 {
504 m_z = z;
505 }

◆ sinWith()

double sinWith ( const Vector3D rhs) const
inline

Sine of the angle between this and rhs.

Definition at line 231 of file Vector3D.h.

232 {
233 return cross(rhs).norm() / (norm() * rhs.norm());
234 }
Vector3D cross(const Vector3D &rhs) const
Calculated the three dimensional cross product.
Definition: Vector3D.h:186

◆ subtract() [1/2]

Vector3D & subtract ( const Vector2D rhs)
inline

Subtracts a two dimensional vector from this in place taking z of the given vector as zero.

Definition at line 340 of file Vector3D.h.

341 {
342 m_xy.subtract(rhs);
343 return *this;
344 }
Vector2D & subtract(const Vector2D &rhs)
Subtracts a vector from this in place.
Definition: Vector2D.h:276

◆ subtract() [2/2]

Vector3D & subtract ( const Vector3D rhs)
inline

Subtracts a vector to this in place.

Definition at line 332 of file Vector3D.h.

333 {
334 m_xy.subtract(rhs.xy());
335 m_z -= rhs.z();
336 return *this;
337 }

◆ tanLambda()

double tanLambda ( ) const
inline

Getter for the tangent of lambda equivalent to cotTheta()

Definition at line 564 of file Vector3D.h.

565 {
566 return z() / cylindricalR();
567 }

◆ theta()

double theta ( ) const
inline

Getter for the polar angle.

Definition at line 546 of file Vector3D.h.

547 {
548 return atan2(cylindricalR(), z());
549 }

◆ unit()

Vector3D unit ( ) const
inline

Returns a unit vector colaligned with this.

Definition at line 359 of file Vector3D.h.

360 {
361 return isNull() ? Vector3D(0.0, 0.0, 0.0) : divided(norm());
362 }
bool isNull() const
Checks if the vector is the null vector.
Definition: Vector3D.h:159

◆ unnormalizedOrthogonalComp()

double unnormalizedOrthogonalComp ( const Vector3D relativTo) const
inline

Same as orthogonalComp() but assumes the given vector to be of unit length.

This assumes the given vector relativeTo to be of unit length and avoids
a costly computation of the vector norm()

Definition at line 454 of file Vector3D.h.

455 {
456 return relativTo.cross(*this).norm();
457 }

◆ unnormalizedParallelComp()

double unnormalizedParallelComp ( const Vector3D relativTo) const
inline

Same as parallelComp() but assumes the given vector to be of unit length.

This assumes the given vector relativeTo to be of unit length and avoids
a costly computation of the vector norm()

Definition at line 430 of file Vector3D.h.

431 {
432 return relativTo.dot(*this);
433 }

◆ x()

double x ( ) const
inline

Getter for the x coordinate.

Definition at line 472 of file Vector3D.h.

473 {
474 return m_xy.x();
475 }
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:595

◆ xy()

const Vector2D & xy ( ) const
inline

Getter for the xy projected vector ( reference ! )

Definition at line 508 of file Vector3D.h.

509 {
510 return m_xy;
511 }

◆ y()

double y ( ) const
inline

Getter for the y coordinate.

Definition at line 484 of file Vector3D.h.

485 {
486 return m_xy.y();
487 }
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:605

◆ z()

double z ( ) const
inline

Getter for the z coordinate.

Definition at line 496 of file Vector3D.h.

497 {
498 return m_z;
499 }

Member Data Documentation

◆ m_xy

Vector2D m_xy
private

Memory for the first and second coordinate available as a vector.

Definition at line 571 of file Vector3D.h.

◆ m_z

double m_z
private

Memory for the third coordinate.

Definition at line 574 of file Vector3D.h.


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