Belle II Software prerelease-11-00-00a
Vector3D Class Reference

A three dimensional vector. More...

#include <Vector3D.h>

Collaboration diagram for Vector3D:

Public Member Functions

 Vector3D ()=default
 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 &xyzVector)
 Constructor translating from a ROOT::Math::XYZVector 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 &xyzVector)
 Assignment translating from a ROOT::Math::XYZVector 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 ROOT::Math::XYZVector 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 Dot (const Vector3D &rhs) const
 Calculates the three dimensional dot product, ROOT::Math compatible.
 
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 Mag2 () const
 Alias for normSquared.
 
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.
 
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 orthogonal 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 {0.0, 0.0}
 Memory for the first and second coordinate available as a vector.
 
double m_z = 0.0
 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 34 of file Vector3D.h.

Constructor & Destructor Documentation

◆ Vector3D() [1/6]

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}
Vector2D m_xy
Memory for the first and second coordinate available as a vector.
Definition Vector3D.h:572
double m_z
Memory for the third coordinate.
Definition Vector3D.h:575

◆ Vector3D() [2/6]

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() [3/6]

Vector3D ( const ROOT::Math::XYZVector & xyzVector)

Constructor translating from a ROOT::Math::XYZVector instance.

Definition at line 32 of file Vector3D.cc.

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

◆ Vector3D() [4/6]

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

Constructor from three coordinates.

Definition at line 50 of file Vector3D.h.

51 : m_xy(x, y)
52 , m_z(z)
53 {
54 }

◆ Vector3D() [5/6]

Vector3D ( const Vector2D & xy)
inlineexplicit

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

Definition at line 57 of file Vector3D.h.

58 : m_xy(xy)
59 , m_z(0.0)
60 {
61 }

◆ Vector3D() [6/6]

Vector3D ( const Vector2D & xy,
double z )
inline

Constructor augmeting a Vector2D to a Vector3D setting z explicitly.

Definition at line 64 of file Vector3D.h.

65 : m_xy(xy)
66 , m_z(z)
67 {
68 }

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 320 of file Vector3D.h.

321 {
322 m_xy.add(rhs);
323 return *this;
324 }

◆ add() [2/2]

Vector3D & add ( const Vector3D & rhs)
inline

Adds a vector to this in place.

Definition at line 312 of file Vector3D.h.

313 {
314 m_xy.add(rhs.xy());
315 m_z += rhs.z();
316 return *this;
317 }

◆ angleWith()

double angleWith ( const Vector3D & rhs) const
inline

The angle between this and rhs.

Definition at line 244 of file Vector3D.h.

245 {
246 return atan2(sinWith(rhs), cosWith(rhs));
247 }

◆ 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 84 of file Vector3D.h.

85 {
86 if (one.hasNAN()) {
87 return two;
88 } else if (two.hasNAN()) {
89 return one;
90 } else {
91 return Vector3D((one.x() + two.x()) / 2.0,
92 (one.y() + two.y()) / 2.0,
93 (one.z() + two.z()) / 2.0);
94 }
95 }
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34

◆ 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 103 of file Vector3D.h.

104 {
105
106 if (one.hasNAN()) {
107 return average(two, three);
108 } else if (two.hasNAN()) {
109 return average(one, three);
110 } else if (three.hasNAN()) {
111 return average(one, two);
112 } else {
113 return Vector3D((one.x() + two.x() + three.x()) / 3.0,
114 (one.y() + two.y() + three.y()) / 3.0,
115 (one.z() + two.z() + three.z()) / 3.0);
116 }
117 }

◆ cosWith()

double cosWith ( const Vector3D & rhs) const
inline

Cosine of the angle between this and rhs

Definition at line 232 of file Vector3D.h.

233 {
234 return dot(rhs) / (norm() * rhs.norm());
235 }
T dot(GeneralVector< T > a, GeneralVector< T > b)
dot product of two general vectors

◆ cotTheta()

double cotTheta ( ) const
inline

Getter for the cotangent of the polar angle.

Definition at line 559 of file Vector3D.h.

560 {
561 return z() / cylindricalR();
562 }

◆ cross()

Vector3D cross ( const Vector3D & rhs) const
inline

Calculated the three dimensional cross product.

Definition at line 188 of file Vector3D.h.

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

