Belle II Software development
|
A two dimensional vector which is equipped with functions for correct handling
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 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. | |
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. | |
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. | |
double | normalizeTo (const double toLength) |
Normalizes the vector to the given length. | |
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. | |
Vector2D | conformalTransformed () const |
Returns a copy of the vector transformed in conformal space. | |
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. | |
double | orthogonalComp (const Vector2D &relativTo) const |
Calculates the component orthogonal to the given vector. | |
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. | |
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. | |
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 positive counterclockwise direction. So a positive 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) |
Constructs 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. | |
static Vector2D | average (const Vector2D &one, const Vector2D &two) |
Constructs the average of two vectors. | |
static Vector2D | average (const Vector2D &one, const Vector2D &two, const Vector2D &three) |
Constructs the average of three vectors. | |
static Vector2D | getLowest () |
Getter for the lowest possible vector. | |
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 handling
of orientation related issues in addition to the expected vector methods.
Definition at line 32 of file Vector2D.h.
|
inline |
Default constructor for ROOT compatibility.
Definition at line 36 of file Vector2D.h.
|
inline |
Constructor from two coordinates.
Definition at line 43 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 55 of file Vector2D.h.
std::string __str__ | ( | ) | const |
Output operator for python.
Definition at line 22 of file Vector2D.cc.
Adds a vector to this in place.
Definition at line 262 of file Vector2D.h.
|
inline |
The angle between this and rhs.
Definition at line 197 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 84 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 101 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 74 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 385 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 393 of file Vector2D.h.
|
inline |
Cosine of the angle between this and rhs
Definition at line 187 of file Vector2D.h.
|
inline |
Calculated the two dimensional cross product.
Definition at line 163 of file Vector2D.h.
|
inline |
Gives the cylindrical radius of the vector. Same as norm()
Definition at line 557 of file Vector2D.h.
Calculates the distance of this point to the rhs.
Definition at line 204 of file Vector2D.h.
|
inline |
Divides all coordinates by a common denominator in place.
Definition at line 237 of file Vector2D.h.
|
inline |
Returns a copy where all coordinates got divided by a common denominator.
Definition at line 251 of file Vector2D.h.
|
inline |
Calculates the two dimensional dot product.
Definition at line 158 of file Vector2D.h.
|
inline |
Getter for the first coordinate.
Definition at line 629 of file Vector2D.h.
|
inline |
Flips the first coordinate inplace (no difference between active and passive)
Definition at line 345 of file Vector2D.h.
Reflects this vector along line designated by the given vector.
Definition at line 377 of file Vector2D.h.
|
inline |
Makes a copy of the vector with the first coordinate flipped (no difference between active and passive)
Definition at line 358 of file Vector2D.h.
Reflects this vector over line designated by the given vector.
Definition at line 371 of file Vector2D.h.
|
inline |
Makes a copy of the vector with the second coordinate flipped (no difference between active and passive)
Definition at line 365 of file Vector2D.h.
|
inline |
Flips the first coordinate inplace (no difference between active and passive)
Definition at line 351 of file Vector2D.h.
|
inlinestatic |
Getter for the lowest possible vector.
The lowest possible vector according to the comparison is the null vector
Definition at line 137 of file Vector2D.h.
|
inline |
|
inline |
Indicates if the given vector is more Reverse if you looked in the direction of this vector.
Definition at line 507 of file Vector2D.h.
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.
Definition at line 525 of file Vector2D.h.
|
inline |
Indicates if the given vector is more counterclockwise if you looked in the direction of this vector.
Definition at line 479 of file Vector2D.h.
Indicates if the given vector is more counterclockwise or more clockwise if you looked in the direction of this vector.
Definition at line 472 of file Vector2D.h.
|
inline |
Indicates if the given vector is more clockwise if you looked in the direction of this vector.
Definition at line 486 of file Vector2D.h.
|
inline |
Indicates if the given vector is more coaligned if you looked in the direction of this vector.
Definition at line 500 of file Vector2D.h.
|
inline |
Indicates if the given vector is more coaligned or reverse if you looked in the direction of this vector.
Definition at line 493 of file Vector2D.h.
|
inline |
Indicates if the given vector is more left if you looked in the direction of this vector.
Definition at line 459 of file Vector2D.h.
|
inline |
Checks if the vector is the null vector.
Definition at line 143 of file Vector2D.h.
|
inline |
Indicates if the given vector is more right if you looked in the direction of this vector.
Definition at line 465 of file Vector2D.h.
|
inline |
Indicates if the given vector is more left or more right if you looked in the direction of this vector.
Definition at line 453 of file Vector2D.h.
|
inline |
Calculates the length of the vector.
Definition at line 175 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 303 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 313 of file Vector2D.h.
|
inline |
|
inline |
Returns a new vector as sum of this and rhs.
Definition at line 399 of file Vector2D.h.
Same as add()
Definition at line 270 of file Vector2D.h.
|
inline |
Same as reversed()
Definition at line 339 of file Vector2D.h.
Returns a new vector as differenc of this and rhs.
Definition at line 405 of file Vector2D.h.
Same as subtract()
Definition at line 283 of file Vector2D.h.
|
inline |
Same as divided()
Definition at line 256 of file Vector2D.h.
|
inline |
Same as divide()
Definition at line 245 of file Vector2D.h.
|
inline |
Total ordering based on cylindrical radius first and azimuth angle second.
Total order achieving a absolute lower bound Vector2D(0.0, 0.0). By first taking the cylindrical radius
for comparison 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 129 of file Vector2D.h.
|
inline |
Equality comparison with both coordinates.
Definition at line 117 of file Vector2D.h.
|
inline |
Orthogonal vector to the counterclockwise direction.
Definition at line 289 of file Vector2D.h.
Orthogonal vector to the direction given by the counterclockwise info.
Definition at line 295 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 432 of file Vector2D.h.
Calculates the part of this vector that is parallel to the given vector.
Definition at line 438 of file Vector2D.h.
|
inline |
Calculates the component parallel to the given vector.
Definition at line 411 of file Vector2D.h.
Calculates the part of this vector that is parallel to the given vector.
Definition at line 417 of file Vector2D.h.
|
inline |
Passivelly moves the vector inplace by the given vector.
Definition at line 575 of file Vector2D.h.
Returns a transformed vector passivelly moved by the given vector.
Definition at line 581 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 589 of file Vector2D.h.
|
inline |
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
Definition at line 569 of file Vector2D.h.
|
inlinestatic |
|
inline |
Reverses the direction of the vector in place.
Definition at line 327 of file Vector2D.h.
|
inline |
Returns a vector pointing in the opposite direction.
Definition at line 334 of file Vector2D.h.
|
inlinestaticprivate |
Check if three values have the same sign.
Definition at line 514 of file Vector2D.h.
|
inline |
Scales the vector in place by the given factor.
Definition at line 212 of file Vector2D.h.
|
inline |
Returns a scaled copy of the vector.
Definition at line 225 of file Vector2D.h.
|
inline |
Getter for the second coordinate.
Definition at line 639 of file Vector2D.h.
|
inline |
Setter for both coordinate.
Definition at line 650 of file Vector2D.h.
|
inline |
Setter for both coordinate by an other vector.
Definition at line 656 of file Vector2D.h.
|
inline |
Set the cylindrical radius while keeping the azimuth angle phi the same.
Definition at line 563 of file Vector2D.h.
|
inline |
Setter for the first coordinate.
Definition at line 634 of file Vector2D.h.
|
inline |
Setter for the second coordinate.
Definition at line 644 of file Vector2D.h.
|
inline |
|
inline |
|
inline |
Setter for both coordinate by an other vector.
Definition at line 622 of file Vector2D.h.
|
inline |
|
inline |
Sine of the angle between this and rhs.
Definition at line 192 of file Vector2D.h.
Subtracts a vector from this in place.
Definition at line 276 of file Vector2D.h.
|
inline |
Swaps the coordinates in place.
Definition at line 551 of file Vector2D.h.
|
inline |
|
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 446 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 425 of file Vector2D.h.
|
inline |
|
inline |
Same as scaled()
Definition at line 231 of file Vector2D.h.
|
private |
Memory for the first coordinate.
Definition at line 664 of file Vector2D.h.
|
private |
Memory for the second coordinate.
Definition at line 667 of file Vector2D.h.