![]() |
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 ROOT::Math::XYVector &xyVector) | |
| Constructor translating from a ROOT::Math::XYVector instance. | |
| Vector2D (const double x, const double y) | |
| Constructor from two coordinates. | |
| Vector2D & | operator= (const ROOT::Math::XYVector &xyVector) |
| Assignment translating from a ROOT::Math::XYVector instance. | |
| operator const ROOT::Math::XYVector () const | |
| Casting the back to ROOT::Math::XYVector seamlessly. | |
| 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. | |
| Vector2D | operator- (const ROOT::Math::XYVector &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. | |
| 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. | |
| 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 34 of file Vector2D.h.
|
inline |
Default constructor for ROOT compatibility.
Definition at line 38 of file Vector2D.h.
| Vector2D | ( | const ROOT::Math::XYVector & | xyVector | ) |
Constructor translating from a ROOT::Math::XYVector instance.
Definition at line 16 of file Vector2D.cc.
|
inline |
Constructor from two coordinates.
Definition at line 55 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 73 of file Vector2D.h.
| std::string __str__ | ( | ) | const |
Output operator for python.
Definition at line 39 of file Vector2D.cc.
Adds a vector to this in place.
Definition at line 280 of file Vector2D.h.
|
inline |
The angle between this and rhs.
Definition at line 215 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 102 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 119 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 92 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 403 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 411 of file Vector2D.h.
|
inline |
Cosine of the angle between this and rhs
Definition at line 205 of file Vector2D.h.
|
inline |
Calculated the two dimensional cross product.
Definition at line 181 of file Vector2D.h.
|
inline |
Gives the cylindrical radius of the vector. Same as norm()
Definition at line 584 of file Vector2D.h.
Calculates the distance of this point to the rhs.
Definition at line 222 of file Vector2D.h.
|
inline |
Divides all coordinates by a common denominator in place.
Definition at line 255 of file Vector2D.h.
|
inline |
Returns a copy where all coordinates got divided by a common denominator.
Definition at line 269 of file Vector2D.h.
|
inline |
Calculates the two dimensional dot product.
Definition at line 176 of file Vector2D.h.
|
inline |
Getter for the first coordinate.
Definition at line 666 of file Vector2D.h.
|
inline |
Flips the first coordinate inplace (no difference between active and passive)
Definition at line 363 of file Vector2D.h.
Reflects this vector along line designated by the given vector.
Definition at line 395 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 376 of file Vector2D.h.
Reflects this vector over line designated by the given vector.
Definition at line 389 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 383 of file Vector2D.h.
|
inline |
Flips the first coordinate inplace (no difference between active and passive)
Definition at line 369 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 155 of file Vector2D.h.
|
inline |
Checks if one of the coordinates is NAN.
Definition at line 167 of file Vector2D.h.
|
inline |
Indicates if the given vector is more Reverse if you looked in the direction of this vector.
Definition at line 534 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 552 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 506 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 499 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 513 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 527 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 520 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 486 of file Vector2D.h.
|
inline |
Checks if the vector is the null vector.
Definition at line 161 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 492 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 480 of file Vector2D.h.
|
inline |
Calculates the length of the vector.
Definition at line 193 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 321 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 331 of file Vector2D.h.
|
inline |
Calculates 
Definition at line 187 of file Vector2D.h.
| operator const ROOT::Math::XYVector | ( | ) | const |
Casting the back to ROOT::Math::XYVector seamlessly.
Definition at line 28 of file Vector2D.cc.
|
inline |
Returns a new vector as sum of this and rhs.
Definition at line 417 of file Vector2D.h.
|
inline |
Same as reversed()
Definition at line 357 of file Vector2D.h.
|
inline |
Returns a new vector as differenc of this and rhs.
Definition at line 429 of file Vector2D.h.
Returns a new vector as differenc of this and rhs.
Definition at line 423 of file Vector2D.h.
|
inline |
Same as divided()
Definition at line 274 of file Vector2D.h.
|
inline |
Same as divide()
Definition at line 263 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 147 of file Vector2D.h.
| Vector2D & operator= | ( | const ROOT::Math::XYVector & | xyVector | ) |
Assignment translating from a ROOT::Math::XYVector instance.
Definition at line 21 of file Vector2D.cc.
|
inline |
Equality comparison with both coordinates.
Definition at line 135 of file Vector2D.h.
|
inline |
Orthogonal vector to the counterclockwise direction.
Definition at line 307 of file Vector2D.h.
Orthogonal vector to the direction given by the counterclockwise info.
Definition at line 313 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 459 of file Vector2D.h.
Calculates the part of this vector that is parallel to the given vector.
Definition at line 465 of file Vector2D.h.
|
inline |
Calculates the component parallel to the given vector.
Definition at line 435 of file Vector2D.h.
Calculates the part of this vector that is parallel to the given vector.
Definition at line 444 of file Vector2D.h.
|
inline |
Passivelly moves the vector inplace by the given vector.
Definition at line 602 of file Vector2D.h.
Returns a transformed vector passivelly moved by the given vector.
Definition at line 608 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 616 of file Vector2D.h.
|
inlinestatic |
Constructs a unit vector with azimuth angle equal to phi.
Definition at line 80 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 596 of file Vector2D.h.
|
inline |
Reverses the direction of the vector in place.
Definition at line 345 of file Vector2D.h.
|
inline |
Returns a vector pointing in the opposite direction.
Definition at line 352 of file Vector2D.h.
|
inlinestaticprivate |
Check if three values have the same sign.
Definition at line 541 of file Vector2D.h.
|
inline |
Scales the vector in place by the given factor.
Definition at line 230 of file Vector2D.h.
|
inline |
Returns a scaled copy of the vector.
Definition at line 243 of file Vector2D.h.
|
inline |
Getter for the second coordinate.
Definition at line 676 of file Vector2D.h.
|
inline |
Setter for both coordinate.
Definition at line 687 of file Vector2D.h.
|
inline |
Setter for both coordinate by an other vector.
Definition at line 693 of file Vector2D.h.
|
inline |
Set the cylindrical radius while keeping the azimuth angle phi the same.
Definition at line 590 of file Vector2D.h.
|
inline |
Setter for the first coordinate.
Definition at line 671 of file Vector2D.h.
|
inline |
Setter for the second coordinate.
Definition at line 681 of file Vector2D.h.
|
inline |
|
inline |
Setter for both coordinate.
Definition at line 653 of file Vector2D.h.
|
inline |
Setter for both coordinate by an other vector.
Definition at line 659 of file Vector2D.h.
|
inline |
|
inline |
Sine of the angle between this and rhs.
Definition at line 210 of file Vector2D.h.
Subtracts a vector from this in place.
Definition at line 294 of file Vector2D.h.
|
inline |
Swaps the coordinates in place.
Definition at line 578 of file Vector2D.h.
|
inline |
Returns a unit vector colaligned with this.
Definition at line 339 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 473 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 452 of file Vector2D.h.
|
inline |
|
inline |
|
inline |
|
inline |
Same as scaled()
Definition at line 249 of file Vector2D.h.
|
private |
Memory for the first coordinate.
Definition at line 701 of file Vector2D.h.
|
private |
Memory for the second coordinate.
Definition at line 704 of file Vector2D.h.