101 {
102 if (size() < 2) {
103 return false;
104 }
105 if (!(front().s() < s + 1.0e-6 && s - 1.0e-6 < back().s())) {
106 return false;
107 }
108
109 auto comp = [](const common::SpeedPoint& sp, const double s) {
110 return sp.s() < s;
111 };
112
113 auto it_lower = std::lower_bound(begin(), end(), s, comp);
114 if (it_lower == end()) {
115 *speed_point = back();
116 } else if (it_lower == begin()) {
117 *speed_point = front();
118 } else {
119 const auto& p0 = *(it_lower - 1);
120 const auto& p1 = *it_lower;
121 double s0 = p0.s();
122 double s1 = p1.s();
123
124 speed_point->Clear();
125 speed_point->set_s(s);
127 if (p0.has_v() && p1.has_v()) {
129 }
130 if (p0.has_a() && p1.has_a()) {
132 }
133 if (p0.has_da() && p1.has_da()) {
135 }
136 }
137 return true;
138}
T lerp(const T &x0, const double t0, const T &x1, const double t1, const double t)
Linear interpolation between two points of type T.