10#include <tracking/trackFindingCDC/numerics/Modulo.h>
12#include <tracking/trackFindingCDC/geometry/Line2D.h>
13#include <tracking/trackFindingCDC/geometry/Vector2D.h>
15#include <tracking/trackFindingCDC/numerics/EIncDec.h>
25 namespace TrackFindingCDC {
53 SinEqLine(
const double slope,
const double intercept) :
60 double map(
const double x)
const
69 {
return floor(x / M_PI); }
101 {
return lower.
x() < next.
x() and next.
x() < upper.
x(); }
106 return fabs(lower.
y()) < 10e-7 or fabs(upper.
y()) < 10e-7;
112 if (not std::isfinite(lower.
y()) or not std::isfinite(upper.
y())) {
116 if (fabs(lower.
y()) <= fabs(upper.
y())) {
120 if (fabs(lower.
y()) > fabs(upper.
y())) {
130 {
return (lower.
y() > 0 and upper.
y() < 0) or (lower.
y() < 0 and upper.
y() > 0); }
135 if (lower.
y() < upper.
y()) {
136 return EIncDec::c_Increasing;
137 }
else if (lower.
y() > upper.
y()) {
138 return EIncDec::c_Decreasing;
139 }
else if (lower.
y() == upper.
y()) {
140 return EIncDec::c_Constant;
142 return EIncDec::c_Invalid;
152 {
return isEven(iHalfPeriod) ? iHalfPeriod / 2 : (iHalfPeriod - 1) / 2; }
A two dimensional normal line.
Helper class to calculate roots for the function f(x) = sin x - slope * x - intercept.
static bool isBetween(const Vector2D &lower, const Vector2D &next, const Vector2D &upper)
Check is next position is within the interval given by lower and upper.
static EIncDec getEIncDec(const Vector2D &lower, const Vector2D &upper)
Determines if the function is increasing or decreasing in the interval.
double getIntercept() const
Getter for the intercept.
double computeExtremumXInHalfPeriod(int iHalfPeriod) const
Get the local extremum that is located in the half period indicated by the given index.
double m_intercept
Memory for the intercept.
static bool updateBounds(Vector2D &lower, Vector2D &upper, const Vector2D &next)
Replaces the lower or upper bound inplace if the next candidate position is valid and within the inte...
SinEqLine(const double slope, const double intercept)
Constructor taking the slope and intercept of the line that shall be superimposed with the sin curve.
bool hasLargeSlope() const
Indicates that the slope is so large such that the function has no local extrema.
double computeRootInInterval(double lowerX, double upperX) const
Computes the solution in between the given x values. The x values are generally chosen consecutive lo...
double getSlope() const
Getter for the slope.
double computeSmallestPositiveRoot(int maxIHalfPeriod=5) const
static double secantX(const Vector2D &lower, const Vector2D &upper)
Fall back shrinking method to the secant algorithm.
double computeRootForLargeSlope() const
Compute single solution in the case that fabs(slope) >= 1.
double newtonX(const Vector2D &pos) const
Shrinking method of the newton algorithm return the next candidate root.
double computeRootLargerThanExtemumInHalfPeriod(int iHalfPeriod) const
Computes the solution that is addressed by the given half period index.
double m_slope
Memory for the slope.
static bool isConverged(const Vector2D &lower, const Vector2D &upper)
Check if the interval has shrunk close enough to the solution.
SinEqLine()
Default constructor initializing slope and intercept to zero.
int getIHalfPeriod(const double x) const
Returns the half period index in which the x position is located.
static int getIPeriodFromIHalfPeriod(int iHalfPeriod)
Helper function to translate the index of the half period to index of the containing period.
double gradient(const double x) const
Interpreting as the function f this method calculates the gradient as need in Newtons algorithms.
static double middleX(const Vector2D &lower, const Vector2D &upper)
Simple fall back shrinking method using trivial division of the interval.
double map(const double x) const
Interpreting as the function f this method carries out the translation from x to y coordinates.
static double getConvergedBound(const Vector2D &lower, const Vector2D &upper)
Returns the better solution x from the bounds of the interval.
SinEqLine(const Line2D &line2D)
Constructor taking the line that shall be superimposed with the sin curve.
static bool changesSign(const Vector2D &lower, const Vector2D &upper)
Checks if the function changes sign in the interval.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
double x() const
Getter for the x coordinate.
double y() const
Getter for the y coordinate.
EIncDec
Enumeration to represent the distinct possibilities of the right left passage information.
Abstract base class for different kinds of events.