/** @packageDocumentation * @module ArraysAndInterfaces */ import { PlaneAltitudeEvaluator } from "../Geometry"; import { Point3d, Vector3d, XYZ } from "./Point3dVector3d"; import { Range3d } from "./Range"; import { Transform } from "./Transform"; import { XAndY, XYAndZ } from "./XYZProps"; /** * Abstract base class for read-only access to XYZ data with indexed reference. * * This allows algorithms to work with Point3d[] or [[GrowableXYZArray]]. * * GrowableXYZArray implements these for its data. * * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference. * * In addition to "point by point" accessors, other abstract members compute commonly useful vector data "between points". * * Methods that create vectors among multiple indices allow callers to avoid creating temporaries. * @public */ export declare abstract class IndexedXYZCollection { /** * Return the point at `index` as a strongly typed Point3d. * @param index index of point within the array. * @param result caller-allocated destination. * @returns undefined if the index is out of bounds. */ abstract getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined; /** * Return the point at `index` as a strongly typed Point3d, without checking the point index validity. * * Use [[getPoint3dAtCheckedPointIndex]] to have index validity test. * @param index index of point within the array. * @param result caller-allocated destination. */ abstract getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d; /** * Get from `index` as a strongly typed Vector3d. * @param index index of point within the array. * @param result caller-allocated destination. * @returns undefined if the index is out of bounds. */ abstract getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined; /** * Return a vector from the point at `indexA` to the point at `indexB`. * @param indexA index of point within the array. * @param indexB index of point within the array. * @param result caller-allocated vector. * @returns undefined if either index is out of bounds. */ abstract vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined; /** * Return a vector from the point at `indexA` to the point at `indexB`. * * This method does not check for index validity. Use [[vectorIndexIndex]] to have validity test. * @param indexA index of point within the array. * @param indexB index of point within the array. * @param result caller-allocated vector. */ vectorUncheckedIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d; /** * Return a vector from `origin` to the point at `indexB`. * @param origin origin for vector. * @param indexB index of point within the array. * @param result caller-allocated vector. * @returns undefined if index is out of bounds. */ abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined; /** * Return a vector from `origin` to the point at `indexB`. * * This method does not check for index validity. Use [[vectorXYAndZIndex]] to have validity test. * @param origin origin for vector. * @param indexB index of point within the array. * @param result caller-allocated vector. */ vectorXYAndZUncheckedIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d; /** * Return a vector from the point at `indexA` to `target`. * @param indexA index of point within the array. * @param target target for vector. * @param result caller-allocated vector. * @returns undefined if index is out of bounds. */ vectorIndexXYAndZ(indexA: number, target: XYAndZ, result?: Vector3d): Vector3d | undefined; /** * Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`. * @param origin index of point within the array; origin of both vectors. * @param indexA index of point within the array; target of the first vector. * @param indexB index of point within the array; target of the second vector. * @returns undefined if index is out of bounds. */ dotProductIndexIndexIndex(origin: number, indexA: number, indexB: number): number | undefined; /** * Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`. * @param origin index of point within the array; origin of both vectors. * @param indexA index of point within the array; target of the first vector. * @param targetB target for second vector. * @returns undefined if index is out of bounds. */ dotProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number | undefined; /** * Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`. * * This method does not check for index validity. Use [[dotProductIndexIndexXYAndZ]] to have validity test. * @param origin index of point within the array; origin of both vectors. * @param indexA index of point within the array; target of the first vector. * @param targetB target for second vector. */ dotProductUncheckedIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number; /** * Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`. * @param origin origin for vector. * @param indexA index of first target within the array. * @param indexB index of second target within the array. * @param result caller-allocated vector. * @returns undefined if either index is out of bounds. */ abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined; /** * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`. * @param origin index of point within the array; origin of both vectors. * @param indexA index of point within the array; target of the first vector. * @param targetB target of second vector. * @param result optional caller-allocated result to fill and return. * @returns undefined if an index is out of bounds. */ crossProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d | undefined; /** * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB. * * This method does not check for index validity. Use [[crossProductIndexIndexXYAndZ]] to have validity test. * @param origin index of point within the array; origin of both vectors. * @param indexA index of point within the array; target of the first vector. * @param targetB target of second vector. * @param result optional caller-allocated result to fill and return. */ crossProductUncheckedIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d; /** * Return the cross product of vectors from `origin` to points at `indexA` and `indexB`. * @param origin origin for vector. * @param indexA index of first target within the array. * @param indexB index of second target within the array. * @param result optional caller-allocated vector. * @returns undefined if either index is out of bounds. */ abstract crossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined; /** * Return the cross product of vectors from the point at `origin` to points at `indexA` and `indexB`. * * This method does not check for index validity. Use [[crossProductIndexIndexIndex]] to have validity test. * @param origin origin for vector. * @param indexA index of first target within the array. * @param indexB index of second target within the array. * @param result optional caller-allocated vector. */ crossProductUncheckedIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d; /** * Compute the cross product from indexed `origin` to targets at indices `indexA` and `indexB`, and add it to `result`. * @param origin index of origin. * @param indexA index of first target within the array. * @param indexB index of second target within the array. * @param result caller-allocated vector. */ abstract accumulateCrossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result: Vector3d): void; /** Read-only property for number of XYZ in the collection. */ abstract get length(): number; /** * Return distance squared between indicated points. * @param index0 first point index. * @param index1 second point index. */ abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined; /** * Return distance squared between indicated points. * * This method does not check for index validity. Use [[distanceSquaredIndexIndex]] to have validity test. * @param index0 first point index. * @param index1 second point index. */ distanceSquaredUncheckedIndexIndex(index0: number, index1: number): number; /** * Return distance squared between the point at index0 and target. * @param index0 first point index. * @param target second point. */ distanceSquaredIndexXYAndZ(index0: number, target: XYAndZ): number | undefined; /** * Return distance squared between the point at index0 and target. * * This method does not check for index validity. Use [[distanceSquaredIndexXYAndZ]] to have validity test. * @param index0 first point index. * @param target second point. */ distanceSquaredUncheckedIndexXYAndZ(index0: number, target: XYAndZ): number; /** * Return distance between indicated points. * @param index0 first point index. * @param index1 second point index. */ abstract distanceIndexIndex(index0: number, index1: number): number | undefined; /** * Return distance between indicated points. * * This method does not check for index validity. Use [[distanceIndexIndex]] to have validity test. * @param index0 first point index. * @param index1 second point index. */ distanceUncheckedIndexIndex(index0: number, index1: number): number; /** * Test if index is valid for an xyz within this array. * @param index xyz index to test. */ isIndexValid(index: number): boolean; /** Adjust index into range by modulo with the length. */ cyclicIndex(i: number): number; /** Return the range of the points. */ getRange(transform?: Transform, result?: Range3d): Range3d; /** * For each subset of `k` successive points within tolerance of the first point in the subset, return the indices of * the last `k-1` duplicates. * * Index `0` is never returned. * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]]). * @param preserveLast if the last `k < this.length` points of the instance are duplicates, whether to return the * indices of the *first* `k-1` duplicates for this last run. If true, index `this.length - 1` is not returned. * unless all points are duplicates, in which case all indices but `0` are returned. Default value is false. * @return ordered array of 0-based indices of duplicate points */ findOrderedDuplicates(tolerance?: number, preserveLast?: boolean): number[]; /** * Accumulate scale times the x,y,z values at index. * * No action if index is out of bounds. */ abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void; /** * Compute the linear combination s of the indexed p_i and given scales s_i. * @param scales array of scales. For best results, scales should have same length as the instance. * @param result optional pre-allocated object to fill and return * @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length). */ linearCombination(scales: number[], result?: Point3d | Vector3d): XYZ; /** * Interpolate the points at the given indices. * @param index0 index of point p0 within the array. * @param fraction fraction f such that returned point is p0 + f * (p1 - p0). * @param index1 index of point p1 within the array. * @param result optional caller-allocated result to fill and return. * @returns undefined if an index is out of bounds. */ interpolateIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d | undefined; /** * Interpolate the points at the given indices. * * This method does not check for index validity. Use [[interpolateIndexIndex]] to have validity test. * @param index0 index of point p0 within the array. * @param fraction fraction f such that returned point is p0 + f * (p1 - p0). * @param index1 index of point p1 within the array. * @param result optional caller-allocated result to fill and return. */ interpolateUncheckedIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d; /** Access x of indexed point. */ abstract getXAtUncheckedPointIndex(pointIndex: number): number; /** Access y of indexed point. */ abstract getYAtUncheckedPointIndex(pointIndex: number): number; /** Access z of indexed point. */ abstract getZAtUncheckedPointIndex(pointIndex: number): number; /** * Return iterator over the points in this collection. Usage: * ```ts * for (const point: Point3d of collection.points) { ... } * ``` */ get points(): Iterable; /** Convert to Point3d[]. */ getArray(): Point3d[]; /** Return the first point, or undefined if the array is empty. */ front(result?: Point3d): Point3d | undefined; /** Return the last point, or undefined if the array is empty. */ back(result?: Point3d): Point3d | undefined; /** * Test whether the indexed points are equal within tolerance. * @param index0 index of first point. * @param index1 index of second point. * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`. * @returns whether the points are equal within tolerance, or `undefined` if either index is invalid. */ almostEqualIndexIndex(index0: number, index1: number, tolerance?: number): boolean | undefined; /** * Test whether the indexed points are equal within tolerance. * * This method does not check for index validity. Use [[almostEqualIndexIndex]] to have validity test. * @param index0 index of first point. * @param index1 index of second point. * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`. * @returns whether the points are equal within tolerance. */ almostEqualUncheckedIndexIndex(index0: number, index1: number, tolerance?: number): boolean; /** * Test whether the xy-coordinates of the indexed points are equal within tolerance. The z-coordinates are ignored. * @param index0 index of first point. * @param index1 index of second point. * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`. * @returns whether the xy-coordinates of the points are equal within tolerance, or `undefined` if either index is invalid. */ almostEqualXYIndexIndex(index0: number, index1: number, tolerance?: number): boolean | undefined; /** * Test whether the xy-coordinates of the indexed points are equal within tolerance. The z-coordinates are ignored. * * This method does not check for index validity. Use [[almostEqualXYIndexIndex]] to have validity test. * @param index0 index of first point. * @param index1 index of second point. * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`. * @returns whether the xy-coordinates of the points are equal within tolerance. */ almostEqualXYUncheckedIndexIndex(index0: number, index1: number, tolerance?: number): boolean; /** Return the altitude of the indexed point from the plane. */ evaluateUncheckedIndexPlaneAltitude(pointIndex: number, plane: PlaneAltitudeEvaluator): number; } /** * Abstract base class extends [[IndexedXYZCollection]] with methods that modify the collection. * @public */ export declare abstract class IndexedReadWriteXYZCollection extends IndexedXYZCollection { /** Push a (clone of) point onto the collection. */ abstract push(point: XYAndZ): void; /** Push a new point (given by xyz coordinates) onto the collection. */ abstract pushXYZ(x?: number, y?: number, z?: number): void; /** Remove the final point. */ abstract pop(): void; /** Remove all entries. */ abstract clear(): void; /** Reverse the points in place. */ abstract reverseInPlace(): void; /** Push points from the source array to the end of this array and return the number of points pushed. */ pushIndexedXYZCollection(source: IndexedXYZCollection): number; } /** * Type for use as signature for xyz data of a single linestring appearing in a parameter list. * @public */ export type LineStringDataVariant = IndexedXYZCollection | XYAndZ[] | XAndY[] | number[][]; /** * Type for use as signature for multiple xyz data of multiple linestrings appearing in a parameter list. * @public */ export type MultiLineStringDataVariant = LineStringDataVariant | LineStringDataVariant[]; //# sourceMappingURL=IndexedXYZCollection.d.ts.map