/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { Angle } from "@vertexvis/geometry";
class ScaledUnitConverter {
    constructor(scale) {
        this.scale = scale;
    }
    convertTo(value) {
        return value * this.scale;
    }
    convertFrom(value) {
        return value / this.scale;
    }
}
class MillimeterUnitConverter extends ScaledUnitConverter {
    constructor() {
        super(1);
    }
}
class CentimeterUnitConverter extends ScaledUnitConverter {
    constructor(power = 1) {
        super(1 / Math.pow(10, power));
    }
}
class MeterUnitConverter extends ScaledUnitConverter {
    constructor(power = 1) {
        super(1 / Math.pow(1000, power));
    }
}
class InchesUnitConverter extends ScaledUnitConverter {
    constructor(power = 1) {
        super(1 / Math.pow(25.4, power));
    }
}
class FeetUnitConverter extends ScaledUnitConverter {
    constructor(power = 1) {
        super(1 / Math.pow(25.4 * 12, power));
    }
}
class YardUnitConverter extends ScaledUnitConverter {
    constructor(power = 1) {
        super(1 / Math.pow(25.4 * 12 * 3, power));
    }
}
/**
 * A class that contains helpers for transforming values and points between
 * world space distances and real space distances.
 */
export class DistanceUnits {
    constructor(unitType) {
        this.unitType = unitType;
        this.unit = DistanceUnits.units[unitType];
    }
    /**
     * Translates a world space value to a real space value.
     *
     * @param value A world space value to translate.
     * @returns A value in real space units.
     */
    convertWorldValueToReal(value) {
        return this.unit.converter.convertTo(value);
    }
    /**
     * Translates a real space value to a world space value.
     *
     * @param value A real space value to translate.
     * @returns A world space value.
     */
    convertRealValueToWorld(value) {
        return this.unit.converter.convertFrom(value);
    }
    /**
     * Translates a world space point to a point in real space.
     *
     * @param pt A point in world space.
     * @returns A point in real space.
     */
    convertWorldPointToReal(pt) {
        const x = this.unit.converter.convertTo(pt.x);
        const y = this.unit.converter.convertTo(pt.y);
        const z = this.unit.converter.convertTo(pt.z);
        return { x, y, z };
    }
    /**
     * Translates a real space point to a point in world space.
     *
     * @param pt A point in real space.
     * @returns A point in world space.
     */
    convertRealPointToWorld(pt) {
        const x = this.unit.converter.convertFrom(pt.x);
        const y = this.unit.converter.convertFrom(pt.y);
        const z = this.unit.converter.convertFrom(pt.z);
        return { x, y, z };
    }
}
DistanceUnits.units = {
    millimeters: {
        name: 'Millimeters',
        abbreviatedName: 'mm',
        converter: new MillimeterUnitConverter(),
    },
    centimeters: {
        name: 'Centimeters',
        abbreviatedName: 'cm',
        converter: new CentimeterUnitConverter(),
    },
    meters: {
        name: 'Meters',
        abbreviatedName: 'm',
        converter: new MeterUnitConverter(),
    },
    inches: {
        name: 'Inches',
        abbreviatedName: 'in',
        converter: new InchesUnitConverter(),
    },
    feet: {
        name: 'Feet',
        abbreviatedName: 'ft',
        converter: new FeetUnitConverter(),
    },
    yards: {
        name: 'Yards',
        abbreviatedName: 'yd',
        converter: new YardUnitConverter(),
    },
};
class RadiansToDegreesUnitConverter {
    convertTo(radians) {
        return Angle.toDegrees(radians);
    }
    convertFrom(degrees) {
        return Angle.toRadians(degrees);
    }
}
/**
 * A class that contains helpers for transforming angle units.
 */
export class AngleUnits {
    constructor(unitType) {
        this.unitType = unitType;
        this.unit = AngleUnits.units[unitType];
    }
    /**
     * Converts radians to the chosen unit type.
     *
     * @param radians An angle in radians.
     * @returns An angle in the chosen unit type.
     */
    convertTo(radians) {
        return this.unit.converter.convertTo(radians);
    }
    /**
     * Converts the chosen unit type back to radians.
     *
     * @param value The value to convert
     * @returns An angle in radians.
     */
    convertFrom(value) {
        return this.unit.converter.convertFrom(value);
    }
}
AngleUnits.units = {
    radians: {
        name: 'Radians',
        abbreviatedName: 'rad',
        converter: new ScaledUnitConverter(1),
    },
    degrees: {
        name: 'Degrees',
        abbreviatedName: 'deg',
        converter: new RadiansToDegreesUnitConverter(),
    },
};
/**
 * A class that contains helpers for transforming area units.
 */
export class AreaUnits {
    constructor(unitType) {
        this.unitType = unitType;
        this.unit = AreaUnits.units[unitType];
    }
    /**
     * Translates a world space value to a real space value.
     *
     * @param value A world space value to translate.
     * @returns A value in real space units.
     */
    convertWorldValueToReal(value) {
        return this.unit.converter.convertTo(value);
    }
    /**
     * Translates a real space value to a world space value.
     *
     * @param value A real space value to translate.
     * @returns A world space value.
     */
    convertRealValueToWorld(value) {
        return this.unit.converter.convertFrom(value);
    }
}
AreaUnits.units = {
    millimeters: {
        name: 'Square Millimeters',
        abbreviatedName: 'mm²',
        converter: new MillimeterUnitConverter(),
    },
    centimeters: {
        name: 'Square Centimeters',
        abbreviatedName: 'cm²',
        converter: new CentimeterUnitConverter(2),
    },
    meters: {
        name: 'Square Meters',
        abbreviatedName: 'm²',
        converter: new MeterUnitConverter(2),
    },
    inches: {
        name: 'Square Inches',
        abbreviatedName: 'in²',
        converter: new InchesUnitConverter(2),
    },
    feet: {
        name: 'Square Feet',
        abbreviatedName: 'ft²',
        converter: new FeetUnitConverter(2),
    },
    yards: {
        name: 'Square Yards',
        abbreviatedName: 'yd²',
        converter: new YardUnitConverter(2),
    },
};
//# sourceMappingURL=distanceUnits.js.map
