33 s(
double t,
double s0,
double v0,
double a0,
double j)
35 return s0 + v0 * t + 0.5 * a0 * t * t + 1.0 / 6.0 * j * t * t * t;
39 v(
double t,
double v0,
double a0,
double j)
41 return v0 + a0 * t + 0.5 * j * t * t;
45 a(
double t,
double a0,
double j)
67 return 2 *
t_to_v(
v / 2.0, a0, j);
79 auto t =
t_to_v(v0, -signV * a0, signV * j);
80 return s(t, 0, v0, a0, -signV * j);
96 double dt1 =
std::abs((dec_max - a0) / (-j * d));
99 double v1 =
v(dt1, v0, a0, -d * j);
100 double acc_duration =
std::abs(dec_max) / j;
102 v(acc_duration, 0, 0, d * j);
105 double dt2 = d * ((v1 - v2) / dec_max);
109 double s1 =
s(dt1, 0, v0, a0, d * j);
110 double s2 =
s(dt2, 0, v1, dec_max, 0);
111 double s3 =
s(dt3, 0, v2, dec_max, d * j);
112 double v3 =
v(dt3, v2, dec_max, d * j);
113 double s_total = s1 + s2 + s3;
118 double delta_a =
a(excess_time / 2, 0, d * j);
119 a_max -= d * delta_a;
125 return {s_total * d, v1, v2, v3, dt1, dt2, dt3};
137 return j * v0 - a0 * a0 / 2 > 0.0f;
141 jerk(
double t,
double s0,
double v0,
double a0)
143 return (6 * s0 - 3 * t * (a0 * t + 2 * v0)) / (t * t * t);
146 std::tuple<double, double, double>
150 double t = -(3 * s0) / v0;
151 double a0 = -(2 * v0) / t;
152 double j = 2 * v0 / (t * t);
153 return std::make_tuple(t, a0, j);
172 double part = j * v0 - a0 * a0 / 2.0;
179 throw std::runtime_error(
"unsuitable parameters! : j: " +
std::to_string(j) +
183 double t2 = (a0 / j) + t1;
184 double v1 =
v(t1, v0, a0, -j);
187 double a1 =
a(t1, -a0, -j);
189 double v2 =
v(t2, v1, a1, j);
192 double a2 =
a(t2, a1, j);
195 double s1 =
s(t1, 0, v0, a0, -j);
196 double s2 =
s(t2, 0, v1, a1, j);
197 double s_total = s1 + s2;
198 return {s_total, s1, s2, d * v1, d * v2, d * a1, d * a2, t1 + t2, t1, t2};