#include struct circle { double c; double s; }; void approx_turn_update(double turn, struct circle* ret) { static const double a = 8 * M_SQRT2 / 3 - 3; static const double b = 4 - 8 * M_SQRT2 / 3; double p = turn * (b * turn * turn + a); double q = p * p; double r = 1 + q; double c = (1 - q) / r, s = 2 * p / r; ret->c = c * c - s * s; ret->s = 2 * c * s; } void turn_update(double turn, struct circle* ret) { double arg = M_PI * turn; ret->c = cos(arg); ret->s = sin(arg); }