@itwin/core-geometry 4.0.0-dev.22 → 4.0.0-dev.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/Geometry.d.ts +23 -0
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +25 -1
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +195 -8
- package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/BarycentricTriangle.js +459 -11
- package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYCollection.d.ts +22 -7
- package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYCollection.js +41 -5
- package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +58 -4
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +102 -4
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +10 -0
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.js +14 -0
- package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +0 -6
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js +0 -6
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +2 -2
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +14 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +33 -1
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +120 -10
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +412 -12
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/polyface/FacetLocationDetail.d.ts +264 -0
- package/lib/cjs/polyface/FacetLocationDetail.d.ts.map +1 -0
- package/lib/cjs/polyface/FacetLocationDetail.js +378 -0
- package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -0
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +5 -2
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +20 -14
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +21 -17
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +22 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +52 -2
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/solid/Sphere.d.ts +5 -5
- package/lib/cjs/solid/Sphere.js +5 -5
- package/lib/cjs/solid/Sphere.js.map +1 -1
- package/lib/esm/Geometry.d.ts +23 -0
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +24 -0
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/geometry3d/BarycentricTriangle.d.ts +195 -8
- package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
- package/lib/esm/geometry3d/BarycentricTriangle.js +459 -12
- package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYCollection.d.ts +22 -7
- package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYCollection.js +41 -5
- package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +58 -4
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +103 -5
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +10 -0
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.js +14 -0
- package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +0 -6
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.js +0 -6
- package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +2 -2
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +14 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +33 -1
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +120 -10
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +411 -12
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/polyface/FacetLocationDetail.d.ts +264 -0
- package/lib/esm/polyface/FacetLocationDetail.d.ts.map +1 -0
- package/lib/esm/polyface/FacetLocationDetail.js +371 -0
- package/lib/esm/polyface/FacetLocationDetail.js.map +1 -0
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +5 -2
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +20 -14
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +21 -17
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +22 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +52 -2
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/solid/Sphere.d.ts +5 -5
- package/lib/esm/solid/Sphere.js +5 -5
- package/lib/esm/solid/Sphere.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Point3d, Vector3d } from "./Point3dVector3d";
|
|
1
|
+
import { Point3d, Vector3d, XYZ } from "./Point3dVector3d";
|
|
2
2
|
import { Range3d } from "./Range";
|
|
3
3
|
import { XYAndZ } from "./XYZProps";
|
|
4
4
|
/**
|
|
5
5
|
* abstract base class for read-only access to XYZ data with indexed reference.
|
|
6
6
|
* * This allows algorithms to work with Point3d[] or GrowableXYZ.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* * In addition to "point by point" accessors,
|
|
7
|
+
* * GrowableXYZArray implements these for its data.
|
|
8
|
+
* * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.
|
|
9
|
+
* * In addition to "point by point" accessors, other abstract members compute commonly useful vector data "between points".
|
|
10
10
|
* * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
@@ -48,6 +48,30 @@ export declare abstract class IndexedXYZCollection {
|
|
|
48
48
|
* @returns undefined if index is out of bounds
|
|
49
49
|
*/
|
|
50
50
|
abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Return a vector from the point at `indexA` to `target`
|
|
53
|
+
* @param indexA index of point within the array
|
|
54
|
+
* @param target target for vector
|
|
55
|
+
* @param result caller-allocated vector.
|
|
56
|
+
* @returns undefined if index is out of bounds
|
|
57
|
+
*/
|
|
58
|
+
vectorIndexXYAndZ(indexA: number, target: XYAndZ, result?: Vector3d): Vector3d | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`.
|
|
61
|
+
* @param origin index of point within the array; origin of both vectors
|
|
62
|
+
* @param indexA index of point within the array; target of the first vector
|
|
63
|
+
* @param indexA index of point within the array; target of the second vector
|
|
64
|
+
* @returns undefined if index is out of bounds
|
|
65
|
+
*/
|
|
66
|
+
dotProductIndexIndexIndex(origin: number, indexA: number, indexB: number): number | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`.
|
|
69
|
+
* @param origin index of point within the array; origin of both vectors
|
|
70
|
+
* @param indexA index of point within the array; target of the first vector
|
|
71
|
+
* @param targetB target for second vector
|
|
72
|
+
* @returns undefined if index is out of bounds
|
|
73
|
+
*/
|
|
74
|
+
dotProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number | undefined;
|
|
51
75
|
/**
|
|
52
76
|
* Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`
|
|
53
77
|
* @param origin origin for vector
|
|
@@ -57,6 +81,15 @@ export declare abstract class IndexedXYZCollection {
|
|
|
57
81
|
* @returns undefined if either index is out of bounds
|
|
58
82
|
*/
|
|
59
83
|
abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`
|
|
86
|
+
* @param origin index of point within the array; origin of both vectors
|
|
87
|
+
* @param indexA index of point within the array; target of the first vector
|
|
88
|
+
* @param targetB target of second vector
|
|
89
|
+
* @param result optional caller-allocated result to fill and return
|
|
90
|
+
* @returns undefined if an index is out of bounds
|
|
91
|
+
*/
|
|
92
|
+
crossProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d | undefined;
|
|
60
93
|
/**
|
|
61
94
|
* Return the cross product of vectors from `origin` to points at `indexA` and `indexB`
|
|
62
95
|
* @param origin origin for vector
|
|
@@ -85,6 +118,12 @@ export declare abstract class IndexedXYZCollection {
|
|
|
85
118
|
* @param index1 second point index
|
|
86
119
|
*/
|
|
87
120
|
abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Return distance squared between the point at index0 and target.
|
|
123
|
+
* @param index0 first point index
|
|
124
|
+
* @param target second point
|
|
125
|
+
*/
|
|
126
|
+
distanceSquaredIndexXYAndZ(index0: number, target: XYAndZ): number | undefined;
|
|
88
127
|
/**
|
|
89
128
|
* Return distance between indicated points.
|
|
90
129
|
* @param index0 first point index
|
|
@@ -104,6 +143,21 @@ export declare abstract class IndexedXYZCollection {
|
|
|
104
143
|
* * No action if index is out of bounds.
|
|
105
144
|
*/
|
|
106
145
|
abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void;
|
|
146
|
+
/** Compute the linear combination s of the indexed p_i and given scales s_i.
|
|
147
|
+
* @param scales array of scales. For best results, scales should have same length as the instance.
|
|
148
|
+
* @param result optional pre-allocated object to fill and return
|
|
149
|
+
* @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length).
|
|
150
|
+
*/
|
|
151
|
+
linearCombination(scales: number[], result?: Point3d | Vector3d): XYZ;
|
|
152
|
+
/**
|
|
153
|
+
* Interpolate the points at the given indices.
|
|
154
|
+
* @param index0 index of point p0 within the array
|
|
155
|
+
* @param fraction fraction f such that returned point is p0 + f * (p1 - p0)
|
|
156
|
+
* @param index1 index of point p1 within the array
|
|
157
|
+
* @param result optional caller-allocated result to fill and return
|
|
158
|
+
* @returns undefined if an index is out of bounds
|
|
159
|
+
*/
|
|
160
|
+
interpolateIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d | undefined;
|
|
107
161
|
/** access x of indexed point */
|
|
108
162
|
abstract getXAtUncheckedPointIndex(pointIndex: number): number;
|
|
109
163
|
/** access y of indexed point */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedXYZCollection.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/IndexedXYZCollection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"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8 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module ArraysAndInterfaces
|
|
7
7
|
*/
|
|
8
|
-
// import { Point2d } from "./Geometry2d";
|
|
9
8
|
import { Geometry } from "../Geometry";
|
|
10
|
-
import { Point3d } from "./Point3dVector3d";
|
|
9
|
+
import { Point3d, Vector3d } from "./Point3dVector3d";
|
|
11
10
|
import { Range3d } from "./Range";
|
|
12
11
|
class PointsIterator {
|
|
13
12
|
constructor(collection) {
|
|
@@ -29,13 +28,84 @@ class PointsIterator {
|
|
|
29
28
|
/**
|
|
30
29
|
* abstract base class for read-only access to XYZ data with indexed reference.
|
|
31
30
|
* * This allows algorithms to work with Point3d[] or GrowableXYZ.
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* * In addition to "point by point" accessors,
|
|
31
|
+
* * GrowableXYZArray implements these for its data.
|
|
32
|
+
* * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.
|
|
33
|
+
* * In addition to "point by point" accessors, other abstract members compute commonly useful vector data "between points".
|
|
35
34
|
* * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.
|
|
36
35
|
* @public
|
|
37
36
|
*/
|
|
38
37
|
export class IndexedXYZCollection {
|
|
38
|
+
/**
|
|
39
|
+
* Return a vector from the point at `indexA` to `target`
|
|
40
|
+
* @param indexA index of point within the array
|
|
41
|
+
* @param target target for vector
|
|
42
|
+
* @param result caller-allocated vector.
|
|
43
|
+
* @returns undefined if index is out of bounds
|
|
44
|
+
*/
|
|
45
|
+
vectorIndexXYAndZ(indexA, target, result) {
|
|
46
|
+
const reversed = this.vectorXYAndZIndex(target, indexA, result);
|
|
47
|
+
return reversed === null || reversed === void 0 ? void 0 : reversed.negate(reversed);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`.
|
|
51
|
+
* @param origin index of point within the array; origin of both vectors
|
|
52
|
+
* @param indexA index of point within the array; target of the first vector
|
|
53
|
+
* @param indexA index of point within the array; target of the second vector
|
|
54
|
+
* @returns undefined if index is out of bounds
|
|
55
|
+
*/
|
|
56
|
+
dotProductIndexIndexIndex(origin, indexA, indexB) {
|
|
57
|
+
if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length || indexB < 0 || indexB >= this.length)
|
|
58
|
+
return undefined;
|
|
59
|
+
const x0 = this.getXAtUncheckedPointIndex(origin);
|
|
60
|
+
const y0 = this.getYAtUncheckedPointIndex(origin);
|
|
61
|
+
const z0 = this.getZAtUncheckedPointIndex(origin);
|
|
62
|
+
return (this.getXAtUncheckedPointIndex(indexA) - x0) * (this.getXAtUncheckedPointIndex(indexB) - x0) +
|
|
63
|
+
(this.getYAtUncheckedPointIndex(indexA) - y0) * (this.getYAtUncheckedPointIndex(indexB) - y0) +
|
|
64
|
+
(this.getZAtUncheckedPointIndex(indexA) - z0) * (this.getZAtUncheckedPointIndex(indexB) - z0);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`.
|
|
68
|
+
* @param origin index of point within the array; origin of both vectors
|
|
69
|
+
* @param indexA index of point within the array; target of the first vector
|
|
70
|
+
* @param targetB target for second vector
|
|
71
|
+
* @returns undefined if index is out of bounds
|
|
72
|
+
*/
|
|
73
|
+
dotProductIndexIndexXYAndZ(origin, indexA, targetB) {
|
|
74
|
+
if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)
|
|
75
|
+
return undefined;
|
|
76
|
+
const x0 = this.getXAtUncheckedPointIndex(origin);
|
|
77
|
+
const y0 = this.getYAtUncheckedPointIndex(origin);
|
|
78
|
+
const z0 = this.getZAtUncheckedPointIndex(origin);
|
|
79
|
+
return (this.getXAtUncheckedPointIndex(indexA) - x0) * (targetB.x - x0) +
|
|
80
|
+
(this.getYAtUncheckedPointIndex(indexA) - y0) * (targetB.y - y0) +
|
|
81
|
+
(this.getZAtUncheckedPointIndex(indexA) - z0) * (targetB.z - z0);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`
|
|
85
|
+
* @param origin index of point within the array; origin of both vectors
|
|
86
|
+
* @param indexA index of point within the array; target of the first vector
|
|
87
|
+
* @param targetB target of second vector
|
|
88
|
+
* @param result optional caller-allocated result to fill and return
|
|
89
|
+
* @returns undefined if an index is out of bounds
|
|
90
|
+
*/
|
|
91
|
+
crossProductIndexIndexXYAndZ(origin, indexA, targetB, result) {
|
|
92
|
+
if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)
|
|
93
|
+
return undefined;
|
|
94
|
+
const x0 = this.getXAtUncheckedPointIndex(origin);
|
|
95
|
+
const y0 = this.getYAtUncheckedPointIndex(origin);
|
|
96
|
+
const z0 = this.getZAtUncheckedPointIndex(origin);
|
|
97
|
+
return Vector3d.createCrossProduct(this.getXAtUncheckedPointIndex(indexA) - x0, this.getYAtUncheckedPointIndex(indexA) - y0, this.getZAtUncheckedPointIndex(indexA) - z0, targetB.x - x0, targetB.y - y0, targetB.z - z0, result);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Return distance squared between the point at index0 and target.
|
|
101
|
+
* @param index0 first point index
|
|
102
|
+
* @param target second point
|
|
103
|
+
*/
|
|
104
|
+
distanceSquaredIndexXYAndZ(index0, target) {
|
|
105
|
+
if (index0 < 0 || index0 >= this.length)
|
|
106
|
+
return undefined;
|
|
107
|
+
return Geometry.hypotenuseSquaredXYZ(target.x - this.getXAtUncheckedPointIndex(index0), target.y - this.getYAtUncheckedPointIndex(index0), target.z - this.getZAtUncheckedPointIndex(index0));
|
|
108
|
+
}
|
|
39
109
|
/** Adjust index into range by modulo with the length. */
|
|
40
110
|
cyclicIndex(i) {
|
|
41
111
|
return (i % this.length);
|
|
@@ -73,6 +143,34 @@ export class IndexedXYZCollection {
|
|
|
73
143
|
}
|
|
74
144
|
return indices;
|
|
75
145
|
}
|
|
146
|
+
/** Compute the linear combination s of the indexed p_i and given scales s_i.
|
|
147
|
+
* @param scales array of scales. For best results, scales should have same length as the instance.
|
|
148
|
+
* @param result optional pre-allocated object to fill and return
|
|
149
|
+
* @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length).
|
|
150
|
+
*/
|
|
151
|
+
linearCombination(scales, result) {
|
|
152
|
+
const n = Math.min(this.length, scales.length);
|
|
153
|
+
const sum = (result instanceof Vector3d) ? Vector3d.createZero(result) : Point3d.createZero(result);
|
|
154
|
+
for (let i = 0; i < n; ++i) {
|
|
155
|
+
sum.x += scales[i] * this.getXAtUncheckedPointIndex(i);
|
|
156
|
+
sum.y += scales[i] * this.getYAtUncheckedPointIndex(i);
|
|
157
|
+
sum.z += scales[i] * this.getZAtUncheckedPointIndex(i);
|
|
158
|
+
}
|
|
159
|
+
return sum;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Interpolate the points at the given indices.
|
|
163
|
+
* @param index0 index of point p0 within the array
|
|
164
|
+
* @param fraction fraction f such that returned point is p0 + f * (p1 - p0)
|
|
165
|
+
* @param index1 index of point p1 within the array
|
|
166
|
+
* @param result optional caller-allocated result to fill and return
|
|
167
|
+
* @returns undefined if an index is out of bounds
|
|
168
|
+
*/
|
|
169
|
+
interpolateIndexIndex(index0, fraction, index1, result) {
|
|
170
|
+
if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)
|
|
171
|
+
return undefined;
|
|
172
|
+
return Point3d.create(Geometry.interpolate(this.getXAtUncheckedPointIndex(index0), fraction, this.getXAtUncheckedPointIndex(index1)), Geometry.interpolate(this.getYAtUncheckedPointIndex(index0), fraction, this.getYAtUncheckedPointIndex(index1)), Geometry.interpolate(this.getZAtUncheckedPointIndex(index0), fraction, this.getZAtUncheckedPointIndex(index1)), result);
|
|
173
|
+
}
|
|
76
174
|
/** Return iterator over the points in this collection. Usage:
|
|
77
175
|
* ```ts
|
|
78
176
|
* for (const point: Point3d of collection.points) { ... }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedXYZCollection.js","sourceRoot":"","sources":["../../../src/geometry3d/IndexedXYZCollection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,0CAA0C;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,MAAM,cAAc;IAIlB,YAAmB,UAAgC;QAF3C,cAAS,GAAG,CAAC,CAAC,CAAC;QAGrB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAEM,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;YAC/C,0JAA0J;YAC1J,OAAO,EAAE,IAAI,EAAE,IAAI,EAAoC,CAAC;SACzD;QAED,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,IAAI,CAAC,SAAS,CAAC;YACvE,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAwB,OAAO,IAAI,CAAC,CAAC,CAAC;CAC/D;AACD;;;;;;;;GAQG;AACH,MAAM,OAAgB,oBAAoB;IAoFxC,yDAAyD;IAClD,WAAW,CAAC,CAAS;QAC1B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,sCAAsC;IAC/B,QAAQ;QACb,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,C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,oBAAoB;CAsB/E","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module ArraysAndInterfaces\r\n */\r\n\r\n// import { Point2d } from \"./Geometry2d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\nclass PointsIterator implements Iterator<Point3d>, Iterable<Point3d> {\r\n private readonly _collection: IndexedXYZCollection;\r\n private _curIndex = -1;\r\n\r\n public constructor(collection: IndexedXYZCollection) {\r\n this._collection = collection;\r\n }\r\n\r\n public next(): IteratorResult<Point3d> {\r\n if (++this._curIndex >= this._collection.length) {\r\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\r\n return { done: true } as any as IteratorResult<Point3d>;\r\n }\r\n\r\n return {\r\n value: this._collection.getPoint3dAtUncheckedPointIndex(this._curIndex),\r\n done: false,\r\n };\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<Point3d> { return this; }\r\n}\r\n/**\r\n * abstract base class for read-only access to XYZ data with indexed reference.\r\n * * This allows algorithms to work with Point3d[] or GrowableXYZ.\r\n * ** GrowableXYZArray implements these for its data.\r\n * ** Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.\r\n * * In addition to \"point by point\" accessors, there abstract members compute commonly useful vector data \"between points\".\r\n * * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.\r\n * @public\r\n */\r\nexport abstract class IndexedXYZCollection {\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined;\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d, without checking the point index validity.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d;\r\n /**\r\n * Get from `index` as a strongly typed Vector3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from the point at `indexA` to the point at `indexB`\r\n * @param indexA index of point within the array\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from `origin` to the point at `indexB`\r\n * @param origin origin for vector\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n\r\n /**\r\n * Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result optional caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of vectors from origin point at `indexA` to target points at `indexB` and `indexC`\r\n * @param origin index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public abstract accumulateCrossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result: Vector3d): void;\r\n\r\n /**\r\n * read-only property for number of XYZ in the collection.\r\n */\r\n public abstract get length(): number;\r\n /**\r\n * Return distance squared between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;\r\n /**\r\n * Return distance between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceIndexIndex(index0: number, index1: number): number | undefined;\r\n\r\n /** Adjust index into range by modulo with the length. */\r\n public cyclicIndex(i: number): number {\r\n return (i % this.length);\r\n }\r\n /** Return the range of the points. */\r\n public getRange(): Range3d {\r\n const range = Range3d.createNull();\r\n const n = this.length;\r\n const point = Point3d.create();\r\n for (let i = 0; i < n; i++) {\r\n this.getPoint3dAtUncheckedPointIndex(i, point);\r\n range.extendPoint(point);\r\n }\r\n return range;\r\n }\r\n\r\n /**\r\n * For each run of points with indices i+1 to i+n within distance tolerance of points[i], return the indices i+1, ..., i+n.\r\n * @return ordered array of 0-based indices of duplicate points\r\n */\r\n public findOrderedDuplicates(tolerance: number = Geometry.smallMetricDistance): number[] {\r\n const tol2 = tolerance * tolerance;\r\n const indices: number[] = [];\r\n if (this.length > 1) {\r\n for (let i = 0; i < this.length - 1;) {\r\n let j = i + 1;\r\n for (; j < this.length; ++j) {\r\n const dist2 = this.distanceSquaredIndexIndex(i, j);\r\n if (dist2 !== undefined && dist2 < tol2)\r\n indices.push(j);\r\n else\r\n break;\r\n }\r\n i = j; // found next unique point\r\n }\r\n }\r\n return indices;\r\n }\r\n\r\n /** Accumulate scale times the x,y,z values at index.\r\n * * No action if index is out of bounds.\r\n */\r\n public abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void;\r\n\r\n /** access x of indexed point */\r\n public abstract getXAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access y of indexed point */\r\n public abstract getYAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access z of indexed point */\r\n public abstract getZAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** Return iterator over the points in this collection. Usage:\r\n * ```ts\r\n * for (const point: Point3d of collection.points) { ... }\r\n * ```\r\n */\r\n public get points(): Iterable<Point3d> {\r\n return new PointsIterator(this);\r\n }\r\n /** convert to Point3d[] */\r\n public getArray(): Point3d[] {\r\n const result = [];\r\n for (const p of this.points)\r\n result.push(p);\r\n return result;\r\n }\r\n}\r\n/**\r\n * abstract base class extends IndexedXYZCollection, adding methods to push, peek, and pop, and rewrite.\r\n * @public\r\n */\r\nexport abstract class IndexedReadWriteXYZCollection extends IndexedXYZCollection {\r\n /** push a (clone of) point onto the collection\r\n * * point itself is not pushed -- xyz data is extracted into the native form of the collection.\r\n */\r\n public abstract push(data: XYAndZ): void;\r\n /**\r\n * push a new point (given by coordinates) onto the collection\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n */\r\n public abstract pushXYZ(x?: number, y?: number, z?: number): void;\r\n /** extract the final point */\r\n public abstract back(result?: Point3d): Point3d | undefined;\r\n /** extract the first point */\r\n public abstract front(result?: Point3d): Point3d | undefined;\r\n /** remove the final point. */\r\n public abstract pop(): void;\r\n /** clear all entries */\r\n public abstract clear(): void;\r\n /** reverse the points in place. */\r\n public abstract reverseInPlace(): void;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IndexedXYZCollection.js","sourceRoot":"","sources":["../../../src/geometry3d/IndexedXYZCollection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,QAAQ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AAE,QAAQ,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAC9G,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAC9G,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChJ,CAAC;IAWD;;;;OAIG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,2BAA2B;IACpB,QAAQ;QACb,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM;YACzB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,6BAA8B,SAAQ,oBAAoB;CAsB/E","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module ArraysAndInterfaces\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Point3d, Vector3d, XYZ } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\nclass PointsIterator implements Iterator<Point3d>, Iterable<Point3d> {\r\n private readonly _collection: IndexedXYZCollection;\r\n private _curIndex = -1;\r\n\r\n public constructor(collection: IndexedXYZCollection) {\r\n this._collection = collection;\r\n }\r\n\r\n public next(): IteratorResult<Point3d> {\r\n if (++this._curIndex >= this._collection.length) {\r\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\r\n return { done: true } as any as IteratorResult<Point3d>;\r\n }\r\n\r\n return {\r\n value: this._collection.getPoint3dAtUncheckedPointIndex(this._curIndex),\r\n done: false,\r\n };\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<Point3d> { return this; }\r\n}\r\n/**\r\n * abstract base class for read-only access to XYZ data with indexed reference.\r\n * * This allows algorithms to work with Point3d[] or GrowableXYZ.\r\n * * GrowableXYZArray implements these for its data.\r\n * * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.\r\n * * In addition to \"point by point\" accessors, other abstract members compute commonly useful vector data \"between points\".\r\n * * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.\r\n * @public\r\n */\r\nexport abstract class IndexedXYZCollection {\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined;\r\n /**\r\n * Return the point at `index` as a strongly typed Point3d, without checking the point index validity.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d;\r\n /**\r\n * Get from `index` as a strongly typed Vector3d.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public abstract getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from the point at `indexA` to the point at `indexB`\r\n * @param indexA index of point within the array\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from `origin` to the point at `indexB`\r\n * @param origin origin for vector\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return a vector from the point at `indexA` to `target`\r\n * @param indexA index of point within the array\r\n * @param target target for vector\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public vectorIndexXYAndZ(indexA: number, target: XYAndZ, result?: Vector3d): Vector3d | undefined {\r\n const reversed = this.vectorXYAndZIndex(target, indexA, result);\r\n return reversed?.negate(reversed);\r\n }\r\n /**\r\n * Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`.\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param indexA index of point within the array; target of the second vector\r\n * @returns undefined if index is out of bounds\r\n */\r\n public dotProductIndexIndexIndex(origin: number, indexA: number, indexB: number): number | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length || indexB < 0 || indexB >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (this.getXAtUncheckedPointIndex(indexB) - x0) +\r\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (this.getYAtUncheckedPointIndex(indexB) - y0) +\r\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (this.getZAtUncheckedPointIndex(indexB) - z0);\r\n }\r\n /**\r\n * Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`.\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param targetB target for second vector\r\n * @returns undefined if index is out of bounds\r\n */\r\n public dotProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (targetB.x - x0) +\r\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (targetB.y - y0) +\r\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (targetB.z - z0);\r\n }\r\n /**\r\n * Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`\r\n * @param origin index of point within the array; origin of both vectors\r\n * @param indexA index of point within the array; target of the first vector\r\n * @param targetB target of second vector\r\n * @param result optional caller-allocated result to fill and return\r\n * @returns undefined if an index is out of bounds\r\n */\r\n public crossProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d | undefined {\r\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\r\n return undefined;\r\n const x0 = this.getXAtUncheckedPointIndex(origin);\r\n const y0 = this.getYAtUncheckedPointIndex(origin);\r\n const z0 = this.getZAtUncheckedPointIndex(origin);\r\n return Vector3d.createCrossProduct(this.getXAtUncheckedPointIndex(indexA) - x0,\r\n this.getYAtUncheckedPointIndex(indexA) - y0,\r\n this.getZAtUncheckedPointIndex(indexA) - z0,\r\n targetB.x - x0,\r\n targetB.y - y0,\r\n targetB.z - z0, result);\r\n }\r\n /**\r\n * Return the cross product of vectors from `origin` to points at `indexA` and `indexB`\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result optional caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public abstract crossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\r\n /**\r\n * Return the cross product of vectors from origin point at `indexA` to target points at `indexB` and `indexC`\r\n * @param origin index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public abstract accumulateCrossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result: Vector3d): void;\r\n\r\n /**\r\n * read-only property for number of XYZ in the collection.\r\n */\r\n public abstract get length(): number;\r\n /**\r\n * Return distance squared between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;\r\n /**\r\n * Return distance squared between the point at index0 and target.\r\n * @param index0 first point index\r\n * @param target second point\r\n */\r\n public distanceSquaredIndexXYAndZ(index0: number, target: XYAndZ): number | undefined {\r\n if (index0 < 0 || index0 >= this.length)\r\n return undefined;\r\n return Geometry.hypotenuseSquaredXYZ(\r\n target.x - this.getXAtUncheckedPointIndex(index0),\r\n target.y - this.getYAtUncheckedPointIndex(index0),\r\n target.z - this.getZAtUncheckedPointIndex(index0));\r\n }\r\n /**\r\n * Return distance between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public abstract distanceIndexIndex(index0: number, index1: number): number | undefined;\r\n\r\n /** Adjust index into range by modulo with the length. */\r\n public cyclicIndex(i: number): number {\r\n return (i % this.length);\r\n }\r\n /** Return the range of the points. */\r\n public getRange(): Range3d {\r\n const range = Range3d.createNull();\r\n const n = this.length;\r\n const point = Point3d.create();\r\n for (let i = 0; i < n; i++) {\r\n this.getPoint3dAtUncheckedPointIndex(i, point);\r\n range.extendPoint(point);\r\n }\r\n return range;\r\n }\r\n\r\n /**\r\n * For each run of points with indices i+1 to i+n within distance tolerance of points[i], return the indices i+1, ..., i+n.\r\n * @return ordered array of 0-based indices of duplicate points\r\n */\r\n public findOrderedDuplicates(tolerance: number = Geometry.smallMetricDistance): number[] {\r\n const tol2 = tolerance * tolerance;\r\n const indices: number[] = [];\r\n if (this.length > 1) {\r\n for (let i = 0; i < this.length - 1;) {\r\n let j = i + 1;\r\n for (; j < this.length; ++j) {\r\n const dist2 = this.distanceSquaredIndexIndex(i, j);\r\n if (dist2 !== undefined && dist2 < tol2)\r\n indices.push(j);\r\n else\r\n break;\r\n }\r\n i = j; // found next unique point\r\n }\r\n }\r\n return indices;\r\n }\r\n\r\n /** Accumulate scale times the x,y,z values at index.\r\n * * No action if index is out of bounds.\r\n */\r\n public abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void;\r\n\r\n /** Compute the linear combination s of the indexed p_i and given scales s_i.\r\n * @param scales array of scales. For best results, scales should have same length as the instance.\r\n * @param result optional pre-allocated object to fill and return\r\n * @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length).\r\n */\r\n public linearCombination(scales: number[], result?: Point3d | Vector3d): XYZ {\r\n const n = Math.min(this.length, scales.length);\r\n const sum = (result instanceof Vector3d) ? Vector3d.createZero(result) : Point3d.createZero(result);\r\n for (let i = 0; i < n; ++i) {\r\n sum.x += scales[i] * this.getXAtUncheckedPointIndex(i);\r\n sum.y += scales[i] * this.getYAtUncheckedPointIndex(i);\r\n sum.z += scales[i] * this.getZAtUncheckedPointIndex(i);\r\n }\r\n return sum;\r\n }\r\n\r\n /**\r\n * Interpolate the points at the given indices.\r\n * @param index0 index of point p0 within the array\r\n * @param fraction fraction f such that returned point is p0 + f * (p1 - p0)\r\n * @param index1 index of point p1 within the array\r\n * @param result optional caller-allocated result to fill and return\r\n * @returns undefined if an index is out of bounds\r\n */\r\n public interpolateIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d | undefined {\r\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\r\n return undefined;\r\n return Point3d.create(Geometry.interpolate(this.getXAtUncheckedPointIndex(index0), fraction, this.getXAtUncheckedPointIndex(index1)),\r\n Geometry.interpolate(this.getYAtUncheckedPointIndex(index0), fraction, this.getYAtUncheckedPointIndex(index1)),\r\n Geometry.interpolate(this.getZAtUncheckedPointIndex(index0), fraction, this.getZAtUncheckedPointIndex(index1)), result);\r\n }\r\n\r\n /** access x of indexed point */\r\n public abstract getXAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access y of indexed point */\r\n public abstract getYAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** access z of indexed point */\r\n public abstract getZAtUncheckedPointIndex(pointIndex: number): number;\r\n\r\n /** Return iterator over the points in this collection. Usage:\r\n * ```ts\r\n * for (const point: Point3d of collection.points) { ... }\r\n * ```\r\n */\r\n public get points(): Iterable<Point3d> {\r\n return new PointsIterator(this);\r\n }\r\n /** convert to Point3d[] */\r\n public getArray(): Point3d[] {\r\n const result = [];\r\n for (const p of this.points)\r\n result.push(p);\r\n return result;\r\n }\r\n}\r\n/**\r\n * abstract base class extends IndexedXYZCollection, adding methods to push, peek, and pop, and rewrite.\r\n * @public\r\n */\r\nexport abstract class IndexedReadWriteXYZCollection extends IndexedXYZCollection {\r\n /** push a (clone of) point onto the collection\r\n * * point itself is not pushed -- xyz data is extracted into the native form of the collection.\r\n */\r\n public abstract push(data: XYAndZ): void;\r\n /**\r\n * push a new point (given by coordinates) onto the collection\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n */\r\n public abstract pushXYZ(x?: number, y?: number, z?: number): void;\r\n /** extract the final point */\r\n public abstract back(result?: Point3d): Point3d | undefined;\r\n /** extract the first point */\r\n public abstract front(result?: Point3d): Point3d | undefined;\r\n /** remove the final point. */\r\n public abstract pop(): void;\r\n /** clear all entries */\r\n public abstract clear(): void;\r\n /** reverse the points in place. */\r\n public abstract reverseInPlace(): void;\r\n}\r\n"]}
|
|
@@ -71,5 +71,15 @@ export declare class Point2dArrayCarrier extends IndexedXYCollection {
|
|
|
71
71
|
* read-only property for number of XYZ in the collection.
|
|
72
72
|
*/
|
|
73
73
|
get length(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Get x coordinate by point index, with no index checking
|
|
76
|
+
* @param pointIndex index to access
|
|
77
|
+
*/
|
|
78
|
+
getXAtUncheckedPointIndex(pointIndex: number): number;
|
|
79
|
+
/**
|
|
80
|
+
* Get y coordinate by point index, with no index checking
|
|
81
|
+
* @param pointIndex index to access
|
|
82
|
+
*/
|
|
83
|
+
getYAtUncheckedPointIndex(pointIndex: number): number;
|
|
74
84
|
}
|
|
75
85
|
//# sourceMappingURL=Point2dArrayCarrier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point2dArrayCarrier.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Point2dArrayCarrier.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAM,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;EAME;AACF,qBAAa,mBAAoB,SAAQ,mBAAmB;IAC1D,wCAAwC;IACjC,IAAI,EAAE,OAAO,EAAE,CAAC;IACvB,wCAAwC;gBACrB,IAAI,EAAE,OAAO,EAAE;IAIlC,8BAA8B;IACvB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAG3C;;;;;;OAMG;
|
|
1
|
+
{"version":3,"file":"Point2dArrayCarrier.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Point2dArrayCarrier.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAA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AAM;CAGtE"}
|
|
@@ -108,5 +108,19 @@ export class Point2dArrayCarrier extends IndexedXYCollection {
|
|
|
108
108
|
get length() {
|
|
109
109
|
return this.data.length;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Get x coordinate by point index, with no index checking
|
|
113
|
+
* @param pointIndex index to access
|
|
114
|
+
*/
|
|
115
|
+
getXAtUncheckedPointIndex(pointIndex) {
|
|
116
|
+
return this.data[pointIndex].x;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get y coordinate by point index, with no index checking
|
|
120
|
+
* @param pointIndex index to access
|
|
121
|
+
*/
|
|
122
|
+
getYAtUncheckedPointIndex(pointIndex) {
|
|
123
|
+
return this.data[pointIndex].y;
|
|
124
|
+
}
|
|
111
125
|
}
|
|
112
126
|
//# sourceMappingURL=Point2dArrayCarrier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point2dArrayCarrier.js","sourceRoot":"","sources":["../../../src/geometry3d/Point2dArrayCarrier.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,mEAAmE;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAG1D;;;;;;EAME;AACF,MAAM,OAAO,mBAAoB,SAAQ,mBAAmB;IAG1D,wCAAwC;IACxC,YAAmB,IAAe;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,8BAA8B;IACvB,YAAY,CAAC,KAAa;QAC/B,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAChD,CAAC;IACD;;;;;;OAMG;
|
|
1
|
+
{"version":3,"file":"Point2dArrayCarrier.js","sourceRoot":"","sources":["../../../src/geometry3d/Point2d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F,OAAO,SAAS,CAAC;IACnB,CAAC;IACD;;OAEG;IACH,IAAoB,MAAM;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACa,yBAAyB,CAAC,UAAkB;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED;;;OAGG;IACa,yBAAyB,CAAC,UAAkB;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\n\r\nimport { IndexedXYCollection } from \"./IndexedXYCollection\";\r\nimport { Point2d, Vector2d, XY } from \"./Point2dVector2d\";\r\nimport { XAndY } from \"./XYZProps\";\r\n\r\n/**\r\n * Helper object to access members of a Point2d[] in geometric calculations.\r\n * * The collection holds only a reference to the actual array.\r\n * * The actual array may be replaced by the user as needed.\r\n * * When replaced, there is no cached data to be updated.\r\n * @public\r\n*/\r\nexport class Point2dArrayCarrier extends IndexedXYCollection {\r\n /** reference to array being queried. */\r\n public data: Point2d[];\r\n /** CAPTURE caller supplied array ... */\r\n public constructor(data: Point2d[]) {\r\n super();\r\n this.data = data;\r\n }\r\n /** test if index is valid */\r\n public isValidIndex(index: number): boolean {\r\n return index >= 0 && index < this.data.length;\r\n }\r\n /**\r\n * Access by index, returning strongly typed Point2d\r\n * * This returns the xy value but NOT reference to the point in the \"carried\" array.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public override getPoint2dAtCheckedPointIndex(index: number, result?: Point2d): Point2d | undefined {\r\n if (this.isValidIndex(index)) {\r\n const source = this.data[index];\r\n return Point2d.create(source.x, source.y, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Access by index, returning strongly typed Vector2d\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public override getVector2dAtCheckedVectorIndex(index: number, result?: Vector2d): Vector2d | undefined {\r\n if (this.isValidIndex(index)) {\r\n const source = this.data[index];\r\n return Vector2d.create(source.x, source.y, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return a vector from the point at indexA to the point at indexB\r\n * @param indexA index of point within the array\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public override vectorIndexIndex(indexA: number, indexB: number, result?: Vector2d): Vector2d | undefined {\r\n if (this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return Vector2d.createStartEnd(this.data[indexA], this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Return a vector from given origin to point at indexB\r\n * @param origin origin for vector\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public override vectorXAndYIndex(origin: XAndY, indexB: number, result?: Vector2d): Vector2d | undefined {\r\n if (this.isValidIndex(indexB))\r\n return Vector2d.createStartEnd(origin, this.data[indexB], result);\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Return the cross product of vectors from origin to points at indexA and indexB\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public override crossProductXAndYIndexIndex(origin: XAndY, indexA: number, indexB: number): number | undefined {\r\n if (this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return XY.crossProductToPoints(origin, this.data[indexA], this.data[indexB]);\r\n return undefined;\r\n }\r\n /**\r\n * Return the cross product of vectors from point at originIndex to points at indexA and indexB\r\n * @param originIndex index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public override crossProductIndexIndexIndex(originIndex: number, indexA: number, indexB: number): number | undefined {\r\n if (this.isValidIndex(originIndex) && this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return XY.crossProductToPoints(this.data[originIndex], this.data[indexA], this.data[indexB]);\r\n return undefined;\r\n }\r\n /**\r\n * read-only property for number of XYZ in the collection.\r\n */\r\n public override get length(): number {\r\n return this.data.length;\r\n }\r\n\r\n /**\r\n * Get x coordinate by point index, with no index checking\r\n * @param pointIndex index to access\r\n */\r\n public override getXAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].x;\r\n }\r\n\r\n /**\r\n * Get y coordinate by point index, with no index checking\r\n * @param pointIndex index to access\r\n */\r\n public override getYAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].y;\r\n }\r\n}\r\n"]}
|
|
@@ -31,7 +31,6 @@ export declare class Point3dArrayCarrier extends IndexedReadWriteXYZCollection {
|
|
|
31
31
|
* * This returns the xyz value but NOT reference to the point in the "carried" array.
|
|
32
32
|
* @param index index of point within the array
|
|
33
33
|
* @param result caller-allocated destination
|
|
34
|
-
* @returns undefined if the index is out of bounds
|
|
35
34
|
*/
|
|
36
35
|
getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d;
|
|
37
36
|
/**
|
|
@@ -131,19 +130,14 @@ export declare class Point3dArrayCarrier extends IndexedReadWriteXYZCollection {
|
|
|
131
130
|
reverseInPlace(): void;
|
|
132
131
|
/**
|
|
133
132
|
* Return distance squared between indicated points.
|
|
134
|
-
* * Concrete classes may be able to implement this without creating a temporary.
|
|
135
133
|
* @param index0 first point index
|
|
136
134
|
* @param index1 second point index
|
|
137
|
-
* @param defaultDistanceSquared distance squared to return if either point index is invalid.
|
|
138
|
-
*
|
|
139
135
|
*/
|
|
140
136
|
distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;
|
|
141
137
|
/**
|
|
142
138
|
* Return distance between indicated points.
|
|
143
|
-
* * Concrete classes may be able to implement this without creating a temporary.
|
|
144
139
|
* @param index0 first point index
|
|
145
140
|
* @param index1 second point index
|
|
146
|
-
* @param defaultDistanceSquared distance squared to return if either point index is invalid.
|
|
147
141
|
*/
|
|
148
142
|
distanceIndexIndex(index0: number, index1: number): number | undefined;
|
|
149
143
|
/** Adjust index into range by modulo with the length. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point3dArrayCarrier.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Point3dArrayCarrier.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,6BAA6B;IACpE,wCAAwC;IACjC,IAAI,EAAE,OAAO,EAAE,CAAC;IACvB,wCAAwC;gBACrB,IAAI,EAAE,OAAO,EAAE;IAIlC,uDAAuD;IAChD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAG3C;;;;;;OAMG;IACI,6BAA6B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IAO1F
|
|
1
|
+
{"version":3,"file":"Point3dArrayCarrier.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Point3dArrayCarrier.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;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
|
* * This returns the xyz value but NOT reference to the point in the "carried" array.
|
|
44
44
|
* @param index index of point within the array
|
|
45
45
|
* @param result caller-allocated destination
|
|
46
|
-
* @returns undefined if the index is out of bounds
|
|
47
46
|
*/
|
|
48
47
|
getPoint3dAtUncheckedPointIndex(index, result) {
|
|
49
48
|
const source = this.data[index];
|
|
@@ -208,11 +207,8 @@ export class Point3dArrayCarrier extends IndexedReadWriteXYZCollection {
|
|
|
208
207
|
}
|
|
209
208
|
/**
|
|
210
209
|
* Return distance squared between indicated points.
|
|
211
|
-
* * Concrete classes may be able to implement this without creating a temporary.
|
|
212
210
|
* @param index0 first point index
|
|
213
211
|
* @param index1 second point index
|
|
214
|
-
* @param defaultDistanceSquared distance squared to return if either point index is invalid.
|
|
215
|
-
*
|
|
216
212
|
*/
|
|
217
213
|
distanceSquaredIndexIndex(index0, index1) {
|
|
218
214
|
const n = this.data.length;
|
|
@@ -223,10 +219,8 @@ export class Point3dArrayCarrier extends IndexedReadWriteXYZCollection {
|
|
|
223
219
|
}
|
|
224
220
|
/**
|
|
225
221
|
* Return distance between indicated points.
|
|
226
|
-
* * Concrete classes may be able to implement this without creating a temporary.
|
|
227
222
|
* @param index0 first point index
|
|
228
223
|
* @param index1 second point index
|
|
229
|
-
* @param defaultDistanceSquared distance squared to return if either point index is invalid.
|
|
230
224
|
*/
|
|
231
225
|
distanceIndexIndex(index0, index1) {
|
|
232
226
|
const n = this.data.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point3dArrayCarrier.js","sourceRoot":"","sources":["../../../src/geometry3d/Point3dArrayCarrier.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;;GAMG;AACH,MAAM,OAAO,mBAAoB,SAAQ,6BAA6B;IAGpE,wCAA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,SAAS,CAAC;IACnB,CAAC;IACD,yDAAyD;IACzC,WAAW,CAAC,CAAS;QACnC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ArraysAndInterfaces\r\n */\r\n\r\nimport { IndexedReadWriteXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n/**\r\n * Helper object to access members of a Point3d[] in geometric calculations.\r\n * * The collection holds only a reference to the actual array.\r\n * * The actual array may be replaced by the user as needed.\r\n * * When replaced, there is no cached data to be updated.\r\n * @public\r\n */\r\nexport class Point3dArrayCarrier extends IndexedReadWriteXYZCollection {\r\n /** reference to array being queried. */\r\n public data: Point3d[];\r\n /** CAPTURE caller supplied array ... */\r\n public constructor(data: Point3d[]) {\r\n super();\r\n this.data = data;\r\n }\r\n /** test if `index` is a valid index into the array. */\r\n public isValidIndex(index: number): boolean {\r\n return index >= 0 && index < this.data.length;\r\n }\r\n /**\r\n * Access by index, returning strongly typed Point3d\r\n * * This returns the xyz value but NOT reference to the point in the \"carried\" array.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined {\r\n if (this.isValidIndex(index)) {\r\n const source = this.data[index];\r\n return Point3d.create(source.x, source.y, source.z, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Access by index, returning strongly typed Point3d\r\n * * This returns the xyz value but NOT reference to the point in the \"carried\" array.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d {\r\n const source = this.data[index];\r\n return Point3d.create(source.x, source.y, source.z, result);\r\n }\r\n /**\r\n * Access by index, returning strongly typed Vector3d\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(index)) {\r\n const source = this.data[index];\r\n return Vector3d.create(source.x, source.y, source.z, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * access x of indexed point\r\n * * WARNING: make sure `pointIndex` is a valid index, otherwise, you get random results\r\n * */\r\n public getXAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].x;\r\n }\r\n /**\r\n * access y of indexed point\r\n * * WARNING: make sure `pointIndex` is a valid index, otherwise, you get random results\r\n * */\r\n public getYAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].y;\r\n }\r\n /**\r\n * access z of indexed point\r\n * * WARNING: make sure `pointIndex` is a valid index, otherwise, you get random results\r\n * */\r\n public getZAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].z;\r\n }\r\n /**\r\n * Return a vector from the point at indexA to the point at indexB\r\n * @param indexA index of point within the array\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return Vector3d.createStartEnd(this.data[indexA], this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Return a vector from given origin to point at indexB\r\n * @param origin origin for vector\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(indexB))\r\n return Vector3d.createStartEnd(origin, this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Return the cross product of vectors from origin to points at indexA and indexB\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return Vector3d.createCrossProductToPoints(origin, this.data[indexA], this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Return the cross product of vectors from point at originIndex to points at indexA and indexB\r\n * @param originIndex index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public crossProductIndexIndexIndex(originIndex: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(originIndex) && this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return Vector3d.createCrossProductToPoints(this.data[originIndex], this.data[indexA], this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Compute the cross product of vectors from point at originIndex to points at indexA and indexB, and accumulate it to the result.\r\n * @param origin index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public accumulateCrossProductIndexIndexIndex(originIndex: number, indexA: number, indexB: number, result: Vector3d): void {\r\n const data = this.data;\r\n if (this.isValidIndex(originIndex) && this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n result.addCrossProductToTargetsInPlace(\r\n data[originIndex].x, data[originIndex].y, data[originIndex].z,\r\n data[indexA].x, data[indexA].y, data[indexA].z,\r\n data[indexB].x, data[indexB].y, data[indexB].z\r\n );\r\n }\r\n /**\r\n * Accumulate scale times the x,y,z values at index to the sum.\r\n * No action if index is out of bounds.\r\n */\r\n public accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void {\r\n if (this.isValidIndex(index)) {\r\n const point = this.data[index];\r\n sum.x += scale * point.x;\r\n sum.y += scale * point.y;\r\n sum.z += scale * point.z;\r\n }\r\n }\r\n /**\r\n * read-only property for number of XYZ in the collection.\r\n */\r\n public get length(): number {\r\n return this.data.length;\r\n }\r\n /** push a (clone of) point onto the collection\r\n * * point itself is not pushed -- xyz data is extracted into the native form of the collection.\r\n */\r\n public push(data: Point3d): void {\r\n this.data.push(data.clone());\r\n }\r\n /**\r\n * push a new point (given by coordinates) onto the collection\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n */\r\n public pushXYZ(x?: number, y?: number, z?: number): void {\r\n this.data.push(\r\n Point3d.create(x === undefined ? 0.0 : x, y === undefined ? 0.0 : y, z === undefined ? 0.0 : z)\r\n );\r\n }\r\n /** extract (copy) the final point */\r\n public back(result?: Point3d): Point3d | undefined {\r\n if (this.data.length > 0) {\r\n return this.data[this.data.length - 1].clone(result);\r\n }\r\n return undefined;\r\n }\r\n /** extract (copy) the first point */\r\n public front(result?: Point3d): Point3d | undefined {\r\n if (this.data.length > 0) {\r\n return this.data[0].clone(result);\r\n }\r\n return undefined;\r\n }\r\n /** remove the final point. */\r\n public pop(): void {\r\n if (this.data.length > 0)\r\n this.data.pop();\r\n }\r\n /** remove all points. */\r\n public clear(): void {\r\n this.data.length = 0;\r\n }\r\n /** Reverse the points in place */\r\n public reverseInPlace(): void {\r\n this.data.reverse();\r\n }\r\n /**\r\n * Return distance squared between indicated points.\r\n * * Concrete classes may be able to implement this without creating a temporary.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n * @param defaultDistanceSquared distance squared to return if either point index is invalid.\r\n *\r\n */\r\n public distanceSquaredIndexIndex(index0: number, index1: number): number | undefined {\r\n const n = this.data.length;\r\n if (index0 >= 0 && index0 < n && index1 >= 0 && index1 < n) {\r\n return this.data[index0].distanceSquared(this.data[index1]);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return distance between indicated points.\r\n * * Concrete classes may be able to implement this without creating a temporary.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n * @param defaultDistanceSquared distance squared to return if either point index is invalid.\r\n */\r\n public distanceIndexIndex(index0: number, index1: number): number | undefined {\r\n const n = this.data.length;\r\n if (index0 >= 0 && index0 < n && index1 >= 0 && index1 < n) {\r\n return this.data[index0].distance(this.data[index1]);\r\n }\r\n return undefined;\r\n }\r\n /** Adjust index into range by modulo with the length. */\r\n public override cyclicIndex(i: number): number {\r\n return (i % this.data.length);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Point3dArrayCarrier.js","sourceRoot":"","sources":["../../../src/geometry3d/Point3dArrayCarrier.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;;GAMG;AACH,MAAM,OAAO,mBAAoB,SAAQ,6BAA6B;IAGpE,wCAAwC;IACxC,YAAmB,IAAe;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,uDAAuD;IAChD,YAAY,CAAC,KAAa;QAC/B,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAChD,CAAC;IACD;;;;;;OAMG;IACI,6BAA6B,CAAC,KAAa,EAAE,MAAgB;QAClE,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CA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AAC;IACD;;;;OAIG;IACI,yBAAyB,CAAC,MAAc,EAAE,MAAc;QAC7D,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE;YAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SAC7D;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD;;;;OAIG;IACI,kBAAkB,CAAC,MAAc,EAAE,MAAc;QACtD,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE;YAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SACtD;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,yDAAyD;IACzC,WAAW,CAAC,CAAS;QACnC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ArraysAndInterfaces\r\n */\r\n\r\nimport { IndexedReadWriteXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n/**\r\n * Helper object to access members of a Point3d[] in geometric calculations.\r\n * * The collection holds only a reference to the actual array.\r\n * * The actual array may be replaced by the user as needed.\r\n * * When replaced, there is no cached data to be updated.\r\n * @public\r\n */\r\nexport class Point3dArrayCarrier extends IndexedReadWriteXYZCollection {\r\n /** reference to array being queried. */\r\n public data: Point3d[];\r\n /** CAPTURE caller supplied array ... */\r\n public constructor(data: Point3d[]) {\r\n super();\r\n this.data = data;\r\n }\r\n /** test if `index` is a valid index into the array. */\r\n public isValidIndex(index: number): boolean {\r\n return index >= 0 && index < this.data.length;\r\n }\r\n /**\r\n * Access by index, returning strongly typed Point3d\r\n * * This returns the xyz value but NOT reference to the point in the \"carried\" array.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined {\r\n if (this.isValidIndex(index)) {\r\n const source = this.data[index];\r\n return Point3d.create(source.x, source.y, source.z, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Access by index, returning strongly typed Point3d\r\n * * This returns the xyz value but NOT reference to the point in the \"carried\" array.\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n */\r\n public getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d {\r\n const source = this.data[index];\r\n return Point3d.create(source.x, source.y, source.z, result);\r\n }\r\n /**\r\n * Access by index, returning strongly typed Vector3d\r\n * @param index index of point within the array\r\n * @param result caller-allocated destination\r\n * @returns undefined if the index is out of bounds\r\n */\r\n public getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(index)) {\r\n const source = this.data[index];\r\n return Vector3d.create(source.x, source.y, source.z, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * access x of indexed point\r\n * * WARNING: make sure `pointIndex` is a valid index, otherwise, you get random results\r\n * */\r\n public getXAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].x;\r\n }\r\n /**\r\n * access y of indexed point\r\n * * WARNING: make sure `pointIndex` is a valid index, otherwise, you get random results\r\n * */\r\n public getYAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].y;\r\n }\r\n /**\r\n * access z of indexed point\r\n * * WARNING: make sure `pointIndex` is a valid index, otherwise, you get random results\r\n * */\r\n public getZAtUncheckedPointIndex(pointIndex: number): number {\r\n return this.data[pointIndex].z;\r\n }\r\n /**\r\n * Return a vector from the point at indexA to the point at indexB\r\n * @param indexA index of point within the array\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return Vector3d.createStartEnd(this.data[indexA], this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Return a vector from given origin to point at indexB\r\n * @param origin origin for vector\r\n * @param indexB index of point within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if index is out of bounds\r\n */\r\n public vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(indexB))\r\n return Vector3d.createStartEnd(origin, this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Return the cross product of vectors from origin to points at indexA and indexB\r\n * @param origin origin for vector\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns undefined if either index is out of bounds\r\n */\r\n public crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return Vector3d.createCrossProductToPoints(origin, this.data[indexA], this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Return the cross product of vectors from point at originIndex to points at indexA and indexB\r\n * @param originIndex index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public crossProductIndexIndexIndex(originIndex: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined {\r\n if (this.isValidIndex(originIndex) && this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n return Vector3d.createCrossProductToPoints(this.data[originIndex], this.data[indexA], this.data[indexB], result);\r\n return undefined;\r\n }\r\n /**\r\n * Compute the cross product of vectors from point at originIndex to points at indexA and indexB, and accumulate it to the result.\r\n * @param origin index of origin\r\n * @param indexA index of first target within the array\r\n * @param indexB index of second target within the array\r\n * @param result caller-allocated vector.\r\n * @returns return true if indexA, indexB both valid\r\n */\r\n public accumulateCrossProductIndexIndexIndex(originIndex: number, indexA: number, indexB: number, result: Vector3d): void {\r\n const data = this.data;\r\n if (this.isValidIndex(originIndex) && this.isValidIndex(indexA) && this.isValidIndex(indexB))\r\n result.addCrossProductToTargetsInPlace(\r\n data[originIndex].x, data[originIndex].y, data[originIndex].z,\r\n data[indexA].x, data[indexA].y, data[indexA].z,\r\n data[indexB].x, data[indexB].y, data[indexB].z\r\n );\r\n }\r\n /**\r\n * Accumulate scale times the x,y,z values at index to the sum.\r\n * No action if index is out of bounds.\r\n */\r\n public accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void {\r\n if (this.isValidIndex(index)) {\r\n const point = this.data[index];\r\n sum.x += scale * point.x;\r\n sum.y += scale * point.y;\r\n sum.z += scale * point.z;\r\n }\r\n }\r\n /**\r\n * read-only property for number of XYZ in the collection.\r\n */\r\n public get length(): number {\r\n return this.data.length;\r\n }\r\n /** push a (clone of) point onto the collection\r\n * * point itself is not pushed -- xyz data is extracted into the native form of the collection.\r\n */\r\n public push(data: Point3d): void {\r\n this.data.push(data.clone());\r\n }\r\n /**\r\n * push a new point (given by coordinates) onto the collection\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n */\r\n public pushXYZ(x?: number, y?: number, z?: number): void {\r\n this.data.push(\r\n Point3d.create(x === undefined ? 0.0 : x, y === undefined ? 0.0 : y, z === undefined ? 0.0 : z)\r\n );\r\n }\r\n /** extract (copy) the final point */\r\n public back(result?: Point3d): Point3d | undefined {\r\n if (this.data.length > 0) {\r\n return this.data[this.data.length - 1].clone(result);\r\n }\r\n return undefined;\r\n }\r\n /** extract (copy) the first point */\r\n public front(result?: Point3d): Point3d | undefined {\r\n if (this.data.length > 0) {\r\n return this.data[0].clone(result);\r\n }\r\n return undefined;\r\n }\r\n /** remove the final point. */\r\n public pop(): void {\r\n if (this.data.length > 0)\r\n this.data.pop();\r\n }\r\n /** remove all points. */\r\n public clear(): void {\r\n this.data.length = 0;\r\n }\r\n /** Reverse the points in place */\r\n public reverseInPlace(): void {\r\n this.data.reverse();\r\n }\r\n /**\r\n * Return distance squared between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public distanceSquaredIndexIndex(index0: number, index1: number): number | undefined {\r\n const n = this.data.length;\r\n if (index0 >= 0 && index0 < n && index1 >= 0 && index1 < n) {\r\n return this.data[index0].distanceSquared(this.data[index1]);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return distance between indicated points.\r\n * @param index0 first point index\r\n * @param index1 second point index\r\n */\r\n public distanceIndexIndex(index0: number, index1: number): number | undefined {\r\n const n = this.data.length;\r\n if (index0 >= 0 && index0 < n && index1 >= 0 && index1 < n) {\r\n return this.data[index0].distance(this.data[index1]);\r\n }\r\n return undefined;\r\n }\r\n /** Adjust index into range by modulo with the length. */\r\n public override cyclicIndex(i: number): number {\r\n return (i % this.data.length);\r\n }\r\n}\r\n"]}
|
|
@@ -460,7 +460,7 @@ export declare class Vector3d extends XYZ {
|
|
|
460
460
|
/** Return a vector same length as this but rotated 90 degrees clockwise */
|
|
461
461
|
rotate90CWXY(result?: Vector3d): Vector3d;
|
|
462
462
|
/**
|
|
463
|
-
* Return a vector which is in the xy plane, perpendicular
|
|
463
|
+
* Return a vector which is in the xy plane, perpendicular to the xy part of this vector, and of unit length.
|
|
464
464
|
* * If the xy part is 00, the return is the rotated (but not normalized) xy parts of this vector.
|
|
465
465
|
* @param result optional preallocated result.
|
|
466
466
|
*/
|
|
@@ -248,7 +248,7 @@ export class XYZ {
|
|
|
248
248
|
setAt(index, value) {
|
|
249
249
|
if (index < 0.5)
|
|
250
250
|
this.x = value;
|
|
251
|
-
if (index > 1.5)
|
|
251
|
+
else if (index > 1.5)
|
|
252
252
|
this.z = value;
|
|
253
253
|
else
|
|
254
254
|
this.y = value;
|
|
@@ -934,7 +934,7 @@ export class Vector3d extends XYZ {
|
|
|
934
934
|
return result;
|
|
935
935
|
}
|
|
936
936
|
/**
|
|
937
|
-
* Return a vector which is in the xy plane, perpendicular
|
|
937
|
+
* Return a vector which is in the xy plane, perpendicular to the xy part of this vector, and of unit length.
|
|
938
938
|
* * If the xy part is 00, the return is the rotated (but not normalized) xy parts of this vector.
|
|
939
939
|
* @param result optional preallocated result.
|
|
940
940
|
*/
|