mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Prevent invalid invinite solutions in Numerical.solveQuadratic()
Closes #708
This commit is contained in:
parent
e3f04478d9
commit
ce41447793
1 changed files with 2 additions and 2 deletions
|
@ -176,12 +176,12 @@ var Numerical = new function() {
|
||||||
B = b,
|
B = b,
|
||||||
D;
|
D;
|
||||||
b /= 2;
|
b /= 2;
|
||||||
D = b * b - a * c; // Discriminant
|
D = b * b - a * c; // Discriminant
|
||||||
/*
|
/*
|
||||||
* If the discriminant is very small, we can try to pre-condition
|
* If the discriminant is very small, we can try to pre-condition
|
||||||
* the coefficients, so that we may get better accuracy
|
* the coefficients, so that we may get better accuracy
|
||||||
*/
|
*/
|
||||||
if (abs(D) < MACHINE_EPSILON) {
|
if (D !== 0 && abs(D) < MACHINE_EPSILON) {
|
||||||
// If the geometric mean of the coefficients is small enough
|
// If the geometric mean of the coefficients is small enough
|
||||||
var pow = Math.pow,
|
var pow = Math.pow,
|
||||||
gmC = pow(abs(a*b*c), 1/3);
|
gmC = pow(abs(a*b*c), 1/3);
|
||||||
|
|
Loading…
Reference in a new issue