scenario_simulator_v2 C++ API
Public Member Functions | Static Public Attributes | List of all members
math::geometry::PolynomialSolver Class Reference

#include <polynomial_solver.hpp>

Public Member Functions

auto solveLinearEquation (const double a, const double b, const double min_value=0, const double max_value=1) const -> std::vector< double >
 solve linear equation a*x + b = 0 More...
 
auto solveQuadraticEquation (const double a, const double b, const double c, const double min_value=0, const double max_value=1) const -> std::vector< double >
 solve quadratic equation a*x^2 + b*x + c = 0 More...
 
auto solveCubicEquation (const double a, const double b, const double c, const double d, const double min_value=0, const double max_value=1) const -> std::vector< double >
 solve cubic function a*t^3 + b*t^2 + c*t + d = 0 More...
 
auto linear (const double a, const double b, const double t) const -> double
 calculate result of linear function a*t + b More...
 
auto quadratic (const double a, const double b, const double c, const double t) const -> double
 calculate result of quadratic function a*t^2 + b*t + c More...
 
auto cubic (const double a, const double b, const double c, const double d, const double t) const -> double
 calculate result of cubic function a*t^3 + b*t^2 + c*t + d More...
 

Static Public Attributes

constexpr static double tolerance = 1e-7
 Hard coded parameter, tolerance of calculation results of the PolynomialSolver. This value was determined by Masaya Kataoka (@hakuturu583). The reason this value is not std::numeric_limits<double>::epsilon is that when using this set of functions to find the intersection of a Catmull-Rom spline curve and a line segment, it was confirmed that when the solution is very close to the endpoints of the Hermite curves that make up the Catmull-Rom spline, the solution could not calculated. When considering a 1 km long Catmull-Rom spline (assuming a very long lanelet) with a tolerance of 1e-7, the error in calculating the intersection position in a tangentially distorted coordinate system was ±0.0001 m. This value is sufficiently small that it was tentatively determined to be 1e-7. More...
 

Member Function Documentation

◆ cubic()

auto math::geometry::PolynomialSolver::cubic ( const double  a,
const double  b,
const double  c,
const double  d,
const double  t 
) const -> double

calculate result of cubic function a*t^3 + b*t^2 + c*t + d

Parameters
a
b
c
d
t
Returns
double result of cubic function

◆ linear()

auto math::geometry::PolynomialSolver::linear ( const double  a,
const double  b,
const double  t 
) const -> double

calculate result of linear function a*t + b

Parameters
a
b
t
Returns
double result of linear function

◆ quadratic()

auto math::geometry::PolynomialSolver::quadratic ( const double  a,
const double  b,
const double  c,
const double  t 
) const -> double

calculate result of quadratic function a*t^2 + b*t + c

Parameters
a
b
c
t
Returns
double result of quadratic function

◆ solveCubicEquation()

auto math::geometry::PolynomialSolver::solveCubicEquation ( const double  a,
const double  b,
const double  c,
const double  d,
const double  min_value = 0,
const double  max_value = 1 
) const -> std::vector<double>

solve cubic function a*t^3 + b*t^2 + c*t + d = 0

Parameters
a
b
c
d
Returns
std::vector<double> real solution of the cubic functions (from min_value to max_value)
Note
Function that takes a std::vector of complex numbers and selects only real numbers from it and returns them
Function that takes a complex number as input and returns the real part if it is a real number (imaginary part is 0) or std::nullopt if it is an imaginary or complex number.
Iterate all complex values and check the value is real value or not.
Finds the complex solution of the monic cubic equation and returns only those that are real numbers.
Fallback to quadratic equation solver if a = 0

◆ solveLinearEquation()

auto math::geometry::PolynomialSolver::solveLinearEquation ( const double  a,
const double  b,
const double  min_value = 0,
const double  max_value = 1 
) const -> std::vector<double>

solve linear equation a*x + b = 0

Parameters
a
b
Returns
std::vector<double> real solution of the quadratic functions (from min_value to max_value)
Note
In this case, ax*b = 0 (a=0) can cause division by zero. So give special treatment to this case.
In this case, ax*b = 0 (a=0,b!=0) so any x cannot satisfy this equation.
In this case, ax*b = 0 (a!=0, b!=0) so x = -b/a is a only solution.
No fallback because of the order cannot be lowered any further.

◆ solveQuadraticEquation()

auto math::geometry::PolynomialSolver::solveQuadraticEquation ( const double  a,
const double  b,
const double  c,
const double  min_value = 0,
const double  max_value = 1 
) const -> std::vector<double>

solve quadratic equation a*x^2 + b*x + c = 0

Parameters
a
b
Returns
std::vector<double> real solution of the quadratic functions (from min_value to max_value)
Note
Fallback to linear equation solver if a = 0

Member Data Documentation

◆ tolerance

constexpr static double math::geometry::PolynomialSolver::tolerance = 1e-7
staticconstexpr

Hard coded parameter, tolerance of calculation results of the PolynomialSolver. This value was determined by Masaya Kataoka (@hakuturu583). The reason this value is not std::numeric_limits<double>::epsilon is that when using this set of functions to find the intersection of a Catmull-Rom spline curve and a line segment, it was confirmed that when the solution is very close to the endpoints of the Hermite curves that make up the Catmull-Rom spline, the solution could not calculated. When considering a 1 km long Catmull-Rom spline (assuming a very long lanelet) with a tolerance of 1e-7, the error in calculating the intersection position in a tangentially distorted coordinate system was ±0.0001 m. This value is sufficiently small that it was tentatively determined to be 1e-7.


The documentation for this class was generated from the following files: