38 #ifndef FCL_NARROWPHASE_DETAIL_POLYSOLVER_INL_H 39 #define FCL_NARROWPHASE_DETAIL_POLYSOLVER_INL_H 41 #include "fcl/math/detail/polysolver.h" 44 #include "fcl/common/types.h" 53 class PolySolver<double>;
74 return solveLinear(c, s);
77 p = c[1] / (2.0 * c[2]);
102 template <
typename S>
106 S sub, A, B, C, sq_A, p, q, cb_p, D;
107 const S ONE_OVER_THREE = 1 / 3.0;
108 const S PI = 3.14159265358979323846;
112 return solveQuadric(c, s);
121 p = (-ONE_OVER_THREE * sq_A + B) * ONE_OVER_THREE;
122 q = 0.5 * (2.0 / 27.0 * A * sq_A - ONE_OVER_THREE * A * B + C);
150 S phi = ONE_OVER_THREE * acos(-q / sqrt(-cb_p));
151 S t = 2.0 * sqrt(-p);
153 s[1] = -t * cos(phi + PI / 3.0);
154 s[2] = -t * cos(phi - PI / 3.0);
161 S u = cbrt(sqrt_D + fabs(q));
171 sub = ONE_OVER_THREE * A;
172 for(i = 0; i < num; i++)
178 template <
typename S>
181 return (v < getNearZeroThreshold()) && (v > -getNearZeroThreshold());
185 template <
typename S>
188 return std::pow(v, 1.0 / 3.0);
192 template <
typename S>
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
static int solveQuadric(S c[3], S s[2])
Solve a quadratic function with coefficients c, return roots s and number of roots.
Definition: polysolver-inl.h:67
static int solveLinear(S c[2], S s[1])
Solve a linear equation with coefficients c, return roots s and number of roots.
Definition: polysolver-inl.h:57
A class solves polynomial degree (1,2,3) equations.
Definition: polysolver.h:48
static int solveCubic(S c[4], S s[3])
Solve a cubic function with coefficients c, return roots s and number of roots.
Definition: polysolver-inl.h:103