mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Clean up Numerical code a bit.
This commit is contained in:
parent
f6f9d963eb
commit
00f1d5089f
1 changed files with 4 additions and 4 deletions
|
@ -121,7 +121,7 @@ var Numerical = new function() {
|
||||||
* Numerical.EPSILON.
|
* Numerical.EPSILON.
|
||||||
*/
|
*/
|
||||||
isZero: function(val) {
|
isZero: function(val) {
|
||||||
return abs(val) <= EPSILON;
|
return val >= -EPSILON && val <= EPSILON;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,7 +180,7 @@ var Numerical = new function() {
|
||||||
*
|
*
|
||||||
* References:
|
* References:
|
||||||
* Kahan W. - "To Solve a Real Cubic Equation"
|
* Kahan W. - "To Solve a Real Cubic Equation"
|
||||||
* http://www.cs.berkeley.edu/~wkahan/Math128/Cubic.pdf
|
* http://www.cs.berkeley.edu/~wkahan/Math128/Cubic.pdf
|
||||||
* Blinn J. - "How to solve a Quadratic Equation"
|
* Blinn J. - "How to solve a Quadratic Equation"
|
||||||
*
|
*
|
||||||
* @param {Number} a the quadratic term
|
* @param {Number} a the quadratic term
|
||||||
|
@ -212,8 +212,8 @@ var Numerical = new function() {
|
||||||
// We multiply with a factor to normalize the coefficients.
|
// We multiply with a factor to normalize the coefficients.
|
||||||
// The factor is just the nearest exponent of 10, big enough
|
// The factor is just the nearest exponent of 10, big enough
|
||||||
// to raise all the coefficients to nearly [-1, +1] range.
|
// to raise all the coefficients to nearly [-1, +1] range.
|
||||||
var mult = pow(10, abs(
|
var mult = pow(10,
|
||||||
Math.floor(Math.log(gmC) * Math.LOG10E)));
|
abs(Math.floor(Math.log(gmC) * Math.LOG10E)));
|
||||||
if (!isFinite(mult))
|
if (!isFinite(mult))
|
||||||
mult = 0;
|
mult = 0;
|
||||||
a *= mult;
|
a *= mult;
|
||||||
|
|
Loading…
Reference in a new issue