Belle II Software
release-08-01-10
|
A two dimensional vector which is equipped with functions for correct handeling
of orientation related issues in addition to the expected vector methods.
More...
#include <Vector2D.h>
Public Member Functions | |
Vector2D () | |
Default constructor for ROOT compatibility. | |
Vector2D (const TVector2 &tVector2) | |
Constructor translating from a TVector2 instance. | |
Vector2D (const double x, const double y) | |
Constructor from two coordinates. | |
Vector2D (const Vector2D &coordinateVec, const double parallelCoor, const double orthoCoor) | |
Constructs a vector from a unit coordinate system vector and the coordinates in that system. More... | |
Vector2D & | operator= (const TVector2 &tvector) |
Assignment translating from a TVector2 instance. | |
operator const TVector2 () | |
Casting the back to TVector2 seamlessly. | |
bool | operator== (const Vector2D &rhs) const |
Equality comparison with both coordinates. | |
bool | operator< (const Vector2D &rhs) const |
Total ordering based on cylindrical radius first and azimuth angle second. 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 Vector2D &rhs) const |
Calculates the two dimensional dot product. | |
double | cross (const Vector2D &rhs) const |
Calculated the two dimensional cross product. | |
double | normSquared () const |
Calculates . | |
double | norm () const |
Calculates the length of the vector. | |
double | distance (const Vector2D &rhs=Vector2D(0.0, 0.0)) const |
Calculates the distance of this point to the rhs. | |
Vector2D & | scale (const double factor) |
Scales the vector in place by the given factor. | |
Vector2D & | operator*= (const double factor) |
Same as scale() | |
Vector2D | scaled (const double factor) const |
Returns a scaled copy of the vector. | |
Vector2D & | divide (const double denominator) |
Divides all coordinates by a common denominator in place. | |
Vector2D & | operator/= (const double denominator) |
Same as divide() | |
Vector2D | divided (const double denominator) const |
Returns a copy where all coordinates got divided by a common denominator. | |
Vector2D | operator/ (const double denominator) const |
Same as divided() | |
Vector2D & | add (const Vector2D &rhs) |
Adds a vector to this in place. | |
Vector2D & | operator+= (const Vector2D &rhs) |
Same as add() | |
Vector2D & | subtract (const Vector2D &rhs) |
Subtracts a vector from this in place. | |
Vector2D & | operator-= (const Vector2D &rhs) |
Same as subtract() | |
Vector2D | orthogonal () const |
Orthogonal vector to the counterclockwise direction. | |
Vector2D | orthogonal (const ERotation ccwInfo) const |
Orthogonal vector to the direction given by the counterclockwise info. | |
double | normalize () |
Normalizes the vector to unit length. More... | |
double | normalizeTo (const double toLength) |
Normalizes the vector to the given length. More... | |
Vector2D | unit () const |
Returns a unit vector colaligned with this. | |
Vector2D & | reverse () |
Reverses the direction of the vector in place. | |
Vector2D | reversed () const |
Returns a vector pointing in the opposite direction. | |
Vector2D | operator- () const |
Same as reversed() | |
void | flipFirst () |
Flips the first coordinate inplace (no difference between active and passive) | |
void | flipSecond () |
Flips the first coordinate inplace (no difference between active and passive) | |
Vector2D | flippedFirst () const |
Makes a copy of the vector with the first coordinate flipped (no difference between active and passive) | |
Vector2D | flippedSecond () const |
Makes a copy of the vector with the second coordinate flipped (no difference between active and passive) | |
Vector2D | flippedOver (const Vector2D &reflectionLine) const |
Reflects this vector over line designated by the given vector. | |
Vector2D | flippedAlong (const Vector2D &flippingDirection) const |
Reflects this vector along line designated by the given vector. | |
void | conformalTransform () |
Transforms the vector to conformal space inplace. More... | |
Vector2D | conformalTransformed () const |
Returns a copy of the vector transformed in conformal space. More... | |
Vector2D | operator+ (const Vector2D &rhs) const |
Returns a new vector as sum of this and rhs. | |
Vector2D | operator- (const Vector2D &rhs) const |
Returns a new vector as differenc of this and rhs. | |
double | parallelComp (const Vector2D &relativTo) const |
Calculates the component parallel to the given vector. | |
Vector2D | parallelVector (const Vector2D &relativTo) const |
Calculates the part of this vector that is parallel to the given vector. | |
double | unnormalizedParallelComp (const Vector2D &relativTo) const |
Same as parallelComp() but assumes the given vector to be of unit length. More... | |
double | orthogonalComp (const Vector2D &relativTo) const |
Calculates the component orthogonal to the given vector. More... | |
Vector2D | orthogonalVector (const Vector2D &relativTo) const |
Calculates the part of this vector that is parallel to the given vector. | |
double | unnormalizedOrthogonalComp (const Vector2D &relativTo) const |
Same as orthogonalComp() but assumes the given vector to be of unit length. More... | |
ERightLeft | isRightOrLeftOf (const Vector2D &rhs) const |
Indicates if the given vector is more left or more right if you looked in the direction of this vector. | |
bool | isLeftOf (const Vector2D &rhs) const |
Indicates if the given vector is more left if you looked in the direction of this vector. | |
bool | isRightOf (const Vector2D &rhs) const |
Indicates if the given vector is more right if you looked in the direction of this vector. | |
ERotation | isCCWOrCWOf (const Vector2D &rhs) const |
Indicates if the given vector is more counterclockwise or more clockwise if you looked in the direction of this vector. | |
bool | isCCWOf (const Vector2D &rhs) const |
Indicates if the given vector is more counterclockwise if you looked in the direction of this vector. | |
bool | isCWOf (const Vector2D &rhs) const |
Indicates if the given vector is more clockwise if you looked in the direction of this vector. | |
EForwardBackward | isForwardOrBackwardOf (const Vector2D &rhs) const |
Indicates if the given vector is more coaligned or reverse if you looked in the direction of this vector. | |
bool | isForwardOf (const Vector2D &rhs) const |
Indicates if the given vector is more coaligned if you looked in the direction of this vector. | |
bool | isBackwardOf (const Vector2D &rhs) const |
Indicates if the given vector is more Reverse if you looked in the direction of this vector. | |
bool | isBetween (const Vector2D &lower, const Vector2D &upper) const |
Checks if this vector is between two other vectors Between means here that when rotating the lower vector (first argument) mathematically positively it becomes coaligned with this vector before it becomes coalgined with the other vector. | |
void | swapCoordinates () |
Swaps the coordinates in place. | |
double | cylindricalR () const |
Gives the cylindrical radius of the vector. Same as norm() | |
void | setCylindricalR (const double cylindricalR) |
Set the cylindrical radius while keeping the azimuth angle phi the same. | |
double | phi () const |
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI ) | |
void | passiveMoveBy (const Vector2D &by) |
Passivelly moves the vector inplace by the given vector. | |
Vector2D | passiveMovedBy (const Vector2D &by) const |
Returns a transformed vector passivelly moved by the given vector. | |
Vector2D | passiveRotatedBy (const Vector2D &phiVec) const |
Returns a transformed vector version rotated by the given vector. More... | |
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. | |
void | setXY (const double x, const double y) |
Setter for both coordinate. | |
void | setXY (const Vector2D &xy) |
Setter for both coordinate by an other vector. | |
double | first () const |
Getter for the first coordinate. | |
void | setFirst (const double first) |
Setter for the first coordinate. | |
double | second () const |
Getter for the second coordinate. | |
void | setSecond (const double second) |
Setter for the second coordinate. | |
void | set (const double first, const double second) |
Setter for both coordinate. | |
void | set (const Vector2D &both) |
Setter for both coordinate by an other vector. | |
Angle functions | |
These functions measure the angle between two vectors from this to rhs in the mathematical positve counterclockwise direction. So a positiv angle means rhs is more counterclockwise than this. | |
double | cosWith (const Vector2D &rhs) const |
double | sinWith (const Vector2D &rhs) const |
Sine of the angle between this and rhs. | |
double | angleWith (const Vector2D &rhs) const |
The angle between this and rhs. | |
Static Public Member Functions | |
static Vector2D | Phi (const double phi) |
Constucts a unit vector with azimuth angle equal to phi. | |
static Vector2D | compose (const Vector2D &coordinateVec, const double parallelCoor, const double orthoCoor) |
Constructs a vector from a unit coordinate system vector and the coordinates in that system. More... | |
static Vector2D | average (const Vector2D &one, const Vector2D &two) |
Constructs the average of two vectors. More... | |
static Vector2D | average (const Vector2D &one, const Vector2D &two, const Vector2D &three) |
Constructs the average of three vectors. More... | |
static Vector2D | getLowest () |
Getter for the lowest possible vector. More... | |
Static Private Member Functions | |
static bool | sameSign (float n1, float n2, float n3) |
Check if three values have the same sign. | |
Private Attributes | |
double | m_x |
Memory for the first coordinate. | |
double | m_y |
Memory for the second coordinate. | |
Friends | |
Vector2D | operator* (const Vector2D &vec2D, const double factor) |
Same as scaled() | |
A two dimensional vector which is equipped with functions for correct handeling
of orientation related issues in addition to the expected vector methods.
Also this vector can be passed to functions where a TVector2 is expected syntactically.
Definition at line 35 of file Vector2D.h.
|
inline |
Constructs a vector from a unit coordinate system vector and the coordinates in that system.
Same as compose() See compose() for details.
Definition at line 61 of file Vector2D.h.
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 93 of file Vector2D.h.
|
inlinestatic |
Constructs the average of three vectors.
Computes the average of three vectors. In case one of the two 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 110 of file Vector2D.h.
|
inlinestatic |
Constructs a vector from a unit coordinate system vector and the coordinates in that system.
Combines a coordinate system vector expressed in laboratory coordinates
with the parallel and orthogonal components in the coordinate system
to a vector in laboratory coordinates. The coordinate system vector
is assumed the unit of the coordinate system
Definition at line 83 of file Vector2D.h.
|
inline |
Transforms the vector to conformal space inplace.
Applies the conformal map in the self-inverse from X = x / (x^2 + y^2) and Y = y / (x^2 +y^2) inplace
Definition at line 397 of file Vector2D.h.
|
inline |
Returns a copy of the vector transformed in conformal space.
Applies the conformal map in the self-inverse from X = x / (x^2 + y^2) and Y = y / (x^2 +y^2) and returns the result as a new Vector2D
Definition at line 405 of file Vector2D.h.
|
inline |
Cosine of the angle between this and rhs
Definition at line 199 of file Vector2D.h.
|
inlinestatic |
Getter for the lowest possible vector.
The lowest possilbe vector according to the comparision is the null vector
Definition at line 149 of file Vector2D.h.
|
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 315 of file Vector2D.h.
|
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 325 of file Vector2D.h.
|
inline |
Total ordering based on cylindrical radius first and azimuth angle second.
Total order achiving a absolute lower bound Vector2D(0.0, 0.0). By first taking the cylindrical radius
for comparision the null vector is smaller than all other possible
vectors. Secondly the azimuth angle is considered to have a total ordering
for all vectors.
Definition at line 141 of file Vector2D.h.
|
inline |
Calculates the component orthogonal to the given vector.
The orthogonal component is the component parallel to relativeTo.orthogonal()
Definition at line 444 of file Vector2D.h.
Returns a transformed vector version rotated by the given vector.
The rotated coordinates are such that the given phiVec becomes the new x axes.
phiVec | Unit vector marking the x axes of the new rotated coordinate system |
Definition at line 601 of file Vector2D.h.
|
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 458 of file Vector2D.h.
|
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 437 of file Vector2D.h.