UNPKG

gs-json

Version:

gs-JSON is a domain agnostic unifying 3D file format for geometric and semantic modelling (hence the 'gs').

156 lines (131 loc) 5.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Hyperbola = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _entity_obj = require("./entity_obj"); var _entity_point = require("./entity_point"); var _threex = require("./libs/threex/threex"); var threex = _interopRequireWildcard(_threex); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * Class ConicCurve. */ var Hyperbola = exports.Hyperbola = function (_Obj) { _inherits(Hyperbola, _Obj); function Hyperbola() { _classCallCheck(this, Hyperbola); return _possibleConstructorReturn(this, (Hyperbola.__proto__ || Object.getPrototypeOf(Hyperbola)).apply(this, arguments)); } _createClass(Hyperbola, [{ key: "getObjType", /** * Get the object type: "hyperbola". * @return ConicCurve object type. */ value: function getObjType() { return 6 /* hyperbola */; } /** * Get the origin of the hyperbola. * @return Plane object type. */ }, { key: "getOrigin", value: function getOrigin() { return new _entity_point.Point(this._kernel, this._kernel.objGetOnePoint(this._id)); } /** * Returns the x and y vectors of this curve. The length of the x vector * defines the a,b parameters of the hyperbola. * @return The x and y vectors. */ }, { key: "getVectors", value: function getVectors() { return [this._kernel.objGetParams(this._id)[1], this._kernel.objGetParams(this._id)[2]]; } /** * Sets the x and y vectors of this curve. The length of the x,y vectors * defines the a,b parameters of the hyperbola. * @return The x and y vectors. */ }, { key: "setVectors", value: function setVectors(x_vec, y_vec) { // param are [type, x_vec, y_vec, z_vec, angles] this._kernel.objGetParams(this._id)[1] = x_vec; this._kernel.objGetParams(this._id)[2] = y_vec; this._kernel.objGetParams(this._id)[3] = threex.crossXYZs(x_vec, y_vec, true); } /** * Returns the Alpha and Beta angles of this curve. * @return The Alpha and Beta angles. */ }, { key: "getAngles", value: function getAngles() { return this._kernel.objGetParams(this._id)[4]; } /** * Returns the Alpha and Beta angles of this curve. * @return The Alpha and Beta angles. */ }, { key: "setAngles", value: function setAngles(angles) { this._kernel.objGetParams(this._id)[4] = angles; } /** * Returns the radii of this curve (the lengths of the x,y vectors). * @return The radii. */ }, { key: "getRadii", value: function getRadii() { return [threex.lengthXYZ(this._kernel.objGetParams(this._id)[1]), threex.lengthXYZ(this._kernel.objGetParams(this._id)[2])]; } /** * Get the length of the circle or arc. * @return The length. */ }, { key: "length", value: function length() { throw new Error("method not implemented"); // return math_conics.hyperbolaLength(this); } /** * Get a point located at t% of the hyperbola length. * @return A Point. */ }, { key: "evalParam", value: function evalParam(t) { throw new Error("method not implemented"); // const xyz: XYZ = math_conics.hyperbolaEvaluate(this, t); // return this._kernel.getGeom().addPoint(xyz); } /** * Get a set of equidistant points along the arc of hyperbola. * @return An array of points. */ }, { key: "equiPoints", value: function equiPoints(num_points) { throw new Error("method not implemented"); // const length: number = math_conics.hyperbolaLength(this); // const xyzs: XYZ[] = []; // for (let i = 0; i < num_points; i++) { // xyzs.push(math_conics.hyperbolaEvaluate(this, i/(num_points - 1))); // } // return this._kernel.getGeom().addPoints(xyzs); } }]); return Hyperbola; }(_entity_obj.Obj); //# sourceMappingURL=entity_obj_hyperbola.js.map