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));
49 const double radius = 1.0 / _curvature;
50 constexpr
double pi_half = geom::Math::Pi<double>() / 2.0;
52 p.location.x +=
static_cast<float>(radius * std::cos(p.tangent + pi_half));
53 p.location.y +=
static_cast<float>(radius * std::sin(p.tangent + pi_half));
54 p.tangent += dist * _curvature;
55 p.location.x -=
static_cast<float>(radius * std::cos(p.tangent + pi_half));
56 p.location.y -=
static_cast<float>(radius * std::sin(p.tangent + pi_half));
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));
74 const double curve_end = (_curve_end);
75 const double curve_start = (_curve_start);
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);
106 return {location.
x - _start_position.x, location.
y - _start_position.y};
110 auto result = _rtree.GetNearestNeighbours(
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));
131 return {_start_position.x, _start_position.y};
136 constexpr
double interval_size = 0.3;
137 const double delta_u = interval_size;
138 double current_s = 0;
139 double current_u = 0;
141 double last_v = _poly.Evaluate(current_u);
143 RtreeValue last_val{last_u, last_v, last_s, _poly.Tangent(current_u)};
144 while (current_s < _length + delta_u) {
145 current_u += delta_u;
146 double current_v = _poly.Evaluate(current_u);
147 double du = current_u - last_u;
148 double dv = current_v - last_v;
149 double ds = sqrt(du * du + dv * dv);
151 double current_t = _poly.Tangent(current_u);
152 RtreeValue current_val{current_u, current_v, current_s, current_t};
161 last_val = current_val;
167 auto result = _rtree.GetNearestNeighbours(
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);
188 return {_start_position.x, _start_position.y};
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;
202 double last_u = _polyU.Evaluate(param_p);
203 double last_v = _polyV.Evaluate(param_p);
209 _polyU.Tangent(param_p),
210 _polyV.Tangent(param_p) };
211 for(
size_t i = 0; i < number_intervals; ++i) {
213 double current_u = _polyU.Evaluate(param_p);
214 double current_v = _polyV.Evaluate(param_p);
215 double du = current_u - last_u;
216 double dv = current_v - last_v;
217 double ds = sqrt(du * du + dv * dv);
219 double current_t_u = _polyU.Tangent(param_p);
220 double current_t_v = _polyV.Tangent(param_p);
235 last_val = current_val;
237 if(current_s > _length){
DirectedPoint PosFromDist(double dist) const override
geom::Vector2D RotatebyAngle(double angle, double x, double y)
static T Clamp(T a, T min=T(0), T max=T(1))
This file contains definitions of common data structures used in traffic manager. ...
DirectedPoint PosFromDist(double dist) const override
#define DEBUG_ASSERT(predicate)
boost::geometry::model::point< float, Dimension, boost::geometry::cs::cartesian > BPoint
DirectedPoint PosFromDist(double dist) const override
DirectedPoint PosFromDist(double dist) const override
std::pair< float, float > DistanceTo(const geom::Location &) const override
void odrSpiral(double s, double cDot, double *x, double *y, double *t)
compute the actual "standard" spiral, starting with curvature 0
DirectedPoint PosFromDist(double dist) const override
boost::geometry::model::segment< BPoint > BSegment
std::pair< float, float > DistanceTo(const geom::Location &) const override
void ApplyLateralOffset(float lateral_offset)
std::pair< float, float > DistanceTo(const geom::Location &) const override