97 auto xrp = std::ranges::upper_bound(coords, t, {}, &T::t);
99 if (xrp == coords.begin())
103 else if (xrp == coords.end())
109 using index_type =
typename std::vector<T>::size_type;
110 const auto right_index =
static_cast<index_type
>(xrp - coords.begin());
111 const auto left_index = right_index - 1;
113 const RealType iw = coords[right_index].t - coords[left_index].t;
114 const RealType rw = (coords[right_index].t - t) / iw;
117 coord = coords[right_index] * lw + coords[left_index] * rw;
141 auto xrp = std::ranges::upper_bound(coords, t, {}, &T::t);
143 if (xrp == coords.begin())
147 else if (xrp == coords.end())
153 using index_type =
typename std::vector<T>::size_type;
154 const auto right_index =
static_cast<index_type
>(xrp - coords.begin());
155 const auto left_index = right_index - 1;
157 const RealType xrd = coords[right_index].t - t;
158 const RealType xld = t - coords[left_index].t;
159 const RealType iw = coords[right_index].t - coords[left_index].t;
163 const RealType c = (a * a * a - a) * iws;
164 const RealType d = (b * b * b - b) * iws;
166 coord = coords[left_index] * a + coords[right_index] * b + dd[left_index] * c + dd[right_index] * d;
182 using index_type =
typename std::vector<T>::size_type;
183 const index_type size = coords.size();
189 std::vector<T> tmp(size);
195 for (index_type i = 1; i + 1 < size; ++i)
197 const index_type next_index = i + 1;
198 const index_type prev_index = i - 1;
200 const T yrd = coords[next_index] - coords[i];
201 const T yld = coords[i] - coords[prev_index];
202 const RealType xrd = coords[next_index].t - coords[i].t;
203 const RealType xld = coords[i].t - coords[prev_index].t;
204 const RealType iw = coords[next_index].t - coords[prev_index].t;
213 const T yrd_xrd = (xrd <=
EPSILON) ? (yrd * 0.0) : (yrd / xrd);
214 const T yld_xld = (xld <=
EPSILON) ? (yld * 0.0) : (yld / xld);
217 const T p = dd[prev_index] * si + 2.0;
218 dd[i] = (si - 1.0) / p;
219 tmp[i] = ((yrd_xrd - yld_xld) * 6.0 / iw - tmp[prev_index] * si) / p;
222 for (index_type i = size - 1; i-- > 0;)
224 dd[i] = dd[i] * dd[i + 1] + tmp[i];
void getPositionLinear(RealType t, T &coord, const std::vector< T > &coords)
Performs linear interpolation between coordinate points.
void getPositionCubic(RealType t, T &coord, const std::vector< T > &coords, const std::vector< T > &dd)
Performs cubic spline interpolation between coordinate points.