"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Geometry
 */
// cspell:ignore Helmert
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdditionalTransform = exports.Helmert2DWithZOffset = void 0;
const core_geometry_1 = require("@itwin/core-geometry");
/** An affine transformation with an additional Z Offset.
 *  The equations are:
 *  given a = scale * cos(rotation) and b = scale * sin(rotation)
 *  X = a * x - b * y + translationX
 *  Y = b * x + a * y + translationY
 *  Z = z + translationZ
 *
 *  Note that the class only implements the definition and not the operation.
 *  @public
 */
class Helmert2DWithZOffset {
    constructor(data) {
        if (data) {
            this.translationX = data.translationX;
            this.translationY = data.translationY;
            this.translationZ = data.translationZ;
            this.rotDeg = data.rotDeg;
            this.scale = data.scale;
        }
    }
    /** Creates an Helmert Transform from JSON representation.
     * @public */
    static fromJSON(data) {
        return new Helmert2DWithZOffset(data);
    }
    /** Creates a JSON from the Helmert Transform definition
     * @public */
    toJSON() {
        return { translationX: this.translationX, translationY: this.translationY, translationZ: this.translationZ, rotDeg: this.rotDeg, scale: this.scale };
    }
    /** Compares two Helmert2DWithZOffset objects applying a minuscule tolerance.
     *  @public */
    equals(other) {
        return (Math.abs(this.translationX - other.translationX) < core_geometry_1.Geometry.smallMetricDistance &&
            Math.abs(this.translationY - other.translationY) < core_geometry_1.Geometry.smallMetricDistance &&
            Math.abs(this.translationZ - other.translationZ) < core_geometry_1.Geometry.smallMetricDistance &&
            Math.abs(this.rotDeg - other.rotDeg) < core_geometry_1.Geometry.smallAngleDegrees &&
            Math.abs(this.scale - other.scale) < core_geometry_1.Geometry.smallFraction);
    }
}
exports.Helmert2DWithZOffset = Helmert2DWithZOffset;
/** Additional Transform implementation.
 *  An additional transform is a transformation that can apply to either the horizontal or vertical coordinates of a
 *  geographic CRS. The transformation is applied after the latitude/longitude have been projected thus the process
 *  is applied to the result Cartesian coordinates of the projection process.
 *  @public
*/
class AdditionalTransform {
    constructor(data) {
        if (data)
            this.helmert2DWithZOffset = data.helmert2DWithZOffset ? Helmert2DWithZOffset.fromJSON(data.helmert2DWithZOffset) : undefined;
    }
    /** Creates an Additional Transform from JSON representation.
     * @public */
    static fromJSON(data) {
        return new AdditionalTransform(data);
    }
    /** Creates a JSON from the Additional Transform definition
     * @public */
    toJSON() {
        return { helmert2DWithZOffset: this.helmert2DWithZOffset };
    }
    /** Compares two additional transforms applying a minuscule tolerance to comparing numbers.
     *  @public */
    equals(other) {
        if ((this.helmert2DWithZOffset === undefined) !== (other.helmert2DWithZOffset === undefined))
            return false;
        if (this.helmert2DWithZOffset && !this.helmert2DWithZOffset.equals(other.helmert2DWithZOffset))
            return false;
        return true;
    }
}
exports.AdditionalTransform = AdditionalTransform;
//# sourceMappingURL=AdditionalTransform.js.map