@nexys/math-ts
Version:
[](https://www.npmjs.com/package/@nexys/math-ts) [](https://travis-ci.com/github/Nexysweb/math-ts) [ • 503 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.equationFromSegment = (p1, p2) => {
const m = (p2.y - p1.y) / (p2.x - p1.x);
const q = p1.y - m * p1.x;
return { m, q };
};
exports.polyY = (x, { m, q }) => m * x + q;
exports.polyX = (y, { m, q }) => (y - q) / m;
exports.solve2nd = (a, b, c) => {
const d = Math.pow(b, 2) - 4 * a * c;
const x1 = (-b + Math.sqrt(d)) / (2 * a);
const x2 = (-b - Math.sqrt(d)) / (2 * a);
return [x1, x2];
};