6 constexpr
const double JUMP_SPEED = 268.3281572999748;
11 inline double dot_product(
const double *__restrict a,
const double *__restrict b)
14 for (
int i = 0; i < N; ++i) {
32 return speed * (1 - tau_k);
35 const double tau_E_k = tau_k * E;
36 if (speed >= tau_E_k && speed >= 0.1) {
37 return speed - tau_E_k;
50 void fric_vel(
double *__restrict vel,
double speed,
double E,
double tau_k)
53 const double tmp = 1 - tau_k;
59 const double tau_E_k = tau_k * E;
60 if (speed >= tau_E_k && speed >= 0.1) {
61 const double tmp = tau_E_k / speed;
62 vel[0] -= vel[0] * tmp;
63 vel[1] -= vel[1] * tmp;
82 if (speedsq >= E * E) {
83 const double tmp = 1 - tau_k;
84 return speedsq * tmp * tmp;
87 const double tau_E_k = tau_k * E;
88 const double tau_E_k_sq = tau_E_k * tau_E_k;
89 if (speedsq >= tau_E_k_sq && speedsq >= 0.01) {
90 return speedsq - 2 * std::sqrt(speedsq) * tau_E_k + tau_E_k_sq;
99 double fme_speed(
double speed,
double costheta,
double L,
double ke_tau_M_A)
101 const double gamma2 = L - speed * costheta;
106 double mu = ke_tau_M_A;
111 return std::sqrt(speed * (speed + 2 * mu * costheta) + mu * mu);
124 void fme_vel_theta(
double *__restrict vel,
double speed,
double costheta,
double sintheta,
double L,
double ke_tau_M_A)
126 const double gamma2 = L - speed * costheta;
131 const double mu = std::min(ke_tau_M_A, gamma2);
132 const double tmp = mu / speed;
133 const double ax = vel[0] * costheta + vel[1] * sintheta;
134 const double ay = vel[1] * costheta - vel[0] * sintheta;
145 if (ke_tau_M_A >= 0) {
146 if (L <= ke_tau_M_A) {
157 const double tmp = L - ke_tau_M_A;
159 const double ct = tmp / speed;
161 *sintheta = std::sqrt(1 - ct * ct);
186 if (ke_tau_M_A >= 0) {
187 if (L <= ke_tau_M_A) {
189 return std::sqrt(speed * speed + L * L);
194 const double tmp = L - ke_tau_M_A;
196 return std::sqrt(speed * speed + ke_tau_M_A * (L + tmp));
198 return speed + ke_tau_M_A;
202 return speed - ke_tau_M_A;
233 if (ke_tau_M_A >= 0) {
234 if (L <= ke_tau_M_A) {
241 const double tmp = L - ke_tau_M_A;
242 if (tmp * tmp <= speedsq) {
243 return ke_tau_M_A * (L + tmp);
245 return (2 * std::sqrt(speedsq) + ke_tau_M_A) * ke_tau_M_A;
248 if (L >= 0 || L * L < speedsq) {
249 return (ke_tau_M_A - 2 * std::sqrt(speedsq)) * ke_tau_M_A;
258 if (ke_tau_M_A >= 0) {
260 if (L >= ke_tau_M_A) {
261 return std::fabs(speed - ke_tau_M_A);
264 const double tmp = L - ke_tau_M_A;
265 if (L <= speed || -tmp <= speed) {
266 return std::fabs(speed - ke_tau_M_A);
272 if (ke_tau_M_A - L <= speed) {
273 return std::fabs(speed - ke_tau_M_A);
287 void collision_vel(
double *__restrict v,
const double *__restrict n,
double b)
289 const double tmp = b * dot_product<N>(v, n);
290 for (
int i = 0; i < N; ++i) {
301 const double speed = std::sqrt(dot_product<N>(v, v));
303 if (speed > 95. / 3) {
304 tmp = 50 / (speed + 10);
306 for (
int i = 0; i < N; ++i) {
307 v[i] = tmp * v[i] + 300 * dir[i];
315 return 0.001 * std::floor(1000 * tau_g);
321 void water_vel(
double *__restrict v,
double speed,
const double *__restrict a,
double geomfric,
double M,
double ke_tau_M_A)
323 const double m = 0.8 * M;
324 const double gamma2 = m - geomfric * speed;
325 if (gamma2 <= 0 || m < 0.1) {
329 const double mu = std::min(0.8 * ke_tau_M_A, gamma2);
330 for (
int i = 0; i < 3; ++i) {
331 v[i] = geomfric * v[i] + mu * a[i];
void fric_vel(double *__restrict vel, double speed, double E, double tau_k)
Definition: strafelib.hpp:50
double fme_maxaccel_speed_C(double speedsq, double L, double ke_tau_M_A)
Definition: strafelib.hpp:231
double fme_minaccel_speed(double speed, double L, double ke_tau_M_A)
Definition: strafelib.hpp:256
void snark_hunt_vel(double *__restrict v, const double *__restrict dir)
Definition: strafelib.hpp:299
void collision_vel(double *__restrict v, const double *__restrict n, double b)
Definition: strafelib.hpp:287
double dot_product(const double *__restrict a, const double *__restrict b)
Definition: strafelib.hpp:11
double fme_speed(double speed, double costheta, double L, double ke_tau_M_A)
Definition: strafelib.hpp:99
double fme_maxaccel_speed(double speed, double L, double ke_tau_M_A)
Definition: strafelib.hpp:184
void water_vel(double *__restrict v, double speed, const double *__restrict a, double geomfric, double M, double ke_tau_M_A)
Definition: strafelib.hpp:321
constexpr const double JUMP_SPEED
The initial jumping speed, before gravity is applied.
Definition: strafelib.hpp:6
void fme_maxaccel_cossin_theta(double speed, double L, double ke_tau_M_A, double *__restrict costheta, double *__restrict sintheta)
Definition: strafelib.hpp:143
void fme_vel_theta(double *__restrict vel, double speed, double costheta, double sintheta, double L, double ke_tau_M_A)
Definition: strafelib.hpp:124
double fric_speedsq(double speedsq, double E, double tau_k)
Definition: strafelib.hpp:80
double tau_g_to_p(double tau_g)
Definition: strafelib.hpp:313
double fric_speed(double speed, double E, double tau_k)
Definition: strafelib.hpp:29