From 6441620f45006c26f65e73c846609b4c47473685 Mon Sep 17 00:00:00 2001 From: hoangviet1985 Date: Tue, 10 Nov 2015 16:18:07 -0500 Subject: [PATCH] The right signs give the right results --- modules/core/src/mathfuncs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index 4b5327116..9e6b89ff4 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -2440,13 +2440,13 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots ) { if(R >= 0) { - x0 = pow(R/4, 1./3) - a1/3; - x1 = -pow(2*R, 1./3) - a1/3; + x0 = -2*pow(R, 1./3) - a1/3; + x1 = pow(R, 1./3) - a1/3; } else { - x0 = -pow(-R/4, 1./3) - a1/3; - x1 = pow(-2*R, 1./3) - a1/3; + x0 = 2*pow(-R, 1./3) - a1/3; + x1 = -pow(-R, 1./3) - a1/3; } x2 = 0; n = x0 == x1 ? 1 : 2;