15#include <boost/array.hpp>
16#include <boost/math/tools/rational.hpp>
30 auto normal_x = std::sin(
static_cast<float>(
tangent));
31 auto normal_y = -std::cos(
static_cast<float>(
tangent));
50 constexpr double pi_half = geom::Math::Pi<double>() / 2.0;
62 const double cos_a = std::cos(angle);
63 const double sin_a = std::sin(angle);
65 static_cast<float>(x * cos_a - y * sin_a),
66 static_cast<float>(y * cos_a + x * sin_a));
76 const double curve_dot = (curve_end - curve_start) / (
_length);
77 const double s_o = curve_start / curve_dot;
78 double s = s_o + dist;
88 odrSpiral(s_o, curve_dot, &x_o, &y_o, &t_o);
113 auto &val1 = result.second.first;
114 auto &val2 = result.second.second;
116 double rate = (val2.s - dist) / (val2.s - val1.s);
117 double u = rate * val1.u + (1.0 - rate) * val2.u;
118 double v = rate * val1.v + (1.0 - rate) * val2.v;
119 double tangent = atan((rate * val1.t + (1.0 - rate) * val2.t));
136 constexpr double interval_size = 0.3;
137 const double delta_u = interval_size;
138 double current_s = 0;
139 double current_u = 0;
144 while (current_s <
_length + delta_u) {
145 current_u += delta_u;
147 double du = current_u - last_u;
148 double dv = current_v - last_v;
149 double ds = sqrt(du * du + dv * dv);
152 RtreeValue current_val{current_u, current_v, current_s, current_t};
161 last_val = current_val;
170 auto &val1 = result.second.first;
171 auto &val2 = result.second.second;
172 double rate = (val2.s - dist) / (val2.s - val1.s);
173 double u = rate * val1.u + (1.0 - rate) * val2.u;
174 double v = rate * val1.v + (1.0 - rate) * val2.v;
175 double t_u = (rate * val1.t_u + (1.0 - rate) * val2.t_u);
176 double t_v = (rate * val1.t_v + (1.0 - rate) * val2.t_v);
177 double tangent = atan2(t_v, t_u);
193 constexpr double interval_size = 0.5;
194 size_t number_intervals =
195 std::max(
static_cast<size_t>(
_length / interval_size),
size_t(5));
196 double delta_p = 1.0 / number_intervals;
201 double current_s = 0;
211 for(
size_t i = 0; i < number_intervals; ++i) {
215 double du = current_u - last_u;
216 double dv = current_v - last_v;
217 double ds = sqrt(du * du + dv * dv);
235 last_val = current_val;
#define DEBUG_ASSERT(predicate)
value_type Evaluate(const value_type &x) const
Evaluates f(x) = a + bx + cx^2 + dx^3
value_type Tangent(const value_type &x) const
Evaluates the tangent using df/dx = b + 2cx + 3dx^2
static T Clamp(T a, T min=T(0), T max=T(1))
boost::geometry::model::point< float, Dimension, boost::geometry::cs::cartesian > BPoint
boost::geometry::model::segment< BPoint > BSegment
void InsertElement(const BSegment &segment, const T &element_start, const T &element_end)
std::vector< TreeElement > GetNearestNeighbours(const Geometry &geometry, size_t number_neighbours=1) const
DirectedPoint PosFromDist(double dist) const override
DirectedPoint PosFromDist(double dist) const override
DirectedPoint PosFromDist(double dist) const override
geom::CubicPolynomial _polyU
std::pair< float, float > DistanceTo(const geom::Location &) const override
geom::CubicPolynomial _polyV
geom::CubicPolynomial _poly
std::pair< float, float > DistanceTo(const geom::Location &) const override
DirectedPoint PosFromDist(double dist) const override
std::pair< float, float > DistanceTo(const geom::Location &) const override
DirectedPoint PosFromDist(double dist) const override
geom::Location _start_position
geom::Vector2D RotatebyAngle(double angle, double x, double y)
This file contains definitions of common data structures used in traffic manager.
void odrSpiral(double s, double cDot, double *x, double *y, double *t)
compute the actual "standard" spiral, starting with curvature 0
void ApplyLateralOffset(float lateral_offset)