10#include <tracking/trackFindingCDC/geometry/Vector2D.h>
12#include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
13#include <tracking/trackFindingCDC/numerics/ERightLeft.h>
14#include <tracking/trackFindingCDC/numerics/ESign.h>
23 namespace TrackFindingCDC {
88 return Line2D(
intercept *
static_cast<double>(orientation),
slope *
static_cast<double>(orientation), -orientation);
94 return Line2D(end.cross(start), (start - end).orthogonal());
192 setN1(
slope *
static_cast<double>(orientation));
253 double distance(
const double first,
const double second)
const
255 return n0() + first *
n1() + second *
n2();
294 const double closestParallel = -
n0();
296 return Vector2D(
n12(), closestParallel, closestOrthgonal);
302 return n12() * (-
n0());
481 double map(
const double first)
const
483 return -(
n0() +
n1() * first) /
n2();
494 return -(
n0() +
n2() * second) /
n1();
A two dimensional normal line.
Line2D passiveMovedAlongFirst(const double first) const
Return a copy of the line passively moved long the first coordinate.
void flipSecond()
Flips the first coordinate inplace (no difference between active and passive)
Line2D movedAlongFirst(const double first) const
Return a copy of the line actively moved long the first coordinate.
Vector2D tangential() const
Gives the tangential vector in the direction of positive advance on the line.
Line2D()
Default constructor for ROOT compatibility.
double n1() const
Getter for the second line parameter.
EForwardBackward alignedWithFirst() const
Returns if the direction of positive advance has a common component aligned or anti aligned with the ...
Line2D(const double n0, const Vector2D &n12)
Constructs taking the distance to the origin ( n0 ) and the normal vector.
Line2D flippedSecond() const
Makes a copy of the line with the second coordinate flipped (no difference between active and passive...
double absoluteDistance(const Vector2D &point) const
Returns the absolute value of distance(point)
double normalization() const
Calculates the normalization. Helper for normalize.
double zero() const
Returns the root of the line.
bool isInvalid() const
Indicates if all circle parameters are zero.
void reverse()
Flips orientation the line in place.
Line2D inverted() const
Returns the inverse function line as a copy.
void setN0(const double n0)
Setter for first line parameter This sets the signed distance of the line to the origin.
double slope() const
Returns the slope over the first coordinate.
void setSlopeIntercept(const double slope, const double intercept)
Sets the new intercept and slope of the line the direction is set to be forward with the increasing x...
const Vector2D & n12() const
Getter for the unit normal vector to the line.
double map(const double first) const
Maps the first coordinate to the second.
double distance(const Vector2D &point) const
Calculates the signed distance of the point to the line.
void setN2(const double n2)
Setter for the third line parameter. May violate the normalization.
void flipFirst()
Flips the first coordinate inplace (no difference between active and passive)
Vector2D closestToOrigin() const
Returns the point closest to the origin.
void setN1(const double n1)
Setter for the second line parameter. May violate the normalization.
double m_n0
Memory for the first line parameter.
double distanceToOrigin() const
Returns the distance to the origin The distance to the origin is equivalent to the first line paramet...
void passiveMoveBy(const Vector2D &by)
Passively move the coordinate system in place by the given vector.
double intercept() const
Returns the intercept over the first coordinate.
Vector2D support() const
Getter for the support point of the line being the point closest to the origin.
bool isLeft(const Vector2D &rhs) const
Return if the point given is left of the line.
bool isRight(const Vector2D &rhs) const
Return if the point given is right of the line.
static Line2D throughPoints(const Vector2D &start, const Vector2D &end)
Constructs a line through the two given points.
void moveAlongFirst(const double first)
Actively moves the line in the direction given in place along the first coordinate.
void setN12(const double n1, const double n2)
Setter for the normal vector by its coordinates.
double inverseSlope() const
Returns the slope over the second coordinate.
double normalizationSquared() const
Calculates the squared normalization. Helper for normalize.
double inverseMap(const double second) const
Maps the second coordinate to the first.
double operator()(const double first) const
Maps the first coordinate to the second.
const Vector2D & gradient() const
Getter for the gradient of the distance field.
void invert()
Turns the line function into its inverse function in place.
static Line2D fromSlopeIntercept(const double slope, const double intercept, const EForwardBackward orientation)
Constructs a line from its slope and intercept over the first coordinate with the given orientation.
void passiveMoveAlongFirst(const double first)
Passively move the coordinate system in place along the first coordinate.
void invalidate()
Sets all line parameters to zero.
EForwardBackward alignedWithSecond() const
Returns if the direction of positive advance has a common component aligned or anti aligned with the ...
Vector2D intersection(const Line2D &line) const
Calculates the intersection point of two line. Infinity for parallels.
Line2D flippedFirst() const
Makes a copy of the line with the first coordinate flipped (no difference between active and passive)
void scaleN(const double factor)
Scales all parameters. Helper for normalize.
void moveBy(const Vector2D &by)
Actively moves the line in the direction given in place by the vector given.
Line2D reversed() const
Returns a copy of the line with the reversed orientation.
double n2() const
Getter for the third line parameter.
ERightLeft isRightOrLeft(const Vector2D &point) const
Return if the point given is right or left of the line.
const Vector2D & normal() const
Getter for the unit normal vector of the line.
void setN12(const Vector2D &n12)
Setter for the normal vector.
Line2D movedAlongSecond(const double second) const
Return a copy of the line actively moved long the first coordinate.
double distance(const double first, const double second) const
Calculates the signed distance of the point given by its to coordinates to the line.
void setSlopeIntercept(const double slope, const double intercept, const EForwardBackward orientation)
Sets the new intercept and slope of the line the direction is set to be forward with the increasing x...
Vector2D closest(const Vector2D &point) const
Calculates the point of closest approach on the line to the point.
void setN(const double n0, const double n1, const double n2)
Setter the for the line parameters which takes care of the correct normalization of the normal vector...
void normalize()
Updates the parameters to obey the normalization condition.
Line2D(const double n0, const double n1, const double n2)
Constructs taking all three line parameters.
Vector2D m_n12
Memory for the second line parameter.
void passiveMoveAlongSecond(const double second)
Passively move the coordinate system in place along the second coordinate.
double n0() const
Getter for the first line parameter.
static Line2D fromSlopeIntercept(const double slope, const double intercept)
Constructs a line from its slope and intercept over the first coordinate (default forward orientation...
double lengthOnCurve(const Vector2D &from, const Vector2D &to) const
Calculates the length on the curve between two points.
void moveAlongSecond(const double second)
Actively moves the line in the direction given in place along the second coordinate.
Line2D passiveMovedAlongSecond(const double second) const
Return a copy of the line passively moved long the first coordinate.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
void setSecond(const double second)
Setter for the second coordinate.
void swapCoordinates()
Swaps the coordinates in place.
void flipSecond()
Flips the first coordinate inplace (no difference between active and passive)
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
void set(const double first, const double second)
Setter for both coordinate.
double unnormalizedParallelComp(const Vector2D &relativTo) const
Same as parallelComp() but assumes the given vector to be of unit length.
void flipFirst()
Flips the first coordinate inplace (no difference between active and passive)
double second() const
Getter for the second coordinate.
double normSquared() const
Calculates .
bool isNull() const
Checks if the vector is the null vector.
Vector2D orthogonal() const
Orthogonal vector to the counterclockwise direction.
double first() const
Getter for the first coordinate.
void setFirst(const double first)
Setter for the first coordinate.
double unnormalizedOrthogonalComp(const Vector2D &relativTo) const
Same as orthogonalComp() but assumes the given vector to be of unit length.
double sqrt(double a)
sqrt for double
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Abstract base class for different kinds of events.