◆ crossXY() [1/2]

double crossXY ( const Vector2D & rhs) const
inline

Calculates the two dimensional cross product in xy projection.

Definition at line 202 of file Vector3D.h.

203 {
204 return xy().cross(rhs);
205 }

◆ crossXY() [2/2]

double crossXY ( const Vector3D & rhs) const
inline

Calculates the two dimensional cross product in xy projection.

Definition at line 196 of file Vector3D.h.

197 {
198 return xy().cross(rhs.xy());
199 }

◆ cylindricalR()

double cylindricalR ( ) const
inline

Getter for the cylindrical radius ( xy projected norm )

Definition at line 535 of file Vector3D.h.

536 {
537 return xy().norm();
538 }

◆ cylindricalRSquared()

double cylindricalRSquared ( ) const
inline

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

Definition at line 529 of file Vector3D.h.

530 {
531 return xy().normSquared();
532 }

◆ 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 251 of file Vector3D.h.

252 {
253 double deltaX = x() - rhs.x();
254 double deltaY = y() - rhs.y();
255 double deltaZ = z() - rhs.z();
256 return hypot3(deltaX, deltaY, deltaZ);
257 }

◆ divide()

Vector3D & divide ( const double denominator)
inline

Divides all coordinates by a common denominator in place.

Definition at line 286 of file Vector3D.h.

287 {
288 m_xy.divide(denominator);
289 m_z /= denominator;
290 return *this;
291 }

◆ divided()

Vector3D divided ( const double denominator) const
inline

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

Definition at line 300 of file Vector3D.h.

301 {
302 return Vector3D(xy().divided(denominator), z() / denominator);
303 }

◆ Dot()

double Dot ( const Vector3D & rhs) const
inline

Calculates the three dimensional dot product, ROOT::Math compatible.

Definition at line 176 of file Vector3D.h.

177 {
178 return dot(rhs);
179 }

◆ dot()

double dot ( const Vector3D & rhs) const
inline

Calculates the three dimensional dot product.

Definition at line 171 of file Vector3D.h.

172 {
173 return x() * rhs.x() + y() * rhs.y() + z() * rhs.z();
174 }

◆ dotXY()

double dotXY ( const Vector3D & rhs) const
inline

Calculates the two dimensional dot product in xy projection.

Definition at line 182 of file Vector3D.h.

183 {
184 return x() * rhs.x() + y() * rhs.y();
185 }

◆ 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 150 of file Vector3D.h.

151 {
152 return Vector3D(0.0, 0.0, 0.0);
153 }

◆ hasNAN()

bool hasNAN ( ) const
inline

Checks if one of the coordinates is NAN.

Definition at line 162 of file Vector3D.h.

163 {
164 return std::isnan(x()) or std::isnan(y()) or std::isnan(z());
165 }

◆ isNull()

bool isNull ( ) const
inline

Checks if the vector is the null vector.

Definition at line 156 of file Vector3D.h.

157 {
158 return x() == 0.0 and y() == 0.0 and z() == 0.0;
159 }

◆ lambda()

double lambda ( ) const
inline

Getter for lambda.

Definition at line 553 of file Vector3D.h.

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

◆ Mag2()

double Mag2 ( ) const
inline

Alias for normSquared.

Definition at line 213 of file Vector3D.h.

214 {
215 return normSquared();
216 }

◆ norm()

double norm ( ) const
inline

Calculates the length of the vector.

Definition at line 219 of file Vector3D.h.

220 {
221 return hypot3(x(), y(), z());
222 }

◆ 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 374 of file Vector3D.h.

375 {
376 double result = norm();
377 if (result != 0.0) divide(result);
378 return result;
379 }

◆ 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 384 of file Vector3D.h.

385 {
386 double result = norm();
387 if (result != 0.0) scale(toLength / result);
388 return result;
389 }

◆ normSquared()

double normSquared ( ) const
inline

Calculates the squared length of the vector.

Definition at line 208 of file Vector3D.h.

209 {
210 return x() * x() + y() * y() + z() * z();
211 }

◆ 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}
double x() const
Getter for the x coordinate.
Definition Vector3D.h:473
double y() const
Getter for the y coordinate.
Definition Vector3D.h:485
double z() const
Getter for the z coordinate.
Definition Vector3D.h:497
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 ROOT::Math::XYZVector 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 280 of file Vector3D.h.

