UNPKG

geometric-pack

Version:

Geometric pack with lots of available calculations for 2D and 3D geometry

103 lines 4.48 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Tube = void 0; var normalize_result_1 = require("../../utils/normalize-result"); var Tube = /** @class */ (function () { function Tube() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this.validateInput(args); this.outerRadius = args[0]; this.innerRadius = args[1]; this.height = args[2]; } Tube.prototype.validateInput = function (args) { args.forEach(function (arg) { if (typeof arg !== "number") { throw new Error("Argument must be a number"); } }); if (args.length !== 3) { throw new Error("Tube constructor takes 3 arguments"); } if (args[0] <= args[1]) { throw new Error("Outer radius must be bigger number than inner radius"); } if (this.hasNegative(args)) { throw new Error("Radiuses and height must be positive numbers"); } }; Tube.prototype.hasNegative = function (_a) { var outerRadius = _a[0], innerRadius = _a[1], height = _a[2]; return outerRadius <= 0 || innerRadius <= 0 || height <= 0; }; Tube.prototype.getDefinition = function () { return { outerRadius: this.outerRadius, innerRadius: this.innerRadius, height: this.height, outerCircumference: this.getOuterCircumference(), innerCircumference: this.getInnerCircumference(), ExternalLateralSurfaceArea: this.getExternalLateralSurfaceArea(), InternalLateralSurfaceArea: this.getInternalLateralSurfaceArea(), outerArea: this.getOuterArea(), innerArea: this.getInnerArea(), endSurfaceArea: this.getEndSurfaceArea(), outerVolume: this.getOuterVolume(), innerVolume: this.getInnerVolume(), solidVolume: this.getSolidVolume(), wallThickness: this.getWallThickness(), }; }; Tube.prototype.getOuterCircumference = function () { return 2 * Math.PI * this.outerRadius; }; Tube.prototype.getInnerCircumference = function () { return 2 * Math.PI * this.innerRadius; }; Tube.prototype.getExternalLateralSurfaceArea = function () { return 2 * Math.PI * this.outerRadius * this.height; }; Tube.prototype.getInternalLateralSurfaceArea = function () { return 2 * Math.PI * this.innerRadius * this.height; }; Tube.prototype.getOuterArea = function () { return Math.PI * Math.pow(this.outerRadius, 2); }; Tube.prototype.getInnerArea = function () { return Math.PI * Math.pow(this.innerRadius, 2); }; Tube.prototype.getEndSurfaceArea = function () { return this.getOuterArea() - this.getInnerArea(); }; Tube.prototype.getOuterVolume = function () { return Math.PI * Math.pow(this.outerRadius, 2) * this.height; }; Tube.prototype.getInnerVolume = function () { return Math.PI * Math.pow(this.innerRadius, 2) * this.height; }; Tube.prototype.getSolidVolume = function () { return this.getOuterVolume() - this.getInnerVolume(); }; Tube.prototype.getWallThickness = function () { return this.outerRadius - this.innerRadius; }; Tube = __decorate([ normalize_result_1.NormalizeResults(), __metadata("design:paramtypes", [Number]) ], Tube); return Tube; }()); exports.Tube = Tube; //# sourceMappingURL=tube.js.map