Fixed (?) splines in critical region

I have no explanation for the broken code that used to be in the solve_cubic function.  Seems it was related to the linear or quadratic cases but it makes no sense. Removed the code.

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-10-14 14:49:19 +02:00
parent 9c4ca15c28
commit 3310d1cf11
4 changed files with 12 additions and 22 deletions

View File

@@ -164,7 +164,7 @@ void solve_cubic(double a, double b, double c, double d, int &N, double &x0, dou
{
// 0 = ax^3 + b*x^2 + c*x + d
// First check if the "cubic" is actually a second order or first order curve
if (std::abs(a) < 10*DBL_EPSILON){
if (std::abs(b) < 10*DBL_EPSILON){
// Linear solution if a = 0 and b = 0
@@ -185,26 +185,6 @@ void solve_cubic(double a, double b, double c, double d, int &N, double &x0, dou
// Discriminant
double DELTA = 18*a*b*c*d-4*b*b*b*d+b*b*c*c-4*a*c*c*c-27*a*a*d*d;
double DELTA0 = b*b*b-2*a*c;
// Deal with special cases
if (std::abs(DELTA) < 10*DBL_EPSILON){
if (std::abs(DELTA0)>0){
x0 = (9*a*d-b*c)/(2*DELTA0);
x1 = x0;
x2 = (4*a*b*c - 9*a*a*d - b*b*b)/(a*DELTA0);
N = 3;
return;
}
else{
x0 = -b/(3*a);
x1 = x0;
x2 = x0;
N = 3;
return;
}
}
// Coefficients for the depressed cubic t^3+p*t+q = 0
double p = (3*a*c-b*b)/(3*a*a);
double q = (2*b*b*b-9*a*b*c+27*a*a*d)/(27*a*a*a);