UNPKG

@nexys/math-ts

Version:

[![npm version](https://badge.fury.io/js/%40nexys%2Fmath-ts.svg)](https://www.npmjs.com/package/@nexys/math-ts) [![TavisCI](https://travis-ci.com/Nexysweb/tableau-wdc-react.svg?branch=master)](https://travis-ci.com/github/Nexysweb/math-ts) [![Deployment](

16 lines (15 loc) 503 B
"use strict"; 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]; };