10#define TwoPi 6.28318530717958648
30 r -= 1. / 3. * (r - x / (r * r));
31 r -= 1. / 3. * (r - x / (r * r));
32 r -= 1. / 3. * (r - x / (r * r));
33 r -= 1. / 3. * (r - x / (r * r));
34 r -= 1. / 3. * (r - x / (r * r));
35 r -= 1. / 3. * (r - x / (r * r));
77 btScalar r = (a * (2 * a2 - 9 * b) + 27 * c) / 54;
92 x[0] = q * cos(t / 3) - a;
93 x[1] = q * cos((t +
TwoPi) / 3) - a;
94 x[2] = q * cos((t -
TwoPi) / 3) - a;
100 A = -
root3(fabs(r) + sqrt(r2 - q3));
103 B = (A == 0 ? 0 : q / A);
107 x[1] = -0.5 * (A + B) - a;
108 x[2] = 0.5 * sqrt(3.) * (A - B);
109 if (fabs(x[2]) <
eps)
138 a = sqrt(0.5 * (x + r));
183 CSqrt(-0.5 * b, sD2, x[0], x[1]);
184 CSqrt(-0.5 * b, -sD2, x[2], x[3]);
211 if (fabs(c) < 1e-14 * (fabs(b) + fabs(d)))
214 int res3 =
SolveP3(x, 2 * b, b * b - 4 * d, -c * c);
228 x[0] = (-sz1 - sz2 - sz3) / 2;
229 x[1] = (-sz1 + sz2 + sz3) / 2;
230 x[2] = (+sz1 - sz2 + sz3) / 2;
231 x[3] = (+sz1 + sz2 - sz3) / 2;
235 x[0] = (-sz1 - sz2 + sz3) / 2;
236 x[1] = (-sz1 + sz2 - sz3) / 2;
237 x[2] = (+sz1 - sz2 - sz3) / 2;
238 x[3] = (+sz1 + sz2 + sz3) / 2;
250 x[1] = (sz1 - sz2) / 2;
252 x[3] = (-sz1 - sz2) / 2;
257 x[1] = (-sz1 + sz2) / 2;
259 x[3] = (sz1 + sz2) / 2;
270 CSqrt(x[1], x[2], szr, szi);
273 x[0] = -sz1 / 2 - szr;
274 x[1] = -sz1 / 2 + szr;
280 x[0] = sz1 / 2 - szr;
281 x[1] = sz1 / 2 + szr;
289 btScalar fxs = ((4 * x + 3 * a) * x + 2 * b) * x + c;
292 btScalar fx = (((x + a) * x + b) * x + c) * x + d;
303 btScalar d1 = d + 0.25 * a * (0.25 * b * a - 3. / 64 * a * a * a - c);
304 btScalar c1 = c + 0.5 * a * (0.25 * a * a - b);
328 x[0] =
N4Step(x[0], a, b, c, d);
329 x[1] =
N4Step(x[1], a, b, c, d);
333 x[2] =
N4Step(x[2], a, b, c, d);
334 x[3] =
N4Step(x[3], a, b, c, d);
339#define F5(t) (((((t + a) * t + b) * t + c) * t + d) * t + e)
387 for (cnt = 0; cnt < 10; cnt++)
414 if (x2 <= x0 || x2 >= x1)
429 f2s = (((5 * x2 + 4 * a) * x2 + 3 * b) * x2 + 2 * c) * x2 + d;
437 }
while (fabs(dx) >
eps);
444 btScalar a1 = a + r, b1 = b + r * a1, c1 = c + r * b1, d1 = d + r * c1;
445 return 1 +
SolveP4(x + 1, a1, b1, c1, d1);
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define SIMD_FORCE_INLINE
btScalar root3(btScalar x)
int SolveP5(btScalar *x, btScalar a, btScalar b, btScalar c, btScalar d, btScalar e)
void CSqrt(btScalar x, btScalar y, btScalar &a, btScalar &b)
btScalar SolveP5_1(btScalar a, btScalar b, btScalar c, btScalar d, btScalar e)
int SolveP4(btScalar *x, btScalar a, btScalar b, btScalar c, btScalar d)
static btScalar _root3(btScalar x)
static void dblSort3(btScalar &a, btScalar &b, btScalar &c)
int SolveP3(btScalar *x, btScalar a, btScalar b, btScalar c)
int SolveP4Bi(btScalar *x, btScalar b, btScalar d)
btScalar N4Step(btScalar x, btScalar a, btScalar b, btScalar c, btScalar d)
int SolveP2(btScalar *x, btScalar a, btScalar b)
int SolveP4De(btScalar *x, btScalar b, btScalar c, btScalar d)