Skip to content

Instantly share code, notes, and snippets.

@Aleksey-Danchin
Last active June 23, 2020 16:17
Show Gist options
  • Save Aleksey-Danchin/d064f00515a1a9bdec63 to your computer and use it in GitHub Desktop.
Save Aleksey-Danchin/d064f00515a1a9bdec63 to your computer and use it in GitHub Desktop.
Fabric function of the others quadratic functions.
function GetQuadraticFunction (a, b, c, d) {
return (function (a, b, c, d) {
function init (value, defaultValue) {
value = parseFloat(value);
if (Number.isNaN(value) || !Number.isFinite(value)) {
value = defaultValue;
}
return value;
}
a = init(a, 1); b = init(b, 0); c = init(c, 0); d = init(d, 0);
return function (x) {
return a * Math.pow(x - d, 2) + b * (x - d) + c;
}
})(a, b, c, d);
}
@Semigradsky
Copy link

Для чего же сделаны тут коментарии, как не для спора, в котором рождается мигрень)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment