Belle II Software  release-08-01-10
Vector3D Class Reference

A three dimensional vector. More...

#include <Vector3D.h>

Collaboration diagram for Vector3D:

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. More...
 
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. More...
 
double normalizeTo (const double toLength)
 Normalizes the vector to the given length. More...
 
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 differenc 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. More...
 
double orthogonalComp (const Vector3D &relativTo) const
 Calculates the component orthogonal to the given vector. More...
 
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. More...
 
void passiveMoveBy (const Vector3D &by)
 Passivelly moves the vector inplace by the given vector.
 
Vector3D passiveMovedBy (const Vector3D &by)
 Passivelly 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 positiv 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. More...
 
static Vector3D average (const Vector3D &one, const Vector3D &two, const Vector3D &three)
 Constructs the average of three vectors. More...
 
static Vector3D getLowest ()
 Getter for the lowest possible vector. More...
 

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 equiped 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.

Member Function Documentation

◆ 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.

◆ cosWith()

double cosWith ( const Vector3D rhs) const
inline

Cosine of the angle between this and rhs

Definition at line 225 of file Vector3D.h.

◆ getLowest()

static Vector3D getLowest ( )
inlinestatic

Getter for the lowest possible vector.

The lowest possilbe vector according to the comparision is the null vector

Definition at line 153 of file Vector3D.h.

◆ 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.

◆ 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.

◆ 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 achiving a lower bound Vector3D(0.0, 0.0, 0.0). By first taking the norm
for comparision 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.

◆ 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 unque
orientation given by the vector relative to, the sign of the orthogonal
component is meaningless and is always set to positiv

Definition at line 440 of file Vector3D.h.

◆ 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.

◆ 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.


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