281 {
282 return scaled(factor);
283 }

◆ operator*=()

Vector3D & operator*= ( const double factor)
inline

Same as scale()

Definition at line 268 of file Vector3D.h.

269 {
270 return scale(factor);
271 }

◆ operator+()

Vector3D operator+ ( const Vector3D & rhs) const
inline

Returns a new vector as sum of this and rhs.

Definition at line 411 of file Vector3D.h.

412 {
413 return Vector3D(xy() + rhs.xy(), z() + rhs.z());
414 }

◆ operator+=() [1/2]

Vector3D & operator+= ( const Vector2D & rhs)
inline

Same as add()

Definition at line 333 of file Vector3D.h.

334 {
335 return add(rhs);
336 }

◆ operator+=() [2/2]

Vector3D & operator+= ( const Vector3D & rhs)
inline

Same as add()

Definition at line 327 of file Vector3D.h.

328 {
329 return add(rhs);
330 }

◆ operator-() [1/2]

Vector3D operator- ( ) const
inline

Same as reversed()

Definition at line 405 of file Vector3D.h.

406 {
407 return reversed();
408 }
EForwardBackward reversed(EForwardBackward eForwardBackward)
Return the reversed forward backward indicator. Leaves EForwardBackward::c_Invalid the same.

◆ operator-() [2/2]

Vector3D operator- ( const Vector3D & rhs) const
inline

Returns a new vector as difference of this and rhs.

Definition at line 417 of file Vector3D.h.

418 {
419 return Vector3D(xy() - rhs.xy(), z() - rhs.z());
420 }

◆ operator-=() [1/2]

Vector3D & operator-= ( const Vector2D & rhs)
inline

Same as subtract()

Definition at line 360 of file Vector3D.h.

361 {
362 return subtract(rhs);
363 }

◆ operator-=() [2/2]

Vector3D & operator-= ( const Vector3D & rhs)
inline

Same as subtract()

Definition at line 354 of file Vector3D.h.

355 {
356 return subtract(rhs);
357 }

◆ operator/()

Vector3D operator/ ( const double denominator) const
inline

Same as divided()

Definition at line 306 of file Vector3D.h.

307 {
308 return divided(denominator);
309 }

◆ operator/=()

Vector3D & operator/= ( const double denominator)
inline

Same as divide()

Definition at line 294 of file Vector3D.h.

295 {
296 return divide(denominator);
297 }

◆ 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 142 of file Vector3D.h.

143 {
144 return norm() < rhs.norm() or (norm() == rhs.norm() and
145 (z() < rhs.z() or (z() == rhs.z() and (phi() < rhs.phi()))));
146 }

◆ 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:647
void setX(const double x)
Setter for the x coordinate.
Definition Vector2D.h:632

◆ operator=() [2/3]

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

Assignment translating from a ROOT::Math::XYZVector instance.

Definition at line 54 of file Vector3D.cc.

