/** @packageDocumentation * @module Geometry */ import { Point2d, Point3d, Range2d, Range3d, Vector2d, Vector3d } from "@bentley/geometry-core"; /** * Provides facilities for quantizing floating point values within a specified range into 16-bit unsigned integers. * This is a lossy compression technique. * Given a floating point range [min, max], a floating point value `x` within that range is quantized by subtracting * `min`, scaling the result according to `max`, and truncating the result to an integer. * Therefore min quantizes to 0, max to 0xffff, (min+max)/2 to 0x7fff, and so on. * These routines are chiefly used by classes like [[QPoint2d]] and [[QPoint3d]] to reduce the space required to store * coordinate values for [RenderGraphic]($frontend)s. * @public */ export declare namespace Quantization { const rangeScale16 = 65535; const rangeScale8 = 255; /** Compute the scale factor required to quantize `extent` to `rangeScale` discrete values. */ function computeScale(extent: number, rangeScale?: number): number; /** @internal */ function isInRange(qpos: number, rangeScale?: number): boolean; /** Return `pos` quantized to the range [`origin`, `origin + rangeScale`]. * @see [[Quantization.unquantize]] for the inverse operation. */ function quantize(pos: number, origin: number, scale: number, rangeScale?: number): number; /** @internal */ function isQuantizable(pos: number, origin: number, scale: number, rangeScale?: number): boolean; /** Give `qpos` quantized to the range [`origin`, `origin + rangeScale`], return the unquantized value. * @see [[Quantization.quantize]] for the inverse operation. */ function unquantize(qpos: number, origin: number, scale: number): number; /** @internal */ function isQuantized(qpos: number): boolean; } /** Parameters used for [[Quantization]] of 2d points such that the `x` and `y` components are each quantized to 16-bit unsigned integers. * @see [[QPoint2d]] for the quantized representation of a [Point2d]($geometry-core). * @see [[QPoint2dList]] for a list of [[QPoint2d]]s quantized using a [[QParams2d]]. * @public */ export declare class QParams2d { /** The origin of the quantization range. */ readonly origin: Point2d; /** The scale applied to coordinates to quantize them. */ readonly scale: Point2d; private constructor(); private setFrom; /** Set [[origin]] and [[scale]] from `src`. */ copyFrom(src: QParams2d): void; /** Create a copy of these params. * @param out If supplied, these QParams2d will be modified and returned; otherwise a new QParams2d object will be created and returned. */ clone(out?: QParams2d): QParams2d; /** Initialize these parameters to support quantization of values within the specified range. */ setFromRange(range: Range2d, rangeScale?: number): void; /** Create parameters to support quantization of values within the specified range. */ static fromRange(range: Range2d, out?: QParams2d, rangeScale?: number): QParams2d; /** Return the unquantized point for the input `x` and `y` components. If `out` is supplied, it will be modified to hold the result and returned. */ unquantize(x: number, y: number, out?: Point2d): Point2d; /** Creates parameters supporting quantization of values within the range [-1.0, 1.0], appropriate for normalized 2d vectors. */ static fromNormalizedRange(rangeScale?: number): QParams2d; /** Create parameters supporting quantization of values within the range [0.0, 1.0]. */ static fromZeroToOne(rangeScale?: number): QParams2d; /** Create parameters from origin and scale components */ static fromOriginAndScale(originX: number, originY: number, scaleX: number, scaleY: number): QParams2d; /** @internal */ get rangeDiagonal(): Vector2d; /** Return true if the point point is quantizable using these parameters. */ isQuantizable(point: Point2d): boolean; } /** Represents a [Point2d]($geometry-core) compressed such that each component `x` and `y` is quantized to the 16-bit integer range [0, 0xffff]. * These are primarily used to reduce the space required for coordinates used by [RenderGraphic]($frontend)s. * @see [[QParams2d]] to define quantization parameters for a range of points. * @see [[QPoint2dList]] for a list of points all quantized to the same range. * @public */ export declare class QPoint2d { private _x; private _y; /** The quantized x component. */ get x(): number; set x(x: number); /** The quantized y component. */ get y(): number; set y(y: number); /** Construct with `x` and `y` initialized to zero. */ constructor(); /** Initialize this point by quantizing the supplied Point2d using the specified params */ init(pos: Point2d, params: QParams2d): void; /** Create a quantized point from the supplied Point2d using the specified params */ static create(pos: Point2d, params: QParams2d): QPoint2d; /** Initialize `x` and `y` from `src`. */ copyFrom(src: QPoint2d): void; /** Create a copy of this point. * @param out If supplied, it will be modified in-place and returned; otherwise a new QPoint2d will be allocated and returned. */ clone(out?: QPoint2d): QPoint2d; /** * Set the x and y components directly. * @param x Must be an integer in the range [0, 0xffff] * @param y Must be an integer in the range [0, 0xffff] */ setFromScalars(x: number, y: number): void; /** * Create a QPoint2d directly from x and y components. * @param x Must be an integer in the range [0, 0xffff] * @param y Must be an integer in the range [0, 0xffff] */ static fromScalars(x: number, y: number): QPoint2d; /** Return a Point2d unquantized according to the supplied `params`. If `out` is supplied, it will be modified in-place and returned. */ unquantize(params: QParams2d, out?: Point2d): Point2d; } /** A list of [[QPoint2d]]s all quantized to the same range. * @public */ export declare class QPoint2dList { /** Parameters used to quantize the points. */ readonly params: QParams2d; private readonly _list; /** The list of quantized points. */ get list(): ReadonlyArray; /** Construct an empty list set up to use the supplied quantization parameters. */ constructor(params: QParams2d); /** Removes all points from the list. */ clear(): void; /** Removes all points from the list and change the quantization parameters. */ reset(params: QParams2d): void; /** Quantizes the supplied Point2d to this list's range and appends it to the list. */ add(pt: Point2d): void; /** Adds a previously-quantized point to this list. */ push(qpt: QPoint2d): void; /** The number of points in the list. */ get length(): number; /** Returns the unquantized value of the point at the specified index in the list. */ unquantize(index: number, out?: Point2d): Point2d; /** Changes the quantization parameters and requantizes all points in the list to the new range. * @note The loss of precision is compounded each time the points are requantized to a new range. */ requantize(params: QParams2d): void; /** Extracts the current contents of the list as a Uint16Array such that the first element of the array corresponds to the first point's `x` component, * the second to the first point's `y` component, and so on. */ toTypedArray(): Uint16Array; /** Create from a Uint16Array laid out such that `array[0]` corresponds to the first point's `x` component, `array[1]` to the first point's `y` component, and so on. */ fromTypedArray(range: Range2d, array: Uint16Array): void; /** Construct a QPoint2dList containing all points in the supplied list, quantized to the range of those points. */ static fromPoints(points: Point2d[], out?: QPoint2dList): QPoint2dList; } /** Parameters used for [[Quantization]] of 3d points such that the `x`, `y`, and `z` components are each quantized to 16-bit unsigned integers. * @see [[QPoint3d]] for the quantized representation of a [Point3d]($geometry-core). * @see [[QPoint3dList]] for a list of [[QPoint3d]]s quantized using a [[QParams3d]]. * @public */ export declare class QParams3d { /** The origin of the quantization range. */ readonly origin: Point3d; /** The scale applied to coordinates to quantize them. */ readonly scale: Point3d; private constructor(); private setFrom; /** Set `x`, `y`, and `z` from `src. */ copyFrom(src: QParams3d): void; /** Create a copy of these parameters. * @param out If supplied, it will be modified in-place and returned instead of allocating a new QParams3d. */ clone(out?: QParams3d): QParams3d; /** Initialize from origin and scale */ setFromOriginAndScale(origin: Point3d, scale: Point3d): void; /** Initialize these parameters to support quantization of values within the specified range. */ setFromRange(range: Range3d, rangeScale?: number): void; /** Return the unquantized point for the input components. * @param out If supplied, it will be modified in-place and returned instead of allocating a new Point3d. */ unquantize(x: number, y: number, z: number, out?: Point3d): Point3d; /** Creates parameters to support quantization of values within the specified range. * If `out` is supplied, it will be modified in-place and returned instead of allocating a new QParams3d. */ static fromRange(range: Range3d, out?: QParams3d, rangeScale?: number): QParams3d; /** Creates parameters supporting quantization of values within the range [-1.0, 1.0]. * If `out` is supplied, it will be modified in-place and returned instead of allocating a new QParams3d. */ static fromOriginAndScale(origin: Point3d, scale: Point3d, out?: QParams3d): QParams3d; /** Creates parameters supporting quantization of values within the range [-1.0, 1.0]. */ static fromNormalizedRange(rangeScale?: number): QParams3d; /** Creates parameters supporting quantization of values within the range [0.0, 1.0]. */ static fromZeroToOne(rangeScale?: number): QParams3d; /** @internal */ get rangeDiagonal(): Vector3d; /** Return true if the point point is quantizable using these parameters. */ isQuantizable(point: Point3d): boolean; } /** Represents a [Point3d]($geometry-core) compressed such that each component `x`, `y`, and `z` is quantized to the 16-bit integer range [0, 0xffff]. * These are primarily used to reduce the space required for coordinates used by [RenderGraphic]($frontend)s. * @see [[QParams3d]] to define quantization parameters for a range of points. * @see [[QPoint3dList]] for a list of points all quantized to the same range. * @public */ export declare class QPoint3d { private _x; private _y; private _z; /** The quantized x component. */ get x(): number; set x(x: number); /** The quantized y component. */ get y(): number; set y(y: number); /** The quantized z component. */ get z(): number; set z(z: number); /** Construct with all components initialized to zero. */ constructor(); /** Initialize this point by quantizing the supplied Point3d using the specified params */ init(pos: Point3d, params: QParams3d): void; /** Creates a quantized point from the supplied Point3d using the specified params */ static create(pos: Point3d, params: QParams3d): QPoint3d; /** Set this points components from `src`. */ copyFrom(src: QPoint3d): void; /** Create a copy of this point. * @param out If supplied, it will be modified in-place instead of allocating a new QPoint3d. */ clone(out?: QPoint3d): QPoint3d; /** * Sets the x, y, and z components directly. * @param x Must be an integer in the range [0, 0xffff] * @param y Must be an integer in the range [0, 0xffff] * @param z Must be an integer in the range [0, 0xffff] */ setFromScalars(x: number, y: number, z: number): void; /** * Creates a QPoint3d directly from x, y, and z components. * @param x Must be an integer in the range [0, 0xffff] * @param y Must be an integer in the range [0, 0xffff] * @param z Must be an integer in the range [0, 0xffff] * @param out If supplied, it will be modified in-place instead of allocating a new QPoint3d. */ static fromScalars(x: number, y: number, z: number, out?: QPoint3d): QPoint3d; /** Returns a Point3d unquantized according to the supplied params. * If `out` is supplied, it will be modified in-place instead of allocating a new Point3d. */ unquantize(params: QParams3d, out?: Point3d): Point3d; /** Return true if this point's components are identical to the other point's components. */ equals(other: QPoint3d): boolean; /** Perform ordinal comparison to another point. The function returns: * - Zero if this point is identical to `rhs`; or * - A number less than zero if this point is ordered before `rhs`; or * - A number greater than zero if this point is ordered after `rhs`. * @see [OrderedComparator]($bentleyjs-core). */ compare(rhs: QPoint3d): number; } /** A list of [[QPoint3d]]s all quantized to the same range. * @public */ export declare class QPoint3dList { /** Parameters used to quantize the points. */ readonly params: QParams3d; private readonly _list; /** The list of quantized points. */ get list(): ReadonlyArray; /** Construct an empty list set up to quantize to the supplied range. * @param The quantization parameters. If omitted, a null range will be used. */ constructor(params?: QParams3d); /** Construct a QPoint3dList containing all points in the supplied list, quantized to the range of those points. * @param The points to quantize and add to the list. * @param out If supplied, it will be cleared, its parameters recomputed, and the points will be added to it; otherwise, a new QPoint3dList will be created and returned. */ static fromPoints(points: Point3d[], out?: QPoint3dList): QPoint3dList; /** Removes all points from the list. */ clear(): void; /** Clears out the contents of the list and changes the quantization parameters. */ reset(params: QParams3d): void; /** Quantizes the supplied Point3d to this list's range and appends it to the list. */ add(pt: Point3d): void; /** Adds a previously-quantized point to this list. */ push(qpt: QPoint3d): void; /** The number of points in the list. */ get length(): number; /** Returns the unquantized value of the point at the specified index in the list. */ unquantize(index: number, out?: Point3d): Point3d; /** Changes the quantization parameters and requantizes all points in the list to the new range. * @note The loss of precision is compounded each time the points are requantized to a new range. */ requantize(params: QParams3d): void; /** Extracts the current contents of the list as a Uint16Array such that the first 3 elements contain the first point's x, y, and z components, * the second three elements contain the second point's components, and so on. */ toTypedArray(): Uint16Array; /** Reinitialize from a Uint16Array in which the first three elements specify the x, y, and z components of the first point, the second three elements specify the components * of the second point, and so on. */ fromTypedArray(range: Range3d, array: Uint16Array): void; /** Construct a list containing all points in the supplied list, quantized using the supplied parameters. */ static createFrom(points: Point3d[], params: QParams3d): QPoint3dList; /** An iterator over the points in the list. */ [Symbol.iterator](): IterableIterator; } //# sourceMappingURL=QPoint.d.ts.map