 |
Belle II Software
release-05-02-19
|
12 #include <tracking/trackFindingCDC/numerics/Quadratic.h>
14 #include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
15 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
16 #include <tracking/trackFindingCDC/numerics/ERotation.h>
17 #include <tracking/trackFindingCDC/numerics/ESign.h>
31 namespace TrackFindingCDC {
48 explicit Vector2D(
const TVector2& tVector2);
63 Vector2D(
const Vector2D& coordinateVec,
const double parallelCoor,
const double orthoCoor)
64 :
m_x(coordinateVec.
x() * parallelCoor - coordinateVec.
y() * orthoCoor)
65 ,
m_y(coordinateVec.
y() * parallelCoor + coordinateVec.
x() * orthoCoor)
85 compose(
const Vector2D& coordinateVec,
const double parallelCoor,
const double orthoCoor)
87 return Vector2D(coordinateVec, parallelCoor, orthoCoor);
102 return Vector2D((one.
x() + two.
x()) / 2.0, (one.
y() + two.
y()) / 2.0);
117 }
else if (two.
hasNAN()) {
119 }
else if (three.
hasNAN()) {
122 return Vector2D((one.
x() + two.
x() + three.
x()) / 3.0,
123 (one.
y() + two.
y() + three.
y()) / 3.0);
128 operator const TVector2();
133 return x() == rhs.
x() and
y() == rhs.
y();
159 return x() == 0.0 and
y() == 0.0;
165 return std::isnan(
x()) or std::isnan(
y());
174 return x() * rhs.
x() +
y() * rhs.
y();
179 return x() * rhs.
y() -
y() * rhs.
x();
185 return x() *
x() +
y() *
y();
191 return hypot2(
x(),
y());
220 double deltaX =
x() - rhs.
x();
221 double deltaY =
y() - rhs.
y();
222 return hypot2(deltaX, deltaY);
235 return scale(factor);
247 return vec2D.
scaled(factor);
261 return divide(denominator);
267 return Vector2D(
x() / denominator,
y() / denominator);
319 double originalLength =
norm();
320 if (originalLength != 0.0)
divide(originalLength);
321 return originalLength;
329 double originalLength =
norm();
330 if (originalLength != 0.0)
scale(toLength / originalLength);
331 return originalLength;
427 return relativTo.
dot(*
this) / relativTo.
norm();
441 return relativTo.
dot(*
this);
448 return relativTo.
cross(*
this) / relativTo.
norm();
462 return relativTo.
cross(*
this);
495 return isCCWOrCWOf(rhs) == ERotation::c_CounterClockwise;
530 return ((n1 > 0 and n2 > 0 and n3 > 0) or (n1 < 0 and n2 < 0 and n3 < 0));
547 double det = lower.
cross(upper);
552 bool flipsOrientation = det < 0;
554 double transformedX =
cross(upper);
555 double transformedY = -
cross(lower);
556 bool inFirstQuadrant =
sameSign(det, transformedX, transformedY);
557 if (flipsOrientation) {
558 inFirstQuadrant = not inFirstQuadrant;
560 return inFirstQuadrant;
573 return hypot2(
x(),
y());
585 return isNull() ? NAN : atan2(
y(),
x());
bool isRightOf(const Vector2D &rhs) const
Indicates if the given vector is more right if you looked in the direction of this vector.
double sinWith(const Vector2D &rhs) const
Sine of the angle between this and rhs.
void conformalTransform()
Transforms the vector to conformal space inplace.
void setSecond(const double second)
Setter for the second coordinate.
Vector2D flippedOver(const Vector2D &reflectionLine) const
Reflects this vector over line designated by the given vector.
bool isBackwardOf(const Vector2D &rhs) const
Indicates if the given vector is more Reverse if you looked in the direction of this vector.
Vector2D orthogonal() const
Orthogonal vector to the counterclockwise direction.
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
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.
void setY(const double y)
Setter for the y coordinate.
Vector2D unit() const
Returns a unit vector colaligned with this.
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Vector2D flippedFirst() const
Makes a copy of the vector with the first coordinate flipped (no difference between active and passiv...
static Vector2D average(const Vector2D &one, const Vector2D &two, const Vector2D &three)
Constructs the average of three vectors.
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 vecto...
Vector2D & operator=(const TVector2 &tvector)
Assignment translating from a TVector2 instance.
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
double normalize()
Normalizes the vector to unit length.
void set(const Vector2D &both)
Setter for both coordinate by an other vector.
static Vector2D getLowest()
Getter for the lowest possible vector.
void setCylindricalR(const double cylindricalR)
Set the cylindrical radius while keeping the azimuth angle phi the same.
double normSquared() const
Calculates .
double y() const
Getter for the y coordinate.
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 ve...
void passiveMoveBy(const Vector2D &by)
Passivelly moves the vector inplace by the given vector.
double second() const
Getter for the second coordinate.
bool isNull() const
Checks if the vector is the null vector.
Vector2D & operator*=(const double factor)
Same as scale()
double parallelComp(const Vector2D &relativTo) const
Calculates the component parallel to the given vector.
Vector2D scaled(const double factor) const
Returns a scaled copy of the vector.
std::string __str__() const
Output operator for python.
Vector2D operator-() const
Same as reversed()
void flipSecond()
Flips the first coordinate inplace (no difference between active and passive)
Vector2D operator+(const Vector2D &rhs) const
Returns a new vector as sum of this and rhs.
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Vector2D & add(const Vector2D &rhs)
Adds a vector to this in place.
double distance(const Vector2D &rhs=Vector2D(0.0, 0.0)) const
Calculates the distance of this point to the rhs.
double m_y
Memory for the second coordinate.
double phi() const
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
bool isCWOf(const Vector2D &rhs) const
Indicates if the given vector is more clockwise if you looked in the direction of this vector.
void setXY(const double x, const double y)
Setter for both coordinate.
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
void setFirst(const double first)
Setter for the first coordinate.
Vector2D passiveMovedBy(const Vector2D &by) const
Returns a transformed vector passivelly moved by the given vector.
double first() const
Getter for the first coordinate.
Vector2D & operator+=(const Vector2D &rhs)
Same as add()
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
bool hasNAN() const
Checks if one of the coordinates is NAN.
friend Vector2D operator*(const Vector2D &vec2D, const double factor)
Same as scaled()
bool isLeftOf(const Vector2D &rhs) const
Indicates if the given vector is more left if you looked in the direction of this vector.
bool operator<(const Vector2D &rhs) const
Total ordering based on cylindrical radius first and azimuth angle second.
bool isCCWOf(const Vector2D &rhs) const
Indicates if the given vector is more counterclockwise if you looked in the direction of this vector.
Vector2D orthogonalVector(const Vector2D &relativTo) const
Calculates the part of this vector that is parallel to the given vector.
double orthogonalComp(const Vector2D &relativTo) const
Calculates the component orthogonal to the given vector.
static Vector2D Phi(const double phi)
Constucts a unit vector with azimuth angle equal to phi.
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 reversed() const
Returns a vector pointing in the opposite direction.
Abstract base class for different kinds of events.
Vector2D conformalTransformed() const
Returns a copy of the vector transformed in conformal space.
Vector2D(const double x, const double y)
Constructor from two coordinates.
Vector2D parallelVector(const Vector2D &relativTo) const
Calculates the part of this vector that is parallel to the given vector.
void swapCoordinates()
Swaps the coordinates in place.
double cylindricalR() const
Gives the cylindrical radius of the vector. Same as norm()
Vector2D & reverse()
Reverses the direction of the vector in place.
double m_x
Memory for the first coordinate.
double unnormalizedParallelComp(const Vector2D &relativTo) const
Same as parallelComp() but assumes the given vector to be of unit length.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
Vector2D & operator-=(const Vector2D &rhs)
Same as subtract()
double cosWith(const Vector2D &rhs) const
double x() const
Getter for the x coordinate.
Vector2D orthogonal(const ERotation ccwInfo) const
Orthogonal vector to the direction given by the counterclockwise info.
void setXY(const Vector2D &xy)
Setter for both coordinate by an other vector.
double norm() const
Calculates the length of the vector.
Vector2D operator/(const double denominator) const
Same as divided()
Vector2D flippedAlong(const Vector2D &flippingDirection) const
Reflects this vector along line designated by the given vector.
ERotation isCCWOrCWOf(const Vector2D &rhs) const
Indicates if the given vector is more counterclockwise or more clockwise if you looked in the directi...
EForwardBackward isForwardOrBackwardOf(const Vector2D &rhs) const
Indicates if the given vector is more coaligned or reverse if you looked in the direction of this vec...
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
void setX(const double x)
Setter for the x coordinate.
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.
Vector2D & subtract(const Vector2D &rhs)
Subtracts a vector from this in place.
Vector2D flippedSecond() const
Makes a copy of the vector with the second coordinate flipped (no difference between active and passi...
Vector2D()
Default constructor for ROOT compatibility.
double unnormalizedOrthogonalComp(const Vector2D &relativTo) const
Same as orthogonalComp() but assumes the given vector to be of unit length.
static bool sameSign(float n1, float n2, float n3)
Check if three values have the same sign.
void set(const double first, const double second)
Setter for both coordinate.
Vector2D & divide(const double denominator)
Divides all coordinates by a common denominator in place.
Vector2D operator-(const Vector2D &rhs) const
Returns a new vector as differenc of this and rhs.
Vector2D passiveRotatedBy(const Vector2D &phiVec) const
Returns a transformed vector version rotated by the given vector.
bool isForwardOf(const Vector2D &rhs) const
Indicates if the given vector is more coaligned if you looked in the direction of this vector.
Vector2D & scale(const double factor)
Scales the vector in place by the given factor.
void flipFirst()
Flips the first coordinate inplace (no difference between active and passive)
static Vector2D average(const Vector2D &one, const Vector2D &two)
Constructs the average of two vectors.
bool operator==(const Vector2D &rhs) const
Equality comparison with both coordinates.