55{
56 m_xy.setX(xyzVector.X());
57 m_xy.setY(xyzVector.Y());
58 m_z = xyzVector.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 129 of file Vector3D.h.

130 {
131 return x() == rhs.x() and y() == rhs.y() and z() == rhs.z();
132 }

◆ 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 441 of file Vector3D.h.

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

◆ orthogonalVector()

Vector3D orthogonalVector ( const Vector3D & relativTo) const
inline

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

Definition at line 447 of file Vector3D.h.

448 {
449 return *this - Belle2::VectorUtil::parallelVector(*this, relativTo);
450 }

◆ parallelComp()

double parallelComp ( const Vector3D & relativTo) const
inline

Calculates the component parallel to the given vector.

Definition at line 423 of file Vector3D.h.

424 {
425 return relativTo.dot(*this) / relativTo.norm();
426 }

◆ passiveMoveBy()

void passiveMoveBy ( const Vector3D & by)
inline

Passively moves the vector inplace by the given vector.

Definition at line 461 of file Vector3D.h.

462 {
463 subtract(by);
464 }

◆ passiveMovedBy()

Vector3D passiveMovedBy ( const Vector3D & by)
inline

Passively moves the vector inplace by the given vector.

Definition at line 467 of file Vector3D.h.

468 {
469 return *this - by;
470 }

◆ phi()

double phi ( ) const
inline

Getter for the azimuth angle.

Definition at line 541 of file Vector3D.h.

542 {
543 return xy().phi();
544 }

◆ reverse()

Vector3D & reverse ( )
inline

Reverses the direction of the vector in place.

Definition at line 392 of file Vector3D.h.

393 {
394 scale(-1.0);
395 return *this;
396 }

◆ reversed()

Vector3D reversed ( ) const
inline

Returns a vector pointing in the opposite direction.

Definition at line 399 of file Vector3D.h.

400 {
401 return scaled(-1.0);
402 }

◆ scale()

Vector3D & scale ( const double factor)
inline

Scales the vector in place by the given factor.

Definition at line 260 of file Vector3D.h.

261 {
262 m_xy.scale(factor);
263 m_z *= factor;
264 return *this;
265 }

◆ scaled()

Vector3D scaled ( const double factor) const
inline

Returns a scaled copy of the vector.

Definition at line 274 of file Vector3D.h.

275 {
276 return Vector3D(xy().scaled(factor), z() * factor);
277 }

◆ set()

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

Setter for all three coordinates.

Definition at line 521 of file Vector3D.h.

522 {
523 setX(first);
524 setY(second);
525 setZ(third);
526 }

◆ setX()

void setX ( const double x)
inline

Setter for the x coordinate.

Definition at line 479 of file Vector3D.h.

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

◆ setXY()

void setXY ( const Vector2D & xy)
inline

Setter for the xy projected vector.

Definition at line 515 of file Vector3D.h.

516 {
517 m_xy = xy;
518 }

◆ setY()

void setY ( const double y)
inline

Setter for the y coordinate.

Definition at line 491 of file Vector3D.h.

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

◆ setZ()

void setZ ( const double z)
inline

Setter for the z coordinate.

Definition at line 503 of file Vector3D.h.

504 {
505 m_z = z;
506 }

◆ sinWith()

double sinWith ( const Vector3D & rhs) const
inline

Sine of the angle between this and rhs.

Definition at line 238 of file Vector3D.h.

239 {
240 return cross(rhs).norm() / (norm() * rhs.norm());
241 }

◆ 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 347 of file Vector3D.h.

348 {
349 m_xy.subtract(rhs);
350 return *this;
351 }

◆ subtract() [2/2]

Vector3D & subtract ( const Vector3D & rhs)
inline

Subtracts a vector to this in place.

Definition at line 339 of file Vector3D.h.

340 {
341 m_xy.subtract(rhs.xy());
342 m_z -= rhs.z();
343 return *this;
344 }

◆ tanLambda()

double tanLambda ( ) const
inline

Getter for the tangent of lambda equivalent to cotTheta()

Definition at line 565 of file Vector3D.h.

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

◆ theta()

double theta ( ) const
inline

Getter for the polar angle.

Definition at line 547 of file Vector3D.h.

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

◆ unit()

Vector3D unit ( ) const
inline

Returns a unit vector colaligned with this.

Definition at line 366 of file Vector3D.h.

367 {
368 return isNull() ? Vector3D(0.0, 0.0, 0.0) : divided(norm());
369 }

◆ 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 455 of file Vector3D.h.

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

◆ 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 431 of file Vector3D.h.

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

◆ x()

double x ( ) const
inline

Getter for the x coordinate.

Definition at line 473 of file Vector3D.h.

474 {
475 return m_xy.x();
476 }

◆ xy()

const Vector2D & xy ( ) const
inline

Getter for the xy projected vector ( reference ! )

Definition at line 509 of file Vector3D.h.

510 {
511 return m_xy;
512 }

◆ y()

double y ( ) const
inline

Getter for the y coordinate.

Definition at line 485 of file Vector3D.h.

486 {
487 return m_xy.y();
488 }

◆ z()

double z ( ) const
inline

Getter for the z coordinate.

Definition at line 497 of file Vector3D.h.

498 {
499 return m_z;
500 }

Member Data Documentation

◆ m_xy

Vector2D m_xy {0.0, 0.0}
private

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

Definition at line 572 of file Vector3D.h.

572{0.0, 0.0};

◆ m_z

double m_z = 0.0
private

Memory for the third coordinate.

Definition at line 575 of file Vector3D.h.


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