UNPKG

@mlightcad/geometry-engine

Version:

The geometry-engine package provides comprehensive geometric entities, mathematical operations, and transformations for 2D and 3D space. This package mimics AutoCAD ObjectARX's AcGe (Geometry) classes and provides the mathematical foundation for CAD opera

125 lines 4.2 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { AcGeBox2d, AcGePoint2d } from '../math'; import { AcGeCurve2d } from './AcGeCurve2d'; /** * The class represents one 3d line geometry specified by its start point and end point. */ var AcGeLine2d = /** @class */ (function (_super) { __extends(AcGeLine2d, _super); /** * This constructor initializes the line object to use start as the start point, and end * as the endpoint. Both points must be in WCS coordinates. */ function AcGeLine2d(start, end) { var _this = _super.call(this) || this; _this._start = new AcGePoint2d(start); _this._end = new AcGePoint2d(end); return _this; } Object.defineProperty(AcGeLine2d.prototype, "startPoint", { /** * The line's startpoint in WCS coordinates * @returns Return the line's startpoint in WCS coordinates. */ get: function () { return this._start; }, set: function (value) { this._start.copy(value); this._boundingBoxNeedsUpdate = true; }, enumerable: false, configurable: true }); Object.defineProperty(AcGeLine2d.prototype, "endPoint", { /** * The line's endpoint in WCS coordinates * @returns Return the line's endpoint in WCS coordinates. */ get: function () { return this._end; }, set: function (value) { this._end.copy(value); this._boundingBoxNeedsUpdate = true; }, enumerable: false, configurable: true }); /** * Convert line to a point array with start point and end point. * @returns Return an array of point */ AcGeLine2d.prototype.getPoints = function () { return [this.startPoint, this.endPoint]; }; Object.defineProperty(AcGeLine2d.prototype, "length", { /** * @inheritdoc */ get: function () { return this.startPoint.distanceTo(this.endPoint); }, enumerable: false, configurable: true }); /** * @inheritdoc */ AcGeLine2d.prototype.calculateBoundingBox = function () { var min = new AcGePoint2d(Math.min(this._start.x, this._end.x), Math.min(this._start.y, this._end.y)); var max = new AcGePoint2d(Math.max(this._start.x, this._end.x), Math.max(this._start.y, this._end.y)); return new AcGeBox2d(min, max); }; /** * @inheritdoc */ AcGeLine2d.prototype.transform = function (matrix) { this._start.applyMatrix2d(matrix); this._end.applyMatrix2d(matrix); this._boundingBoxNeedsUpdate = true; return this; }; Object.defineProperty(AcGeLine2d.prototype, "closed", { /** * @inheritdoc */ get: function () { return false; }, enumerable: false, configurable: true }); /** * @inheritdoc */ AcGeLine2d.prototype.copy = function (value) { this.startPoint = value.startPoint; this.endPoint = value.endPoint; this._boundingBoxNeedsUpdate = true; return this; }; /** * @inheritdoc */ AcGeLine2d.prototype.clone = function () { return new AcGeLine2d(this._start.clone(), this._end.clone()); }; return AcGeLine2d; }(AcGeCurve2d)); export { AcGeLine2d }; //# sourceMappingURL=AcGeLine2d.js.map