UNPKG

gs-json

Version:

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

85 lines 2.71 kB
import { Obj } from "./entity_obj"; import { Point } from "./entity_point"; import * as threex from "./libs/threex/threex"; import * as util from "./_utils"; /** * Class ConicCurve. */ export class Ellipse extends Obj { /** * Get the object type: "circle". * @return ConicCurve object type. */ getObjType() { return 4 /* ellipse */; } /** * Get the origin of the ellipse. * @return Plane object type. */ getOrigin() { return new 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 radius of the circle. * @return The x and y vectors. */ getAxes() { const params = this._kernel.objGetParams(this._id); return [params[1], params[2], params[3]]; } /** * Returns the x and y vectors of this curve. The length of the x vector defines the radius of the circle. * @return The x and y vectors. */ getNormal() { return this._kernel.objGetParams(this._id)[3]; } /** * Sets the x and y vectors of this curve. The length of the x vector defines the radius of the circle. * @param x_vec Vector, the x axis * @param vec vector, in the plane */ setOrientation(x_vec, vec) { // param are [type, x_vec, y_vec, z_vec, angles] const vecs = threex.makeXYZOrthogonal(x_vec, vec, false); const params = this._kernel.objGetParams(this._id); params[1] = vecs[0]; params[2] = vecs[1]; params[3] = vecs[2]; } /** * Returns the Alpha and Beta angles of this curve. * @return The Alpha and Beta angles. */ getAngles() { return this._kernel.objGetParams(this._id)[4]; } /** * Returns the Alpha and Beta angles of this curve. * @return The Alpha and Beta angles. */ setAngles(angles) { // make sure the angles are ok angles = util.checkCircleAngles(angles); this._kernel.objGetParams(this._id)[4] = angles; } /** * Returns the x and y radii of this curve. * @return The x and y radii. */ getRadii() { return [ threex.lengthXYZ(this._kernel.objGetParams(this._id)[1]), threex.lengthXYZ(this._kernel.objGetParams(this._id)[2]), ]; } /** * Checks if the ellipse is closed. * @return True if the polyline is closed. */ isClosed() { return (this._kernel.objGetParams(this._id)[4] === undefined); } } //# sourceMappingURL=entity_obj_ellipse.js.map