UNPKG

malwoden

Version:

![alt text](./coverage/badge-lines.svg) ![alt text](./coverage/badge-statements.svg) ![alt text](./coverage/badge-functions.svg) ![alt text](./coverage/badge-branches.svg)

83 lines 2.6 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Line = void 0; var Line = /** @class */ (function () { function Line(v1, v2) { this.dx = 0; this.dy = 0; this._v1 = v1; this._v2 = v2; this.calcDeltas(); } Object.defineProperty(Line.prototype, "v1", { get: function () { return this._v1; }, set: function (val) { this._v1 = val; this.calcDeltas(); }, enumerable: false, configurable: true }); Object.defineProperty(Line.prototype, "v2", { get: function () { return this._v2; }, set: function (val) { this._v2 = val; this.calcDeltas(); }, enumerable: false, configurable: true }); Line.prototype.calcDeltas = function () { this.dx = this._v2.x - this.v1.x; this.dy = this._v2.y - this.v1.y; }; Line.prototype.clone = function () { return new Line(__assign({}, this._v1), __assign({}, this._v2)); }; Line.prototype.getDeltaX = function () { return this.dx; }; Line.prototype.getDeltaY = function () { return this.dy; }; Line.prototype.isBelow = function (x, y) { return this.calculateRelativeSlope(x, y) > 0; }; Line.prototype.isBelowOrCollinear = function (x, y) { return this.calculateRelativeSlope(x, y) >= 0; }; Line.prototype.isAbove = function (x, y) { return this.calculateRelativeSlope(x, y) < 0; }; Line.prototype.isAboveOrCollinear = function (x, y) { return this.calculateRelativeSlope(x, y) <= 0; }; Line.prototype.isCollinear = function (x, y) { return this.calculateRelativeSlope(x, y) === 0; }; Line.prototype.isLineCollinear = function (line) { return (this.isCollinear(line.v1.x, line.v1.y) && this.isCollinear(line.v2.x, line.v2.y)); }; Line.prototype.calculateRelativeSlope = function (x, y) { return this.dy * (this.v2.x - x) - this.dx * (this.v2.y - y); }; return Line; }()); exports.Line = Line; //# sourceMappingURL=line.js.map