"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoordinateXYZ = void 0;
const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
const Range_1 = require("../geometry3d/Range");
const GeometryQuery_1 = require("./GeometryQuery");
/**
 * A Coordinate is a Point3d with supporting methods from the GeometryQuery abstraction.
 * @public
 */
class CoordinateXYZ extends GeometryQuery_1.GeometryQuery {
    /** String name for interface properties. */
    geometryCategory = "point";
    _xyz;
    /** Return a (REFERENCE TO) the coordinate data. */
    get point() {
        return this._xyz;
    }
    /**
     * Constructor
     * @param xyz point to be CAPTURED.
     */
    constructor(xyz) {
        super();
        this._xyz = xyz;
    }
    /** Create a new CoordinateXYZ containing a CLONE of point. */
    static create(point) {
        return new CoordinateXYZ(point.clone());
    }
    /** Create a new CoordinateXYZ. */
    static createXYZ(x = 0, y = 0, z = 0) {
        return new CoordinateXYZ(Point3dVector3d_1.Point3d.create(x, y, z));
    }
    /** Return the range of the point. */
    range() {
        return Range_1.Range3d.create(this._xyz);
    }
    /** Extend `rangeToExtend` to include this point (optionally transformed). */
    extendRange(rangeToExtend, transform) {
        if (transform)
            rangeToExtend.extendTransformedXYZ(transform, this._xyz.x, this._xyz.y, this._xyz.z);
        else
            rangeToExtend.extend(this._xyz);
    }
    /** Apply transform to the Coordinate's point. */
    tryTransformInPlace(transform) {
        transform.multiplyPoint3d(this._xyz, this._xyz);
        return true;
    }
    /** Return a transformed clone. */
    cloneTransformed(transform) {
        const result = new CoordinateXYZ(this._xyz.clone());
        result.tryTransformInPlace(transform);
        return result;
    }
    /** Return a clone. */
    clone() {
        return new CoordinateXYZ(this._xyz.clone());
    }
    /** Test if (other instanceof Coordinate).  */
    isSameGeometryClass(other) {
        return other instanceof CoordinateXYZ;
    }
    /**
     * Test for exact structure and nearly identical geometry.
     * *  Leaf classes must implement.
     * *  Base class implementation recurses through children.
     * *  Base implementation is complete for classes with children and no properties.
     * *  Classes with both children and properties must implement for properties, call super for children.
     */
    isAlmostEqual(other) {
        return (other instanceof CoordinateXYZ) && this._xyz.isAlmostEqual(other._xyz);
    }
    /** Second step of double dispatch: call `handler.handleCoordinateXYZ(this)` */
    dispatchToGeometryHandler(handler) {
        return handler.handleCoordinateXYZ(this);
    }
}
exports.CoordinateXYZ = CoordinateXYZ;
//# sourceMappingURL=CoordinateXYZ.js.map