@itwin/ecschema-rpcinterface-tests 4.0.0-dev.63 → 4.0.0-dev.68
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/dist/_d48c.bundled-tests.js.map +1 -1
- package/lib/dist/bundled-tests.js +590 -370
- package/lib/dist/bundled-tests.js.map +1 -1
- package/lib/dist/core_frontend_lib_esm_ApproximateTerrainHeightsProps_js.bundled-tests.js.map +1 -1
- package/lib/dist/object-storage.bundled-tests.js.map +1 -1
- package/lib/dist/vendors-common_temp_node_modules_pnpm_itwin_object-storage-azure_1_5_0_node_modules_itwin_obj-e3e81d.bundled-tests.js.map +1 -1
- package/lib/dist/vendors-common_temp_node_modules_pnpm_loaders_gl_draco_3_3_1_node_modules_loaders_gl_draco_di-d3af41.bundled-tests.js.map +1 -1
- package/lib/dist/vendors-common_temp_node_modules_pnpm_reflect-metadata_0_1_13_node_modules_reflect-metadata_R-610cb3.bundled-tests.js.map +1 -1
- package/package.json +15 -15
|
@@ -59216,27 +59216,63 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
59216
59216
|
* @module Geometry
|
|
59217
59217
|
*/
|
|
59218
59218
|
|
|
59219
|
+
/*
|
|
59220
|
+
The following visualizes the contents of frustum.points, which is sent to computeFrustumPlanes().
|
|
59221
|
+
The below numbers are the indices into that array.
|
|
59222
|
+
|
|
59223
|
+
2----------3
|
|
59224
|
+
/| /|
|
|
59225
|
+
/ 0--------/-1
|
|
59226
|
+
6----------7 /
|
|
59227
|
+
| / | /
|
|
59228
|
+
|/ |/
|
|
59229
|
+
4__________5
|
|
59230
|
+
|
|
59231
|
+
0 = left bottom rear
|
|
59232
|
+
1 = right bottom rear
|
|
59233
|
+
2 = left top right
|
|
59234
|
+
3 = right top rear
|
|
59235
|
+
4 = left bottom front
|
|
59236
|
+
5 = right bottom front
|
|
59237
|
+
6 = left top front
|
|
59238
|
+
7 = right top front
|
|
59239
|
+
*/
|
|
59240
|
+
// Ordering of sub-arrays is: [origin, a, b]
|
|
59219
59241
|
const planePointIndices = [
|
|
59220
|
-
[1,
|
|
59221
|
-
[0,
|
|
59222
|
-
[2,
|
|
59223
|
-
[0,
|
|
59224
|
-
[0,
|
|
59225
|
-
|
|
59242
|
+
[1, 5, 3],
|
|
59243
|
+
[0, 2, 4],
|
|
59244
|
+
[2, 3, 6],
|
|
59245
|
+
[0, 4, 1],
|
|
59246
|
+
[0, 1, 2], // back
|
|
59247
|
+
// Skip front plane because it can be too small. Instead derive it from back plane.
|
|
59248
|
+
// Otherwise, it would be: [4, 6, 5]
|
|
59226
59249
|
];
|
|
59227
59250
|
function computeFrustumPlanes(frustum) {
|
|
59228
59251
|
const planes = [];
|
|
59229
59252
|
const points = frustum.points;
|
|
59230
59253
|
const expandPlaneDistance = 1e-6;
|
|
59254
|
+
let normal;
|
|
59231
59255
|
for (const indices of planePointIndices) {
|
|
59232
59256
|
const i0 = indices[0], i1 = indices[1], i2 = indices[2];
|
|
59233
|
-
|
|
59257
|
+
normal = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_0__.Vector3d.createCrossProductToPoints(points[i0], points[i1], points[i2]);
|
|
59234
59258
|
normal.normalizeInPlace();
|
|
59235
59259
|
const plane = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_0__.ClipPlane.createNormalAndDistance(normal, normal.dotProduct(points[i0]) - expandPlaneDistance);
|
|
59236
59260
|
if (!plane)
|
|
59237
59261
|
return [];
|
|
59238
59262
|
planes.push(plane);
|
|
59239
59263
|
}
|
|
59264
|
+
// Derive front plane from back plane due to fact that front plane can become very tiny and cause precision issues, resulting in zero frustum planes. Deriving the front plane from the rear rect resolves this problem.
|
|
59265
|
+
// The back plane was the last plane processed above, so we can just consult the current value of `normal`.
|
|
59266
|
+
if (undefined !== normal) {
|
|
59267
|
+
normal.negate(normal); // negate the back plane
|
|
59268
|
+
// NB: Below, we make sure we calculate the distance based on a point on the front rect, not the rear rect!
|
|
59269
|
+
const plane = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_0__.ClipPlane.createNormalAndDistance(normal, normal.dotProduct(points[4]) - expandPlaneDistance);
|
|
59270
|
+
if (!plane)
|
|
59271
|
+
return [];
|
|
59272
|
+
planes.push(plane);
|
|
59273
|
+
}
|
|
59274
|
+
else
|
|
59275
|
+
return [];
|
|
59240
59276
|
return planes;
|
|
59241
59277
|
}
|
|
59242
59278
|
// Scratch variable used by FrustumPlanes.computeContainment.
|
|
@@ -59252,6 +59288,7 @@ class FrustumPlanes {
|
|
|
59252
59288
|
}
|
|
59253
59289
|
/** Compute the six planes of the specified frustum.
|
|
59254
59290
|
* If the frustum is degenerate - that is, its points do not represent a truncated pyramid - then the returned `FrustumPlanes` will contain zero planes.
|
|
59291
|
+
* @note This method assumes that the front plane is parallel to the back plane.
|
|
59255
59292
|
* @see [[isValid]] to test this condition.
|
|
59256
59293
|
*/
|
|
59257
59294
|
static fromFrustum(frustum) {
|
|
@@ -59278,6 +59315,7 @@ class FrustumPlanes {
|
|
|
59278
59315
|
}
|
|
59279
59316
|
/** Recompute the planes from the specified frustum.
|
|
59280
59317
|
* @returns true upon success, or false if the input frustum was degenerate, in which case [[isValid]] will be `false`.
|
|
59318
|
+
* @note This method assumes that the front plane is parallel to the back plane.
|
|
59281
59319
|
*/
|
|
59282
59320
|
init(frustum) {
|
|
59283
59321
|
this._planes = computeFrustumPlanes(frustum);
|
|
@@ -173245,7 +173283,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
173245
173283
|
/**
|
|
173246
173284
|
* Enumeration of the 6 possible orderings of XYZ axis order
|
|
173247
173285
|
* * **Note:** There are 3 axis order with right hand system (XYZ = 0, YZX = 1, ZXY = 2) and 3 axis order with
|
|
173248
|
-
* left hand system (XZY = 4, YXZ = 5, ZYX = 6). Note that AxisOrder is encoding the handedness as well. Cross
|
|
173286
|
+
* left hand system (XZY = 4, YXZ = 5, ZYX = 6). Note that `AxisOrder` is encoding the handedness as well. Cross
|
|
173249
173287
|
* product of the i_th axis in an ordering (i=0,1,2), with the i+1_th in that ordering, will produce the i+2_th
|
|
173250
173288
|
* axis in that ordering.
|
|
173251
173289
|
* @public
|
|
@@ -173278,7 +173316,8 @@ var AxisIndex;
|
|
|
173278
173316
|
/** 2 axis is index 2 */
|
|
173279
173317
|
AxisIndex[AxisIndex["Z"] = 2] = "Z";
|
|
173280
173318
|
})(AxisIndex || (AxisIndex = {}));
|
|
173281
|
-
/**
|
|
173319
|
+
/**
|
|
173320
|
+
* Standard views. Used in `Matrix3d.createStandardViewAxes(index: StandardViewIndex, invert: boolean)`
|
|
173282
173321
|
* @public
|
|
173283
173322
|
*/
|
|
173284
173323
|
var StandardViewIndex;
|
|
@@ -173287,20 +173326,21 @@ var StandardViewIndex;
|
|
|
173287
173326
|
StandardViewIndex[StandardViewIndex["Top"] = 1] = "Top";
|
|
173288
173327
|
/** X to right, negative Y up */
|
|
173289
173328
|
StandardViewIndex[StandardViewIndex["Bottom"] = 2] = "Bottom";
|
|
173290
|
-
/**
|
|
173329
|
+
/** Negative Y to right, Z up */
|
|
173291
173330
|
StandardViewIndex[StandardViewIndex["Left"] = 3] = "Left";
|
|
173292
|
-
/**
|
|
173331
|
+
/** Y to right, Z up */
|
|
173293
173332
|
StandardViewIndex[StandardViewIndex["Right"] = 4] = "Right";
|
|
173294
173333
|
/** X to right, Z up */
|
|
173295
173334
|
StandardViewIndex[StandardViewIndex["Front"] = 5] = "Front";
|
|
173296
|
-
/**
|
|
173335
|
+
/** Negative X to right, Z up */
|
|
173297
173336
|
StandardViewIndex[StandardViewIndex["Back"] = 6] = "Back";
|
|
173298
|
-
/**
|
|
173337
|
+
/** Isometric: view towards origin from (-1,-1,1) */
|
|
173299
173338
|
StandardViewIndex[StandardViewIndex["Iso"] = 7] = "Iso";
|
|
173300
|
-
/**
|
|
173339
|
+
/** Right isometric: view towards origin from (1,-1,1) */
|
|
173301
173340
|
StandardViewIndex[StandardViewIndex["RightIso"] = 8] = "RightIso";
|
|
173302
173341
|
})(StandardViewIndex || (StandardViewIndex = {}));
|
|
173303
|
-
/**
|
|
173342
|
+
/**
|
|
173343
|
+
* Enumeration among choice for how a coordinate transformation should incorporate scaling.
|
|
173304
173344
|
* @public
|
|
173305
173345
|
*/
|
|
173306
173346
|
var AxisScaleSelect;
|
|
@@ -173312,7 +173352,8 @@ var AxisScaleSelect;
|
|
|
173312
173352
|
/** On each axis, the vector length matches he length of the corresponding edge of the range. */
|
|
173313
173353
|
AxisScaleSelect[AxisScaleSelect["NonUniformRangeContainment"] = 2] = "NonUniformRangeContainment";
|
|
173314
173354
|
})(AxisScaleSelect || (AxisScaleSelect = {}));
|
|
173315
|
-
/**
|
|
173355
|
+
/**
|
|
173356
|
+
* Enumeration of possible locations of a point in the plane of a polygon.
|
|
173316
173357
|
* @public
|
|
173317
173358
|
*/
|
|
173318
173359
|
var PolygonLocation;
|
|
@@ -173345,18 +173386,26 @@ var PolygonLocation;
|
|
|
173345
173386
|
* @public
|
|
173346
173387
|
*/
|
|
173347
173388
|
class Geometry {
|
|
173348
|
-
/** Test if absolute value of x is
|
|
173349
|
-
|
|
173389
|
+
/** Test if absolute value of x is large (larger than `Geometry.largeCoordinateResult`) */
|
|
173390
|
+
static isLargeCoordinateResult(x) {
|
|
173391
|
+
return x > this.largeCoordinateResult || x < -this.largeCoordinateResult;
|
|
173392
|
+
}
|
|
173393
|
+
/**
|
|
173394
|
+
* Test if absolute value of x is large (larger than `Geometry.largeCoordinateResult`).
|
|
173395
|
+
* @deprecated in 4.x. Use `isLargeCoordinateResult`.
|
|
173350
173396
|
*/
|
|
173351
173397
|
static isHugeCoordinate(x) {
|
|
173352
|
-
return
|
|
173398
|
+
return Geometry.isLargeCoordinateResult(x);
|
|
173353
173399
|
}
|
|
173354
|
-
/** Test if a number is odd
|
|
173355
|
-
*/
|
|
173400
|
+
/** Test if a number is odd */
|
|
173356
173401
|
static isOdd(x) {
|
|
173357
|
-
return (x & (0x01)) === 1;
|
|
173402
|
+
return (x & (0x01)) === 1; // bitwise operation
|
|
173358
173403
|
}
|
|
173359
|
-
/**
|
|
173404
|
+
/**
|
|
173405
|
+
* Correct distance to zero.
|
|
173406
|
+
* * If `distance` magnitude is `undefined` or smaller than `smallMetricDistance`, then return `replacement`
|
|
173407
|
+
* (or 0 if replacement is not passed). Otherwise return `distance`.
|
|
173408
|
+
*/
|
|
173360
173409
|
static correctSmallMetricDistance(distance, replacement = 0.0) {
|
|
173361
173410
|
if (distance === undefined || Math.abs(distance) < Geometry.smallMetricDistance) {
|
|
173362
173411
|
return replacement;
|
|
@@ -173364,64 +173413,119 @@ class Geometry {
|
|
|
173364
173413
|
return distance;
|
|
173365
173414
|
}
|
|
173366
173415
|
/**
|
|
173367
|
-
|
|
173368
|
-
|
|
173369
|
-
|
|
173370
|
-
|
|
173371
|
-
|
|
173416
|
+
* Correct `fraction` to `replacement` if `fraction` is undefined or too small.
|
|
173417
|
+
* @param fraction number to test
|
|
173418
|
+
* @param replacement value to return if `fraction` is too small
|
|
173419
|
+
* @returns `fraction` if its absolute value is at least `Geometry.smallFraction`; otherwise returns `replacement`
|
|
173420
|
+
*/
|
|
173421
|
+
static correctSmallFraction(fraction, replacement = 0.0) {
|
|
173422
|
+
if (fraction === undefined || Math.abs(fraction) < Geometry.smallFraction) {
|
|
173423
|
+
return replacement;
|
|
173424
|
+
}
|
|
173425
|
+
return fraction;
|
|
173372
173426
|
}
|
|
173373
173427
|
/**
|
|
173374
|
-
*
|
|
173375
|
-
*
|
|
173428
|
+
* Return the inverse of `distance`.
|
|
173429
|
+
* * If `distance` magnitude is smaller than `smallMetricDistance` (i.e. distance is large enough for safe division),
|
|
173430
|
+
* then return `1/distance`. Otherwise return `undefined`.
|
|
173376
173431
|
*/
|
|
173377
|
-
static
|
|
173378
|
-
return (Math.abs(
|
|
173432
|
+
static inverseMetricDistance(distance) {
|
|
173433
|
+
return (Math.abs(distance) <= Geometry.smallMetricDistance) ? undefined : 1.0 / distance;
|
|
173379
173434
|
}
|
|
173380
173435
|
/**
|
|
173381
|
-
*
|
|
173382
|
-
* `
|
|
173436
|
+
* Return the inverse of `distanceSquared`.
|
|
173437
|
+
* * If `distanceSquared ` magnitude is smaller than `smallMetricDistanceSquared` (i.e. distanceSquared is large
|
|
173438
|
+
* enough for safe division), then return `1/distanceSquared `. Otherwise return `undefined`.
|
|
173383
173439
|
*/
|
|
173384
|
-
static
|
|
173385
|
-
|
|
173386
|
-
return Math.abs(x - y) < Math.abs(tol);
|
|
173387
|
-
return Math.abs(x - y) < Geometry.smallMetricDistance;
|
|
173440
|
+
static inverseMetricDistanceSquared(distanceSquared) {
|
|
173441
|
+
return (Math.abs(distanceSquared) <= Geometry.smallMetricDistanceSquared) ? undefined : 1.0 / distanceSquared;
|
|
173388
173442
|
}
|
|
173389
|
-
/**
|
|
173443
|
+
/**
|
|
173444
|
+
* Boolean test for metric coordinate near-equality (i.e., if `x` and `y` are almost equal) using `tolerance`.
|
|
173445
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173446
|
+
*/
|
|
173447
|
+
static isSameCoordinate(x, y, tolerance = Geometry.smallMetricDistance) {
|
|
173448
|
+
let d = x - y;
|
|
173449
|
+
if (d < 0)
|
|
173450
|
+
d = -d;
|
|
173451
|
+
return d <= tolerance;
|
|
173452
|
+
}
|
|
173453
|
+
/**
|
|
173454
|
+
* Boolean test for metric coordinate near-equality (i.e., if `x` and `y` are almost equal) using
|
|
173455
|
+
* `tolerance = toleranceFactor * smallMetricDistance`
|
|
173456
|
+
* */
|
|
173390
173457
|
static isSameCoordinateWithToleranceFactor(x, y, toleranceFactor) {
|
|
173391
173458
|
return Geometry.isSameCoordinate(x, y, toleranceFactor * Geometry.smallMetricDistance);
|
|
173392
173459
|
}
|
|
173393
|
-
/**
|
|
173394
|
-
|
|
173460
|
+
/**
|
|
173461
|
+
* Boolean test for metric coordinate pair near-equality (i.e., if `x0` and `x1` are almost equal
|
|
173462
|
+
* and `y0` and `y1` are almost equal) using `tolerance`.
|
|
173463
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173464
|
+
*/
|
|
173465
|
+
static isSameCoordinateXY(x0, y0, x1, y1, tolerance = Geometry.smallMetricDistance) {
|
|
173395
173466
|
let d = x1 - x0;
|
|
173396
173467
|
if (d < 0)
|
|
173397
173468
|
d = -d;
|
|
173398
|
-
if (d >
|
|
173469
|
+
if (d > tolerance)
|
|
173399
173470
|
return false;
|
|
173400
173471
|
d = y1 - y0;
|
|
173401
173472
|
if (d < 0)
|
|
173402
173473
|
d = -d;
|
|
173403
|
-
return d
|
|
173404
|
-
}
|
|
173405
|
-
/**
|
|
173406
|
-
|
|
173407
|
-
|
|
173408
|
-
|
|
173409
|
-
|
|
173410
|
-
static
|
|
173411
|
-
|
|
173412
|
-
|
|
173413
|
-
|
|
173414
|
-
|
|
173415
|
-
|
|
173416
|
-
|
|
173417
|
-
|
|
173418
|
-
|
|
173419
|
-
|
|
173420
|
-
|
|
173421
|
-
|
|
173422
|
-
|
|
173423
|
-
|
|
173424
|
-
|
|
173474
|
+
return d <= tolerance;
|
|
173475
|
+
}
|
|
173476
|
+
/**
|
|
173477
|
+
* Boolean test for squared metric coordinate near-equality (i.e., if `sqrt(x)` and `sqrt(y)` are
|
|
173478
|
+
* almost equal) using `tolerance`.
|
|
173479
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173480
|
+
*/
|
|
173481
|
+
static isSameCoordinateSquared(x, y, tolerance = Geometry.smallMetricDistance) {
|
|
173482
|
+
return Math.abs(Math.sqrt(x) - Math.sqrt(y)) <= tolerance;
|
|
173483
|
+
}
|
|
173484
|
+
/**
|
|
173485
|
+
* Boolean test for small `dataA.distance(dataB)` within `tolerance`.
|
|
173486
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173487
|
+
*/
|
|
173488
|
+
static isSamePoint3d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
173489
|
+
return dataA.distance(dataB) <= tolerance;
|
|
173490
|
+
}
|
|
173491
|
+
/**
|
|
173492
|
+
* Boolean test for small xyz-distance within `tolerance`.
|
|
173493
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173494
|
+
* * Note that Point3d and Vector3d are both derived from XYZ, so this method tolerates mixed types.
|
|
173495
|
+
*/
|
|
173496
|
+
static isSameXYZ(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
173497
|
+
return dataA.distance(dataB) <= tolerance;
|
|
173498
|
+
}
|
|
173499
|
+
/**
|
|
173500
|
+
* Boolean test for small xy-distance (ignoring z) within `tolerance`.
|
|
173501
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173502
|
+
*/
|
|
173503
|
+
static isSamePoint3dXY(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
173504
|
+
return dataA.distanceXY(dataB) <= tolerance;
|
|
173505
|
+
}
|
|
173506
|
+
/**
|
|
173507
|
+
* Boolean test for small xyz-distance within `tolerance`.
|
|
173508
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173509
|
+
*/
|
|
173510
|
+
static isSameVector3d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
173511
|
+
return dataA.distance(dataB) <= tolerance;
|
|
173512
|
+
}
|
|
173513
|
+
/**
|
|
173514
|
+
* Boolean test for small xy-distance within `tolerance`.
|
|
173515
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173516
|
+
*/
|
|
173517
|
+
static isSamePoint2d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
173518
|
+
return dataA.distance(dataB) <= tolerance;
|
|
173519
|
+
}
|
|
173520
|
+
/**
|
|
173521
|
+
* Boolean test for small xy-distance within `tolerance`.
|
|
173522
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173523
|
+
*/
|
|
173524
|
+
static isSameVector2d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
173525
|
+
return dataA.distance(dataB) <= tolerance;
|
|
173526
|
+
}
|
|
173527
|
+
/**
|
|
173528
|
+
* Lexical comparison of (a.x, a.y) and (b.x, b.y) with x as first test and y as second (z is ignored).
|
|
173425
173529
|
* * This is appropriate for a horizontal sweep in the plane.
|
|
173426
173530
|
*/
|
|
173427
173531
|
static lexicalXYLessThan(a, b) {
|
|
@@ -173436,7 +173540,7 @@ class Geometry {
|
|
|
173436
173540
|
return 0;
|
|
173437
173541
|
}
|
|
173438
173542
|
/**
|
|
173439
|
-
* Lexical comparison of (a.x,a.y) (b.x,b.y) with y as first test
|
|
173543
|
+
* Lexical comparison of (a.x, a.y) and (b.x, b.y) with y as first test and x as second (z is ignored).
|
|
173440
173544
|
* * This is appropriate for a vertical sweep in the plane.
|
|
173441
173545
|
*/
|
|
173442
173546
|
static lexicalYXLessThan(a, b) {
|
|
@@ -173450,9 +173554,7 @@ class Geometry {
|
|
|
173450
173554
|
return 1;
|
|
173451
173555
|
return 0;
|
|
173452
173556
|
}
|
|
173453
|
-
/**
|
|
173454
|
-
* Lexical test, based on x first, y second, z third.
|
|
173455
|
-
*/
|
|
173557
|
+
/** Lexical comparison of (a.x, a.y, a.z) and (b.x, b.y, b.z) with x as first test, y as second, and z as third. */
|
|
173456
173558
|
static lexicalXYZLessThan(a, b) {
|
|
173457
173559
|
if (a.x < b.x)
|
|
173458
173560
|
return -1;
|
|
@@ -173468,19 +173570,21 @@ class Geometry {
|
|
|
173468
173570
|
return 1;
|
|
173469
173571
|
return 0;
|
|
173470
173572
|
}
|
|
173471
|
-
/**
|
|
173573
|
+
/**
|
|
173574
|
+
* Test if `value` is small compared to `smallFraction`.
|
|
173472
173575
|
* * This is appropriate if `value` is know to be a typical 0..1 fraction.
|
|
173473
173576
|
*/
|
|
173474
173577
|
static isSmallRelative(value) {
|
|
173475
|
-
return Math.abs(value) < Geometry.
|
|
173578
|
+
return Math.abs(value) < Geometry.smallFraction;
|
|
173476
173579
|
}
|
|
173477
173580
|
/** Test if `value` is small compared to `smallAngleRadians` */
|
|
173478
173581
|
static isSmallAngleRadians(value) {
|
|
173479
173582
|
return Math.abs(value) < Geometry.smallAngleRadians;
|
|
173480
173583
|
}
|
|
173481
|
-
/**
|
|
173482
|
-
*
|
|
173483
|
-
|
|
173584
|
+
/**
|
|
173585
|
+
* Returns `true` if both values are `undefined` or if both are defined and almost equal within tolerance.
|
|
173586
|
+
* If one is `undefined` and the other is not, then `false` is returned.
|
|
173587
|
+
*/
|
|
173484
173588
|
static isAlmostEqualOptional(a, b, tolerance) {
|
|
173485
173589
|
if (a !== undefined && b !== undefined) {
|
|
173486
173590
|
if (Math.abs(a - b) > tolerance)
|
|
@@ -173492,44 +173596,43 @@ class Geometry {
|
|
|
173492
173596
|
}
|
|
173493
173597
|
return true;
|
|
173494
173598
|
}
|
|
173495
|
-
/**
|
|
173496
|
-
*
|
|
173497
|
-
|
|
173498
|
-
|
|
173599
|
+
/**
|
|
173600
|
+
* Toleranced equality test using tolerance `tolerance * ( 1 + abs(a) + abs(b) )`.
|
|
173601
|
+
* * `Geometry.smallAngleRadians` is used if tolerance is `undefined`.
|
|
173602
|
+
*/
|
|
173603
|
+
static isAlmostEqualNumber(a, b, tolerance = Geometry.smallAngleRadians) {
|
|
173499
173604
|
const sumAbs = 1.0 + Math.abs(a) + Math.abs(b);
|
|
173500
|
-
return Math.abs(a - b) <=
|
|
173605
|
+
return Math.abs(a - b) <= tolerance * sumAbs;
|
|
173501
173606
|
}
|
|
173502
|
-
/**
|
|
173503
|
-
*
|
|
173504
|
-
|
|
173505
|
-
|
|
173506
|
-
|
|
173507
|
-
const
|
|
173508
|
-
return Math.abs(a.x - b.x) <=
|
|
173607
|
+
/**
|
|
173608
|
+
* Toleranced equality test using tolerance `tolerance * ( 1 + abs(a.x) + abs(a.y) + abs(b.x) + abs(b.y) )`.
|
|
173609
|
+
* * `Geometry.smallAngleRadians` is used if tolerance is `undefined`.
|
|
173610
|
+
*/
|
|
173611
|
+
static isAlmostEqualXAndY(a, b, tolerance = Geometry.smallAngleRadians) {
|
|
173612
|
+
const tol = tolerance * (1.0 + Math.abs(a.x) + Math.abs(b.x) + Math.abs(a.y) + Math.abs(b.y));
|
|
173613
|
+
return (Math.abs(a.x - b.x) <= tol) && (Math.abs(a.y - b.y) <= tol);
|
|
173509
173614
|
}
|
|
173510
173615
|
/**
|
|
173511
|
-
* Toleranced equality test
|
|
173512
|
-
*
|
|
173616
|
+
* Toleranced equality test using caller-supplied `tolerance`.
|
|
173617
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
173513
173618
|
*/
|
|
173514
|
-
static isDistanceWithinTol(distance,
|
|
173515
|
-
|
|
173516
|
-
return Math.abs(distance) <= Math.abs(tol);
|
|
173517
|
-
return Math.abs(distance) <= Geometry.smallMetricDistance;
|
|
173619
|
+
static isDistanceWithinTol(distance, tolerance = Geometry.smallMetricDistance) {
|
|
173620
|
+
return Math.abs(distance) <= tolerance;
|
|
173518
173621
|
}
|
|
173519
|
-
/** Toleranced equality test
|
|
173622
|
+
/** Toleranced equality test using `smallMetricDistance` tolerance. */
|
|
173520
173623
|
static isSmallMetricDistance(distance) {
|
|
173521
173624
|
return Math.abs(distance) <= Geometry.smallMetricDistance;
|
|
173522
173625
|
}
|
|
173523
|
-
/** Toleranced equality
|
|
173626
|
+
/** Toleranced equality test using `smallMetricDistanceSquared` tolerance. */
|
|
173524
173627
|
static isSmallMetricDistanceSquared(distanceSquared) {
|
|
173525
173628
|
return Math.abs(distanceSquared) <= Geometry.smallMetricDistanceSquared;
|
|
173526
173629
|
}
|
|
173527
173630
|
/**
|
|
173528
173631
|
* Return `axis modulo 3` with proper handling of negative indices
|
|
173529
173632
|
* ..., -3:x, -2:y, -1:z, 0:x, 1:y, 2:z, 3:x, 4:y, 5:z, 6:x, 7:y, 8:z, ...
|
|
173530
|
-
|
|
173633
|
+
*/
|
|
173531
173634
|
static cyclic3dAxis(axis) {
|
|
173532
|
-
/* Direct test for the most common cases
|
|
173635
|
+
/* Direct test for the most common cases to avoid more expensive modulo operation */
|
|
173533
173636
|
if (axis >= 0) {
|
|
173534
173637
|
if (axis < 3)
|
|
173535
173638
|
return axis;
|
|
@@ -173542,7 +173645,8 @@ class Geometry {
|
|
|
173542
173645
|
return j;
|
|
173543
173646
|
return 2 - ((-axis - 1) % 3);
|
|
173544
173647
|
}
|
|
173545
|
-
/**
|
|
173648
|
+
/**
|
|
173649
|
+
* Return the `AxisOrder` for which `axisIndex` is the first named axis.
|
|
173546
173650
|
* * `axisIndex === 0` returns `AxisOrder.XYZ`
|
|
173547
173651
|
* * `axisIndex === 1` returns `AxisOrder.YZX`
|
|
173548
173652
|
* * `axisIndex === 2` returns `AxisOrder.ZXY`
|
|
@@ -173556,32 +173660,55 @@ class Geometry {
|
|
|
173556
173660
|
return AxisOrder.ZXY;
|
|
173557
173661
|
return Geometry.axisIndexToRightHandedAxisOrder(Geometry.cyclic3dAxis(axisIndex));
|
|
173558
173662
|
}
|
|
173559
|
-
/** Return the largest
|
|
173560
|
-
static
|
|
173561
|
-
|
|
173663
|
+
/** Return the largest signed value among `a`, `b`, and `c` */
|
|
173664
|
+
static maxXYZ(a, b, c) {
|
|
173665
|
+
let max = a;
|
|
173666
|
+
if (b > max)
|
|
173667
|
+
max = b;
|
|
173668
|
+
if (c > max)
|
|
173669
|
+
max = c;
|
|
173670
|
+
return max;
|
|
173671
|
+
}
|
|
173672
|
+
/** Return the smallest signed value among `a`, `b`, and `c` */
|
|
173673
|
+
static minXYZ(a, b, c) {
|
|
173674
|
+
let min = a;
|
|
173675
|
+
if (b < min)
|
|
173676
|
+
min = b;
|
|
173677
|
+
if (c < min)
|
|
173678
|
+
min = c;
|
|
173679
|
+
return min;
|
|
173680
|
+
}
|
|
173681
|
+
/** Return the largest signed value among `a` and `b` */
|
|
173682
|
+
static maxXY(a, b) {
|
|
173683
|
+
let max = a;
|
|
173684
|
+
if (b > max)
|
|
173685
|
+
max = b;
|
|
173686
|
+
return max;
|
|
173562
173687
|
}
|
|
173563
|
-
/** Return the
|
|
173688
|
+
/** Return the smallest signed value among `a` and `b` */
|
|
173689
|
+
static minXY(a, b) {
|
|
173690
|
+
let min = a;
|
|
173691
|
+
if (b < min)
|
|
173692
|
+
min = b;
|
|
173693
|
+
return min;
|
|
173694
|
+
}
|
|
173695
|
+
/** Return the largest absolute value among `x`, `y`, and `z` */
|
|
173564
173696
|
static maxAbsXYZ(x, y, z) {
|
|
173565
173697
|
return Geometry.maxXYZ(Math.abs(x), Math.abs(y), Math.abs(z));
|
|
173566
173698
|
}
|
|
173567
|
-
/** Return the largest absolute
|
|
173699
|
+
/** Return the largest absolute value among `x` and `y` */
|
|
173568
173700
|
static maxAbsXY(x, y) {
|
|
173569
173701
|
return Geometry.maxXY(Math.abs(x), Math.abs(y));
|
|
173570
173702
|
}
|
|
173571
|
-
/** Return the largest
|
|
173572
|
-
static
|
|
173573
|
-
|
|
173574
|
-
if (b > q)
|
|
173575
|
-
q = b;
|
|
173576
|
-
if (c > q)
|
|
173577
|
-
q = c;
|
|
173578
|
-
return q;
|
|
173703
|
+
/** Return the largest absolute distance from `a` to either of `b0` or `b1` */
|
|
173704
|
+
static maxAbsDiff(a, b0, b1) {
|
|
173705
|
+
return Math.max(Math.abs(a - b0), Math.abs(a - b1));
|
|
173579
173706
|
}
|
|
173580
173707
|
/**
|
|
173581
|
-
* Examine the
|
|
173582
|
-
* * If x is negative, return outNegative
|
|
173583
|
-
* * If x is true zero, return outZero
|
|
173584
|
-
* * If x is positive, return outPositive
|
|
173708
|
+
* Examine the sign of `x`.
|
|
173709
|
+
* * If `x` is negative, return `outNegative`
|
|
173710
|
+
* * If `x` is true zero, return `outZero`
|
|
173711
|
+
* * If `x` is positive, return `outPositive`
|
|
173585
173712
|
*/
|
|
173586
173713
|
static split3WaySign(x, outNegative, outZero, outPositive) {
|
|
173587
173714
|
if (x < 0)
|
|
@@ -173603,45 +173730,40 @@ class Geometry {
|
|
|
173603
173730
|
return -1;
|
|
173604
173731
|
return 0;
|
|
173605
173732
|
}
|
|
173606
|
-
/** Return the
|
|
173607
|
-
static
|
|
173608
|
-
|
|
173609
|
-
if (b > q)
|
|
173610
|
-
q = b;
|
|
173611
|
-
return q;
|
|
173612
|
-
}
|
|
173613
|
-
/** Return the smallest signed value among a, b */
|
|
173614
|
-
static minXY(a, b) {
|
|
173615
|
-
let q = a;
|
|
173616
|
-
if (b < q)
|
|
173617
|
-
q = b;
|
|
173618
|
-
return q;
|
|
173733
|
+
/** Return the square of x */
|
|
173734
|
+
static square(x) {
|
|
173735
|
+
return x * x;
|
|
173619
173736
|
}
|
|
173620
|
-
/**
|
|
173737
|
+
/**
|
|
173738
|
+
* Return the hypotenuse (i.e., `sqrt(x*x + y*y)`).
|
|
173739
|
+
* * This is much faster than `Math.hypot(x,y)`.
|
|
173740
|
+
*/
|
|
173621
173741
|
static hypotenuseXY(x, y) {
|
|
173622
173742
|
return Math.sqrt(x * x + y * y);
|
|
173623
173743
|
}
|
|
173624
|
-
/** Return the squared
|
|
173744
|
+
/** Return the squared hypotenuse (i.e., `x*x + y*y`). */
|
|
173625
173745
|
static hypotenuseSquaredXY(x, y) {
|
|
173626
173746
|
return x * x + y * y;
|
|
173627
173747
|
}
|
|
173628
|
-
/**
|
|
173629
|
-
|
|
173630
|
-
|
|
173631
|
-
|
|
173632
|
-
/** Return the hypotenuse `sqrt(x*x + y*y + z*z)`. This is much faster than `Math.hypot(x,y,z)`. */
|
|
173748
|
+
/**
|
|
173749
|
+
* Return the hypotenuse (i.e., `sqrt(x*x + y*y + z*z)`).
|
|
173750
|
+
* * This is much faster than `Math.hypot(x,y,z)`.
|
|
173751
|
+
*/
|
|
173633
173752
|
static hypotenuseXYZ(x, y, z) {
|
|
173634
173753
|
return Math.sqrt(x * x + y * y + z * z);
|
|
173635
173754
|
}
|
|
173636
|
-
/** Return the squared hypotenuse `
|
|
173755
|
+
/** Return the squared hypotenuse (i.e., `x*x + y*y + z*z`). */
|
|
173637
173756
|
static hypotenuseSquaredXYZ(x, y, z) {
|
|
173638
173757
|
return x * x + y * y + z * z;
|
|
173639
173758
|
}
|
|
173640
|
-
/**
|
|
173759
|
+
/**
|
|
173760
|
+
* Return the full 4d hypotenuse (i.e., `sqrt(x*x + y*y + z*z + w*w)`).
|
|
173761
|
+
* * This is much faster than `Math.hypot(x,y,z,w)`.
|
|
173762
|
+
*/
|
|
173641
173763
|
static hypotenuseXYZW(x, y, z, w) {
|
|
173642
173764
|
return Math.sqrt(x * x + y * y + z * z + w * w);
|
|
173643
173765
|
}
|
|
173644
|
-
/** Return the squared hypotenuse `
|
|
173766
|
+
/** Return the squared hypotenuse (i.e., `x*x + y*y + z*z + w*w`). */
|
|
173645
173767
|
static hypotenuseSquaredXYZW(x, y, z, w) {
|
|
173646
173768
|
return x * x + y * y + z * z + w * w;
|
|
173647
173769
|
}
|
|
@@ -173667,8 +173789,8 @@ class Geometry {
|
|
|
173667
173789
|
static distanceXYZXYZ(x0, y0, z0, x1, y1, z1) {
|
|
173668
173790
|
return Geometry.hypotenuseXYZ(x1 - x0, y1 - y0, z1 - z0);
|
|
173669
173791
|
}
|
|
173670
|
-
/**
|
|
173671
|
-
*
|
|
173792
|
+
/**
|
|
173793
|
+
* Returns the triple product of 3 vectors provided as x,y,z number sequences.
|
|
173672
173794
|
* * The triple product is the determinant of the 3x3 matrix with the 9 numbers (3 vectors placed in 3 rows).
|
|
173673
173795
|
* * The triple product is positive if the 3 vectors form a right handed coordinate system.
|
|
173674
173796
|
* * The triple product is negative if the 3 vectors form a left handed coordinate system.
|
|
@@ -173676,170 +173798,196 @@ class Geometry {
|
|
|
173676
173798
|
* * U dot (V cross W)
|
|
173677
173799
|
* * V dot (W cross U)
|
|
173678
173800
|
* * W dot (U cross V)
|
|
173679
|
-
* *
|
|
173680
|
-
* *
|
|
173681
|
-
* *
|
|
173682
|
-
* *
|
|
173801
|
+
* * -U dot (W cross V)
|
|
173802
|
+
* * -V dot (U cross W)
|
|
173803
|
+
* * -W dot (V cross U)
|
|
173804
|
+
* * Note the negative in the last 3 formulas. Reversing cross product order changes the sign.
|
|
173805
|
+
* * The triple product is 6 times the (signed) volume of the tetrahedron with the three vectors as edges from a
|
|
173806
|
+
* common vertex.
|
|
173683
173807
|
*/
|
|
173684
173808
|
static tripleProduct(ux, uy, uz, vx, vy, vz, wx, wy, wz) {
|
|
173685
173809
|
return ux * (vy * wz - vz * wy)
|
|
173686
173810
|
+ uy * (vz * wx - vx * wz)
|
|
173687
173811
|
+ uz * (vx * wy - vy * wx);
|
|
173688
173812
|
}
|
|
173689
|
-
/** Returns the determinant of the 4x4 matrix unrolled as the 16 parameters
|
|
173690
|
-
*/
|
|
173813
|
+
/** Returns the determinant of the 4x4 matrix unrolled as the 16 parameters */
|
|
173691
173814
|
static determinant4x4(xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, wx, wy, wz, ww) {
|
|
173692
173815
|
return xx * this.tripleProduct(yy, yz, yw, zy, zz, zw, wy, wz, ww)
|
|
173693
173816
|
- yx * this.tripleProduct(xy, xz, xw, zy, zz, zw, wy, wz, ww)
|
|
173694
173817
|
+ zx * this.tripleProduct(xy, xz, xw, yy, yz, yw, wy, wz, ww)
|
|
173695
173818
|
- wx * this.tripleProduct(xy, xz, xw, yy, yz, yw, zy, zz, zw);
|
|
173696
173819
|
}
|
|
173697
|
-
/** Return the mean curvature for two radii, with 0 radius implying 0 curvature */
|
|
173698
|
-
static meanCurvatureOfRadii(r0, r1) {
|
|
173699
|
-
return 0.5 * (this.safeDivideFraction(1, r0, 0) + this.safeDivideFraction(1, r1, 0));
|
|
173700
|
-
}
|
|
173701
173820
|
/**
|
|
173702
|
-
|
|
173703
|
-
|
|
173704
|
-
|
|
173705
|
-
|
|
173706
|
-
|
|
173707
|
-
* @param vy second derivative y component
|
|
173708
|
-
* @param vz second derivative z component
|
|
173709
|
-
*/
|
|
173710
|
-
static curvatureMagnitude(ux, uy, uz, vx, vy, vz) {
|
|
173711
|
-
let q = uy * vz - uz * vy;
|
|
173712
|
-
let sum = q * q;
|
|
173713
|
-
q = uz * vx - ux * vz;
|
|
173714
|
-
sum += q * q;
|
|
173715
|
-
q = ux * vy - uy * vx;
|
|
173716
|
-
sum += q * q;
|
|
173717
|
-
const a = Math.sqrt(ux * ux + uy * uy + uz * uz);
|
|
173718
|
-
const b = Math.sqrt(sum);
|
|
173719
|
-
// (sum and a are both nonnegative)
|
|
173720
|
-
const aaa = a * a * a;
|
|
173721
|
-
// radius of curvature = aaa / b;
|
|
173722
|
-
// curvature = b/aaa
|
|
173723
|
-
const tol = Geometry.smallAngleRadians;
|
|
173724
|
-
if (aaa > tol * b)
|
|
173725
|
-
return b / aaa;
|
|
173726
|
-
return 0; // hm.. maybe should be infinite?
|
|
173727
|
-
}
|
|
173728
|
-
/** Returns the determinant of 3x3 matrix with x and y rows taken from 3 points, third row from corresponding numbers.
|
|
173729
|
-
*
|
|
173821
|
+
* Returns the determinant of 3x3 matrix with first and second rows created from the 3 xy points and the third
|
|
173822
|
+
* row created from the 3 numbers:
|
|
173823
|
+
* [columnA.x columnB.x columnC.x]
|
|
173824
|
+
* [columnA.y columnB.y columnC.y]
|
|
173825
|
+
* [ weightA weightB weightC ]
|
|
173730
173826
|
*/
|
|
173731
173827
|
static tripleProductXYW(columnA, weightA, columnB, weightB, columnC, weightC) {
|
|
173732
173828
|
return Geometry.tripleProduct(columnA.x, columnB.x, columnC.x, columnA.y, columnB.y, columnC.y, weightA, weightB, weightC);
|
|
173733
173829
|
}
|
|
173734
|
-
/**
|
|
173735
|
-
*
|
|
173830
|
+
/**
|
|
173831
|
+
* Returns the determinant of 3x3 matrix columns created by the given `Point4d` ignoring the z part:
|
|
173832
|
+
* [columnA.x columnB.x columnC.x]
|
|
173833
|
+
* [columnA.y columnB.y columnC.y]
|
|
173834
|
+
* [columnA.w columnB.w columnC.w]
|
|
173736
173835
|
*/
|
|
173737
173836
|
static tripleProductPoint4dXYW(columnA, columnB, columnC) {
|
|
173738
173837
|
return Geometry.tripleProduct(columnA.x, columnB.x, columnC.x, columnA.y, columnB.y, columnC.y, columnA.w, columnB.w, columnC.w);
|
|
173739
173838
|
}
|
|
173740
|
-
/** 2D cross product of vectors
|
|
173839
|
+
/** 2D cross product of vectors with the vectors presented as numbers. */
|
|
173741
173840
|
static crossProductXYXY(ux, uy, vx, vy) {
|
|
173742
173841
|
return ux * vy - uy * vx;
|
|
173743
173842
|
}
|
|
173744
|
-
/** 3D cross product of vectors
|
|
173843
|
+
/** 3D cross product of vectors with the vectors presented as numbers. */
|
|
173745
173844
|
static crossProductXYZXYZ(ux, uy, uz, vx, vy, vz, result) {
|
|
173746
173845
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx, result);
|
|
173747
173846
|
}
|
|
173748
|
-
/**
|
|
173847
|
+
/** Magnitude of 3D cross product of vectors with the vectors presented as numbers. */
|
|
173749
173848
|
static crossProductMagnitude(ux, uy, uz, vx, vy, vz) {
|
|
173750
173849
|
return Geometry.hypotenuseXYZ(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx);
|
|
173751
173850
|
}
|
|
173752
|
-
/**
|
|
173851
|
+
/** 2D dot product of vectors with the vectors presented as numbers. */
|
|
173852
|
+
static dotProductXYXY(ux, uy, vx, vy) {
|
|
173853
|
+
return ux * vx + uy * vy;
|
|
173854
|
+
}
|
|
173855
|
+
/** 3D dot product of vectors with the vectors presented as numbers. */
|
|
173753
173856
|
static dotProductXYZXYZ(ux, uy, uz, vx, vy, vz) {
|
|
173754
173857
|
return ux * vx + uy * vy + uz * vz;
|
|
173755
173858
|
}
|
|
173756
|
-
/**
|
|
173757
|
-
|
|
173758
|
-
|
|
173859
|
+
/**
|
|
173860
|
+
* Return the mean curvature for two radii.
|
|
173861
|
+
* * Curvature is the reciprocal of radius.
|
|
173862
|
+
* * 0 radius implies 0 curvature.
|
|
173863
|
+
* @param r0 first radius
|
|
173864
|
+
* @param r1 second radius
|
|
173865
|
+
*/
|
|
173866
|
+
static meanCurvatureOfRadii(r0, r1) {
|
|
173867
|
+
return 0.5 * (this.safeDivideFraction(1, r0, 0) + this.safeDivideFraction(1, r1, 0));
|
|
173759
173868
|
}
|
|
173760
173869
|
/**
|
|
173761
|
-
*
|
|
173762
|
-
* *
|
|
173763
|
-
*
|
|
173764
|
-
*
|
|
173765
|
-
* @param
|
|
173870
|
+
* Returns curvature from the first and second derivative vectors.
|
|
173871
|
+
* * If U is the first derivative and V is the second derivative, the curvature is defined as:
|
|
173872
|
+
* * `|| U x V || / || U ||^3`.
|
|
173873
|
+
* * Math details can be found at https://en.wikipedia.org/wiki/Curvature#General_expressions
|
|
173874
|
+
* @param ux first derivative x component
|
|
173875
|
+
* @param uy first derivative y component
|
|
173876
|
+
* @param uz first derivative z component
|
|
173877
|
+
* @param vx second derivative x component
|
|
173878
|
+
* @param vy second derivative y component
|
|
173879
|
+
* @param vz second derivative z component
|
|
173766
173880
|
*/
|
|
173767
|
-
static
|
|
173881
|
+
static curvatureMagnitude(ux, uy, uz, vx, vy, vz) {
|
|
173882
|
+
let q = uy * vz - uz * vy;
|
|
173883
|
+
let sum = q * q;
|
|
173884
|
+
q = uz * vx - ux * vz;
|
|
173885
|
+
sum += q * q;
|
|
173886
|
+
q = ux * vy - uy * vx;
|
|
173887
|
+
sum += q * q;
|
|
173888
|
+
const magUxV = Math.sqrt(sum);
|
|
173889
|
+
const magU = Math.sqrt(ux * ux + uy * uy + uz * uz);
|
|
173890
|
+
const magUCubed = magU * magU * magU;
|
|
173891
|
+
if (magUCubed > Geometry.smallAngleRadians * magUxV)
|
|
173892
|
+
return magUxV / magUCubed;
|
|
173893
|
+
return 0;
|
|
173894
|
+
}
|
|
173895
|
+
/**
|
|
173896
|
+
* Clamp to (min(a,b), max(a,b)).
|
|
173897
|
+
* * Always returns a number between `a` and `b`.
|
|
173898
|
+
* @param value value to clamp
|
|
173899
|
+
* @param a smallest allowed output if `a < b` or largest allowed output if `a > b`
|
|
173900
|
+
* @param b largest allowed output if `a < b` or smallest allowed output if `a > b`
|
|
173901
|
+
*/
|
|
173902
|
+
static clampToStartEnd(value, a, b) {
|
|
173768
173903
|
if (a > b)
|
|
173769
|
-
return Geometry.clampToStartEnd(
|
|
173770
|
-
if (
|
|
173904
|
+
return Geometry.clampToStartEnd(value, b, a);
|
|
173905
|
+
if (value < a)
|
|
173771
173906
|
return a;
|
|
173772
|
-
if (b <
|
|
173907
|
+
if (b < value)
|
|
173773
173908
|
return b;
|
|
173774
|
-
return
|
|
173909
|
+
return value;
|
|
173775
173910
|
}
|
|
173776
173911
|
/**
|
|
173777
|
-
* Clamp value to (min,max) with no test for order of (min,max)
|
|
173912
|
+
* Clamp value to (min, max) with no test for order of (min, max).
|
|
173913
|
+
* * Always returns a number between `min` and `max`.
|
|
173778
173914
|
* @param value value to clamp
|
|
173779
173915
|
* @param min smallest allowed output
|
|
173780
|
-
* @param max largest allowed
|
|
173916
|
+
* @param max largest allowed output
|
|
173781
173917
|
*/
|
|
173782
|
-
static clamp(value, min, max) {
|
|
173783
|
-
|
|
173918
|
+
static clamp(value, min, max) {
|
|
173919
|
+
return Math.max(min, Math.min(max, value));
|
|
173920
|
+
}
|
|
173921
|
+
/** If given a `value`, return it. If given `undefined`, return `defaultValue`. */
|
|
173784
173922
|
static resolveNumber(value, defaultValue = 0) {
|
|
173785
173923
|
return value !== undefined ? value : defaultValue;
|
|
173786
173924
|
}
|
|
173787
|
-
/** If given a value
|
|
173925
|
+
/** If given a `value`, return it. If given `undefined`, return `defaultValue`. */
|
|
173788
173926
|
static resolveValue(value, defaultValue) {
|
|
173789
173927
|
return value !== undefined ? value : defaultValue;
|
|
173790
173928
|
}
|
|
173791
|
-
/** If given value matches
|
|
173929
|
+
/** If given `value` matches the `targetValue`, return `undefined`. Otherwise return the `value`. */
|
|
173792
173930
|
static resolveToUndefined(value, targetValue) {
|
|
173793
173931
|
return value === targetValue ? undefined : value;
|
|
173794
173932
|
}
|
|
173795
173933
|
/**
|
|
173796
|
-
* Simple interpolation between values
|
|
173797
|
-
* point for maximum accuracy.
|
|
173934
|
+
* Simple interpolation between values `a` and `b` with fraction `f`.
|
|
173798
173935
|
* * If `f = 0`, then `a` is returned and if `f = 1`, then `b` is returned.
|
|
173936
|
+
* * For maximum accuracy, we choose `a` or `b` as starting point based on fraction `f`.
|
|
173799
173937
|
*/
|
|
173800
173938
|
static interpolate(a, f, b) {
|
|
173801
173939
|
return f <= 0.5 ? a + f * (b - a) : b - (1.0 - f) * (b - a);
|
|
173802
173940
|
}
|
|
173803
173941
|
/**
|
|
173804
|
-
* Given an axisOrder (e.g. XYZ, YZX, etc) and an index
|
|
173805
|
-
* * For example, if axisOrder = XYZ
|
|
173806
|
-
* Y (or axis
|
|
173807
|
-
*
|
|
173808
|
-
*
|
|
173809
|
-
*
|
|
173810
|
-
*
|
|
173942
|
+
* Given an `axisOrder` (e.g. XYZ, YZX, etc) and an `index`, return the `axis` at the given index.
|
|
173943
|
+
* * For example, if `axisOrder = XYZ`, then for index 0 return `X` (or axis 0), for index 1 return
|
|
173944
|
+
* `Y` (or axis 1), and for index 2 return `Z` (or axis 2).
|
|
173945
|
+
* * Another example: if `axisOrder = ZXY`, then for index 0 return `Z` (or axis 2), for index 1 return
|
|
173946
|
+
* `X` (or axis 0), and for index 2 return `Y` (or axis 1).
|
|
173947
|
+
* * For indexes greater than 2 or smaller than 0, it return cyclic axis. See [[Geometry.cyclic3dAxis]]
|
|
173948
|
+
* for more info.
|
|
173949
|
+
*/
|
|
173811
173950
|
static axisOrderToAxis(order, index) {
|
|
173812
173951
|
const axis = order <= AxisOrder.ZXY ? order + index : (order - AxisOrder.XZY) - index;
|
|
173813
173952
|
return Geometry.cyclic3dAxis(axis);
|
|
173814
173953
|
}
|
|
173815
|
-
/**
|
|
173954
|
+
/**
|
|
173955
|
+
* Return `a` modulo `period`.
|
|
173956
|
+
* * Both `a` and `period` can be negative.
|
|
173957
|
+
* * This function can be faster than the `%` operator for the common case when `p > 0` and `-p < a < 2p`.
|
|
173958
|
+
*/
|
|
173816
173959
|
static modulo(a, period) {
|
|
173960
|
+
// period is negative
|
|
173817
173961
|
if (period <= 0) {
|
|
173818
173962
|
if (period === 0)
|
|
173819
173963
|
return a;
|
|
173820
173964
|
return -Geometry.modulo(-a, -period);
|
|
173821
173965
|
}
|
|
173966
|
+
// period is positive
|
|
173822
173967
|
if (a >= 0) {
|
|
173823
|
-
if (a < period)
|
|
173968
|
+
if (a < period) // "0 < a < period"
|
|
173824
173969
|
return a;
|
|
173825
|
-
if (a < 2 * period)
|
|
173970
|
+
if (a < 2 * period) // "0 < period < a < 2*period"
|
|
173826
173971
|
return a - period;
|
|
173827
173972
|
}
|
|
173828
|
-
else {
|
|
173829
|
-
a += period;
|
|
173973
|
+
else { // "-period < a < 0"
|
|
173974
|
+
a += period;
|
|
173830
173975
|
if (a > 0)
|
|
173831
173976
|
return a;
|
|
173832
173977
|
}
|
|
173978
|
+
// "0 < 2*period < a" or "a < -period < 0"
|
|
173833
173979
|
const m = Math.floor(a / period);
|
|
173834
173980
|
return a - m * period;
|
|
173835
173981
|
}
|
|
173836
|
-
/**
|
|
173837
|
-
static defined01(value) {
|
|
173982
|
+
/** Return 0 if the value is `undefined` and 1 if the value is defined. */
|
|
173983
|
+
static defined01(value) {
|
|
173984
|
+
return value === undefined ? 0 : 1;
|
|
173985
|
+
}
|
|
173838
173986
|
/**
|
|
173839
|
-
* Return `numerator` divided by `denominator
|
|
173987
|
+
* Return `numerator` divided by `denominator`.
|
|
173840
173988
|
* @param numerator the numerator
|
|
173841
173989
|
* @param denominator the denominator
|
|
173842
|
-
* @returns return `numerator/denominator` but if the ratio
|
|
173990
|
+
* @returns return `numerator/denominator` but if the ratio exceeds `Geometry.largeFractionResult`,
|
|
173843
173991
|
* return `undefined`.
|
|
173844
173992
|
*/
|
|
173845
173993
|
static conditionalDivideFraction(numerator, denominator) {
|
|
@@ -173851,76 +173999,105 @@ class Geometry {
|
|
|
173851
173999
|
* Return `numerator` divided by `denominator`.
|
|
173852
174000
|
* @param numerator the numerator
|
|
173853
174001
|
* @param denominator the denominator
|
|
173854
|
-
* @returns return `numerator/denominator` but if the ratio
|
|
174002
|
+
* @returns return `numerator/denominator` but if the ratio exceeds `Geometry.largeFractionResult`,
|
|
173855
174003
|
* return `defaultResult`.
|
|
173856
174004
|
*/
|
|
173857
174005
|
static safeDivideFraction(numerator, denominator, defaultResult) {
|
|
173858
|
-
const
|
|
173859
|
-
if (
|
|
173860
|
-
return
|
|
174006
|
+
const ratio = Geometry.conditionalDivideFraction(numerator, denominator);
|
|
174007
|
+
if (ratio !== undefined)
|
|
174008
|
+
return ratio;
|
|
173861
174009
|
return defaultResult;
|
|
173862
174010
|
}
|
|
173863
174011
|
/**
|
|
173864
|
-
* Return `numerator` divided by `denominator` (with a given `largestResult`)
|
|
174012
|
+
* Return `numerator` divided by `denominator` (with a given `largestResult`).
|
|
173865
174013
|
* @param numerator the numerator
|
|
173866
174014
|
* @param denominator the denominator
|
|
173867
|
-
* @param largestResult the ratio threshold
|
|
173868
|
-
* @returns return `numerator/denominator` but if the ratio
|
|
174015
|
+
* @param largestResult the ratio threshold
|
|
174016
|
+
* @returns return `numerator/denominator` but if the ratio exceeds `largestResult`, return `undefined`.
|
|
173869
174017
|
*/
|
|
173870
174018
|
static conditionalDivideCoordinate(numerator, denominator, largestResult = Geometry.largeCoordinateResult) {
|
|
173871
174019
|
if (Math.abs(denominator * largestResult) > Math.abs(numerator))
|
|
173872
174020
|
return numerator / denominator;
|
|
173873
174021
|
return undefined;
|
|
173874
174022
|
}
|
|
173875
|
-
/**
|
|
173876
|
-
*
|
|
173877
|
-
*
|
|
174023
|
+
/**
|
|
174024
|
+
* Return solution(s) of equation `constCoff + cosCoff*c + sinCoff*s = 0` for `c` and `s` with the
|
|
174025
|
+
* constraint `c*c + s*s = 1`.
|
|
174026
|
+
* * There could be 0, 1, or 2 solutions. Return `undefined` if there is no solution.
|
|
173878
174027
|
*/
|
|
173879
174028
|
static solveTrigForm(constCoff, cosCoff, sinCoff) {
|
|
173880
|
-
|
|
173881
|
-
|
|
173882
|
-
|
|
173883
|
-
|
|
173884
|
-
|
|
173885
|
-
|
|
173886
|
-
|
|
173887
|
-
|
|
173888
|
-
|
|
173889
|
-
|
|
173890
|
-
|
|
173891
|
-
|
|
173892
|
-
|
|
173893
|
-
|
|
173894
|
-
|
|
173895
|
-
|
|
173896
|
-
|
|
173897
|
-
|
|
173898
|
-
|
|
173899
|
-
|
|
173900
|
-
|
|
173901
|
-
|
|
173902
|
-
|
|
174029
|
+
/**
|
|
174030
|
+
* Solutions can be found by finding the intersection of line "ax + by + d = 0" and unit circle "x^2 + y^2 = 1".
|
|
174031
|
+
* From the line equation we have "y = (-ax - d) / b". By replacing this into the circle equation we get
|
|
174032
|
+
* "x^2 + (ax+d)^2/b^2 = 1". If we solve this by quadratic formula we get
|
|
174033
|
+
* x = (-ad +- b*sqrt(a^2+b^2-d^2)) / (a^2+b^2)
|
|
174034
|
+
* y = (-ad -+ a*sqrt(a^2+b^2-d^2)) / (a^2+b^2)
|
|
174035
|
+
*
|
|
174036
|
+
* If "a^2+b^2-d^2 > 0" then there are two solutions (above).
|
|
174037
|
+
* If "a^2+b^2-d^2 = 0" then there is one solution which is (-ad/(a^2+b^2), -bd/(a^2+b^2)).
|
|
174038
|
+
* If "a^2+b^2-d^2 < 0" then there is no solution.
|
|
174039
|
+
*
|
|
174040
|
+
* Below in the code we have "a = cosCoff", "b = sinCoff", and "d = constCoff". Also equivalent criterion
|
|
174041
|
+
* is used in the code. For example, "a^2+b^2-d^2 > 0" is equivalent of "1 - d^2/(a^2+b^2) > 0".
|
|
174042
|
+
*/
|
|
174043
|
+
const a2b2 = cosCoff * cosCoff + sinCoff * sinCoff; // a^2+b^2
|
|
174044
|
+
const d2 = constCoff * constCoff; // d^2
|
|
174045
|
+
let result;
|
|
174046
|
+
if (a2b2 > 0.0) {
|
|
174047
|
+
const a2b2r = 1.0 / a2b2; // 1/(a^2+b^2)
|
|
174048
|
+
const d2a2b2 = d2 * a2b2r; // d^2/(a^2+b^2)
|
|
174049
|
+
const criteria = 1.0 - d2a2b2; // 1 - d^2/(a^2+b^2); the criteria to specify how many solutions we got
|
|
174050
|
+
if (criteria < -Geometry.smallMetricDistanceSquared) // nSolution = 0
|
|
174051
|
+
return result;
|
|
174052
|
+
const da2b2 = -constCoff * a2b2r; // -d/(a^2+b^2)
|
|
174053
|
+
const c0 = da2b2 * cosCoff; // -ad/(a^2+b^2)
|
|
174054
|
+
const s0 = da2b2 * sinCoff; // -bd/(a^2+b^2)
|
|
174055
|
+
if (criteria <= 0.0) { // nSolution = 1 (observed criteria = -2.22e-16 in rotated system)
|
|
174056
|
+
result = [_geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_1__.Vector2d.create(c0, s0)];
|
|
174057
|
+
}
|
|
174058
|
+
else if (criteria > 0.0) { // nSolution = 2
|
|
174059
|
+
const s = Math.sqrt(criteria * a2b2r); // sqrt(a^2+b^2-d^2)) / (a^2+b^2)
|
|
174060
|
+
result = [
|
|
174061
|
+
_geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_1__.Vector2d.create(c0 - s * sinCoff, s0 + s * cosCoff),
|
|
174062
|
+
_geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_1__.Vector2d.create(c0 + s * sinCoff, s0 - s * cosCoff),
|
|
174063
|
+
];
|
|
173903
174064
|
}
|
|
173904
|
-
return result;
|
|
173905
174065
|
}
|
|
174066
|
+
return result;
|
|
173906
174067
|
}
|
|
173907
|
-
/**
|
|
173908
|
-
|
|
173909
|
-
|
|
173910
|
-
|
|
173911
|
-
|
|
174068
|
+
/**
|
|
174069
|
+
* For a line `f(x)` where `f(x0) = f0` and `f(x1) = f1`, return the `x` value at which `f(x) = fTarget`
|
|
174070
|
+
* Return `defaultResult` if `(fTarget - f0) / (f1 - f0)` exceeds `Geometry.largeFractionResult`
|
|
174071
|
+
*/
|
|
174072
|
+
static inverseInterpolate(x0, f0, x1, f1, fTarget = 0, defaultResult) {
|
|
174073
|
+
/**
|
|
174074
|
+
* Line equation is "fTarget-f0 = (f1-f0)/(x1-x0) * (x-x0)" or "(fTarget-f0)/(f1-f0) = (x-x0)/(x1-x0)".
|
|
174075
|
+
* The left hand side is known so if we call it "fr" (short for "fraction") we get "fr = (x-x0)/(x1-x0)".
|
|
174076
|
+
* Therefore, "x = x0*(1-fr) + x1*fr". This is same as interpolation between "x0" and "x1" with fraction "fr".
|
|
174077
|
+
*/
|
|
174078
|
+
const fr = Geometry.conditionalDivideFraction(fTarget - f0, f1 - f0); // (fTarget-f0)/(f1-f0)
|
|
174079
|
+
if (fr !== undefined)
|
|
174080
|
+
return Geometry.interpolate(x0, fr, x1); // x = x0*(1-fr) + x1*fr
|
|
173912
174081
|
return defaultResult;
|
|
173913
174082
|
}
|
|
173914
|
-
/**
|
|
173915
|
-
|
|
173916
|
-
|
|
174083
|
+
/**
|
|
174084
|
+
* For a line `f(x)` where `f(0) = f0` and `f(1) = f1`, return the `x` value at which `f(x) = fTarget`
|
|
174085
|
+
* Return `undefined` if `(fTarget - f0) / (f1 - f0)` exceeds `Geometry.largeFractionResult`
|
|
174086
|
+
*/
|
|
174087
|
+
static inverseInterpolate01(f0, f1, fTarget = 0) {
|
|
174088
|
+
/**
|
|
174089
|
+
* Line equation is "fTarget-f0 = (f1-f0)*x" so "x = (fTarget-f0)/(f1-f0)"
|
|
174090
|
+
*/
|
|
174091
|
+
return Geometry.conditionalDivideFraction(fTarget - f0, f1 - f0); // x = (fTarget-f0)/(f1-f0)
|
|
173917
174092
|
}
|
|
173918
|
-
/**
|
|
174093
|
+
/**
|
|
174094
|
+
* Return `true` if `json` is an array with at least `minEntries` entries and all entries are numbers (including
|
|
174095
|
+
* those beyond minEntries).
|
|
174096
|
+
*/
|
|
173919
174097
|
static isNumberArray(json, minEntries = 0) {
|
|
173920
174098
|
if (Array.isArray(json) && json.length >= minEntries) {
|
|
173921
174099
|
let entry;
|
|
173922
174100
|
for (entry of json) {
|
|
173923
|
-
// if (!(entry as number) && entry !== 0.0)
|
|
173924
174101
|
if (!Number.isFinite(entry))
|
|
173925
174102
|
return false;
|
|
173926
174103
|
}
|
|
@@ -173928,10 +174105,12 @@ class Geometry {
|
|
|
173928
174105
|
}
|
|
173929
174106
|
return false;
|
|
173930
174107
|
}
|
|
173931
|
-
/**
|
|
174108
|
+
/**
|
|
174109
|
+
* Return `true` if `json` is an array of at least `minArrays` arrays with at least `minEntries` entries in
|
|
174110
|
+
* each array and all entries are numbers (including those beyond minEntries).
|
|
173932
174111
|
*/
|
|
173933
|
-
static isArrayOfNumberArray(json,
|
|
173934
|
-
if (Array.isArray(json) && json.length >=
|
|
174112
|
+
static isArrayOfNumberArray(json, minArrays, minEntries = 0) {
|
|
174113
|
+
if (Array.isArray(json) && json.length >= minArrays) {
|
|
173935
174114
|
let entry;
|
|
173936
174115
|
for (entry of json)
|
|
173937
174116
|
if (!Geometry.isNumberArray(entry, minEntries))
|
|
@@ -173940,36 +174119,53 @@ class Geometry {
|
|
|
173940
174119
|
}
|
|
173941
174120
|
return false;
|
|
173942
174121
|
}
|
|
173943
|
-
/**
|
|
173944
|
-
*
|
|
173945
|
-
*
|
|
173946
|
-
|
|
174122
|
+
/**
|
|
174123
|
+
* Return the number of steps to take so that `numSteps * stepSize >= total`.
|
|
174124
|
+
* * `minCount` is returned in the following 3 cases:
|
|
174125
|
+
* * (a) `stepSize <= 0`
|
|
174126
|
+
* * (b) `stepSize >= total`
|
|
174127
|
+
* * (b) `numSteps < minCount`
|
|
174128
|
+
* * `maxCount` is returned if `numSteps > maxCount`.
|
|
174129
|
+
*/
|
|
173947
174130
|
static stepCount(stepSize, total, minCount = 1, maxCount = 101) {
|
|
173948
174131
|
if (stepSize <= 0)
|
|
173949
174132
|
return minCount;
|
|
173950
174133
|
total = Math.abs(total);
|
|
173951
174134
|
if (stepSize >= total)
|
|
173952
174135
|
return minCount;
|
|
173953
|
-
|
|
173954
|
-
|
|
174136
|
+
/**
|
|
174137
|
+
* 0.999999 is multiplied so we return the same "numSteps" if
|
|
174138
|
+
* stepSize*(numSteps-1) < total <= stepSize*numSteps.
|
|
174139
|
+
* For example, if "stepSize = 2" then we return "numSteps = 5" if 8 < total <= 10.
|
|
174140
|
+
*/
|
|
174141
|
+
const numSteps = Math.floor((total + 0.999999 * stepSize) / stepSize);
|
|
174142
|
+
if (numSteps < minCount)
|
|
173955
174143
|
return minCount;
|
|
173956
|
-
if (
|
|
174144
|
+
if (numSteps > maxCount)
|
|
173957
174145
|
return maxCount;
|
|
173958
|
-
return
|
|
174146
|
+
return numSteps;
|
|
173959
174147
|
}
|
|
173960
|
-
/**
|
|
174148
|
+
/**
|
|
174149
|
+
* Test if `x` is in the interval [0,1] (but skip the test if `apply01 = false`).
|
|
174150
|
+
* * This odd behavior is very convenient for code that sometimes does not do the filtering.
|
|
173961
174151
|
* @param x value to test.
|
|
173962
|
-
* @param apply01 if false,
|
|
174152
|
+
* @param apply01 if false, return `true` for all values of `x`.
|
|
173963
174153
|
*/
|
|
173964
|
-
static isIn01(x, apply01 = true) {
|
|
173965
|
-
|
|
174154
|
+
static isIn01(x, apply01 = true) {
|
|
174155
|
+
return apply01 ? x >= 0.0 && x <= 1.0 : true;
|
|
174156
|
+
}
|
|
174157
|
+
/**
|
|
174158
|
+
* Test if `x` is in the interval [0,1] for a given positive `tolerance`.
|
|
174159
|
+
* * Make sure to pass a positive `tolerance` because there is no check for that in the code.
|
|
173966
174160
|
* @param x value to test.
|
|
173967
|
-
* @param
|
|
174161
|
+
* @param tolerance the tolerance.
|
|
173968
174162
|
*/
|
|
173969
|
-
static isIn01WithTolerance(x, tolerance) {
|
|
174163
|
+
static isIn01WithTolerance(x, tolerance) {
|
|
174164
|
+
return x + tolerance >= 0.0 && x - tolerance <= 1.0;
|
|
174165
|
+
}
|
|
173970
174166
|
/**
|
|
173971
|
-
*
|
|
173972
|
-
* @param x
|
|
174167
|
+
* Restrict x so it is in the interval `[a,b]` (allowing `a` and `b` to be in either order).
|
|
174168
|
+
* @param x value to restrict
|
|
173973
174169
|
* @param a (usually the lower) interval limit
|
|
173974
174170
|
* @param b (usually the upper) interval limit
|
|
173975
174171
|
*/
|
|
@@ -173981,7 +174177,7 @@ class Geometry {
|
|
|
173981
174177
|
return b;
|
|
173982
174178
|
return x;
|
|
173983
174179
|
}
|
|
173984
|
-
// reversed interval
|
|
174180
|
+
// reversed interval
|
|
173985
174181
|
if (x < b)
|
|
173986
174182
|
return b;
|
|
173987
174183
|
if (x > a)
|
|
@@ -173990,12 +174186,15 @@ class Geometry {
|
|
|
173990
174186
|
}
|
|
173991
174187
|
/**
|
|
173992
174188
|
* Case-insensitive string comparison.
|
|
173993
|
-
* * Return true if the toUpperCase values match.
|
|
174189
|
+
* * Return `true` if the `toUpperCase` values of `string1` and `string2` match.
|
|
173994
174190
|
*/
|
|
173995
174191
|
static equalStringNoCase(string1, string2) {
|
|
173996
174192
|
return string1.toUpperCase() === string2.toUpperCase();
|
|
173997
174193
|
}
|
|
173998
|
-
/**
|
|
174194
|
+
/**
|
|
174195
|
+
* Test for exact match of two number arrays.
|
|
174196
|
+
* Returns `true` if both arrays have the same length and entries, or if both arrays are empty or `undefined`.
|
|
174197
|
+
*/
|
|
173999
174198
|
static exactEqualNumberArrays(a, b) {
|
|
174000
174199
|
if (Array.isArray(a) && a.length === 0)
|
|
174001
174200
|
a = undefined;
|
|
@@ -174013,7 +174212,10 @@ class Geometry {
|
|
|
174013
174212
|
}
|
|
174014
174213
|
return false;
|
|
174015
174214
|
}
|
|
174016
|
-
/**
|
|
174215
|
+
/**
|
|
174216
|
+
* Test for match of two arrays of type `T`.
|
|
174217
|
+
* Returns `true` if both arrays have the same length and have the same entries (or both are empty arrays).
|
|
174218
|
+
*/
|
|
174017
174219
|
static almostEqualArrays(a, b, testFunction) {
|
|
174018
174220
|
if (Array.isArray(a) && a.length === 0)
|
|
174019
174221
|
a = undefined;
|
|
@@ -174032,7 +174234,10 @@ class Geometry {
|
|
|
174032
174234
|
}
|
|
174033
174235
|
return false;
|
|
174034
174236
|
}
|
|
174035
|
-
/**
|
|
174237
|
+
/**
|
|
174238
|
+
* Test for match of two arrays of type number or Float64Array.
|
|
174239
|
+
* Returns `true` if both arrays have the same length and have the same entries (or both are empty arrays).
|
|
174240
|
+
*/
|
|
174036
174241
|
static almostEqualNumberArrays(a, b, testFunction) {
|
|
174037
174242
|
if (Array.isArray(a) && a.length === 0)
|
|
174038
174243
|
a = undefined;
|
|
@@ -174052,15 +174257,12 @@ class Geometry {
|
|
|
174052
174257
|
return false;
|
|
174053
174258
|
}
|
|
174054
174259
|
/**
|
|
174055
|
-
*
|
|
174056
|
-
* * true if both values are defined and equal (with ===).
|
|
174057
|
-
* * false if both defined by not equal
|
|
174058
|
-
* * return (option arg) resultIfBothUndefined when both are undefined.
|
|
174059
|
-
* * return false if one is defined and the other undefined
|
|
174260
|
+
* Test for match of two values of type `T`.
|
|
174060
174261
|
* @param a first value
|
|
174061
174262
|
* @param b second value
|
|
174062
|
-
* @param resultIfBothUndefined
|
|
174063
|
-
* @returns
|
|
174263
|
+
* @param resultIfBothUndefined returned value when both are `undefined`
|
|
174264
|
+
* @returns `true` if both values are defined and equal (with ===) and `false` if both values are defined
|
|
174265
|
+
* but not equal or if one is defined and the other undefined.
|
|
174064
174266
|
*/
|
|
174065
174267
|
static areEqualAllowUndefined(a, b, resultIfBothUndefined = true) {
|
|
174066
174268
|
if (a === undefined && b === undefined)
|
|
@@ -174069,47 +174271,53 @@ class Geometry {
|
|
|
174069
174271
|
return a === b;
|
|
174070
174272
|
return false;
|
|
174071
174273
|
}
|
|
174072
|
-
/**
|
|
174073
|
-
*
|
|
174074
|
-
|
|
174075
|
-
|
|
174076
|
-
|
|
174274
|
+
/**
|
|
174275
|
+
* Clone an array whose members have type `T`, which implements the clone method.
|
|
174276
|
+
* * If the clone method returns `undefined`, then `undefined` is forced into the cloned array.
|
|
174277
|
+
*/
|
|
174278
|
+
static cloneMembers(array) {
|
|
174279
|
+
if (array === undefined)
|
|
174077
174280
|
return undefined;
|
|
174078
|
-
const
|
|
174079
|
-
for (const
|
|
174080
|
-
|
|
174281
|
+
const clonedArray = [];
|
|
174282
|
+
for (const element of array) {
|
|
174283
|
+
clonedArray.push(element.clone());
|
|
174081
174284
|
}
|
|
174082
|
-
return
|
|
174285
|
+
return clonedArray;
|
|
174083
174286
|
}
|
|
174084
174287
|
}
|
|
174085
|
-
/** Tolerance for small distances in metric coordinates */
|
|
174288
|
+
/** Tolerance for small distances in metric coordinates. */
|
|
174086
174289
|
Geometry.smallMetricDistance = 1.0e-6;
|
|
174087
|
-
/** Square of `
|
|
174290
|
+
/** Square of `smallMetricDistance`. */
|
|
174088
174291
|
Geometry.smallMetricDistanceSquared = 1.0e-12;
|
|
174089
|
-
/**
|
|
174292
|
+
/** Tolerance for small angle measured in radians. */
|
|
174090
174293
|
Geometry.smallAngleRadians = 1.0e-12;
|
|
174091
|
-
/**
|
|
174294
|
+
/** Square of `smallAngleRadians`. */
|
|
174092
174295
|
Geometry.smallAngleRadiansSquared = 1.0e-24;
|
|
174093
|
-
/**
|
|
174296
|
+
/** Tolerance for small angle measured in degrees. */
|
|
174094
174297
|
Geometry.smallAngleDegrees = 5.7e-11;
|
|
174095
|
-
/**
|
|
174298
|
+
/** Tolerance for small angle measured in arc-seconds. */
|
|
174096
174299
|
Geometry.smallAngleSeconds = 2e-7;
|
|
174097
|
-
/**
|
|
174098
|
-
|
|
174300
|
+
/** Numeric value that may be considered zero for fractions between 0 and 1. */
|
|
174301
|
+
Geometry.smallFraction = 1.0e-10;
|
|
174302
|
+
/** Radians value for full circle 2PI radians minus `smallAngleRadians`. */
|
|
174303
|
+
Geometry.fullCircleRadiansMinusSmallAngle = 2.0 * Math.PI - Geometry.smallAngleRadians;
|
|
174304
|
+
/**
|
|
174305
|
+
* Numeric value that may be considered large for a ratio of numbers.
|
|
174306
|
+
* * Note that the allowed result value is vastly larger than 1.
|
|
174099
174307
|
*/
|
|
174100
174308
|
Geometry.largeFractionResult = 1.0e10;
|
|
174101
|
-
/**
|
|
174102
|
-
|
|
174103
|
-
/** numeric value that may considered huge for numbers expected to be coordinates.
|
|
174309
|
+
/**
|
|
174310
|
+
* Numeric value that may considered large for numbers expected to be coordinates.
|
|
174104
174311
|
* * This allows larger results than `largeFractionResult`.
|
|
174105
174312
|
*/
|
|
174106
174313
|
Geometry.largeCoordinateResult = 1.0e13;
|
|
174107
|
-
/**
|
|
174108
|
-
*
|
|
174314
|
+
/**
|
|
174315
|
+
* Numeric value that may considered infinite for metric coordinates.
|
|
174316
|
+
* @deprecated in 4.x. Use `largeCoordinateResult`.
|
|
174317
|
+
* * This coordinate should be used only as a placeholder indicating "at infinity" -- computing actual
|
|
174318
|
+
* points at this coordinate invites numerical problems.
|
|
174109
174319
|
*/
|
|
174110
174320
|
Geometry.hugeCoordinate = 1.0e12;
|
|
174111
|
-
/** Radians value for full circle 2PI radians minus `smallAngleRadians` */
|
|
174112
|
-
Geometry.fullCircleRadiansMinusSmallAngle = 2.0 * Math.PI - 1.0e-12; // smallAngleRadians less than 360degrees
|
|
174113
174321
|
|
|
174114
174322
|
|
|
174115
174323
|
|
|
@@ -183137,17 +183345,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
183137
183345
|
/* harmony export */ "ConvexClipPlaneSet": () => (/* binding */ ConvexClipPlaneSet)
|
|
183138
183346
|
/* harmony export */ });
|
|
183139
183347
|
/* harmony import */ var _Geometry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Geometry */ "../../core/geometry/lib/esm/Geometry.js");
|
|
183140
|
-
/* harmony import */ var _geometry3d_Plane3dByOriginAndUnitNormal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geometry3d/Plane3dByOriginAndUnitNormal */ "../../core/geometry/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js");
|
|
183141
183348
|
/* harmony import */ var _geometry3d_GrowableFloat64Array__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../geometry3d/GrowableFloat64Array */ "../../core/geometry/lib/esm/geometry3d/GrowableFloat64Array.js");
|
|
183142
183349
|
/* harmony import */ var _geometry3d_GrowableXYZArray__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../geometry3d/GrowableXYZArray */ "../../core/geometry/lib/esm/geometry3d/GrowableXYZArray.js");
|
|
183143
183350
|
/* harmony import */ var _geometry3d_Matrix3d__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../geometry3d/Matrix3d */ "../../core/geometry/lib/esm/geometry3d/Matrix3d.js");
|
|
183351
|
+
/* harmony import */ var _geometry3d_Plane3dByOriginAndUnitNormal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geometry3d/Plane3dByOriginAndUnitNormal */ "../../core/geometry/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js");
|
|
183144
183352
|
/* harmony import */ var _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../geometry3d/Point3dVector3d */ "../../core/geometry/lib/esm/geometry3d/Point3dVector3d.js");
|
|
183145
183353
|
/* harmony import */ var _geometry3d_PolygonOps__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../geometry3d/PolygonOps */ "../../core/geometry/lib/esm/geometry3d/PolygonOps.js");
|
|
183146
183354
|
/* harmony import */ var _geometry3d_Range__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../geometry3d/Range */ "../../core/geometry/lib/esm/geometry3d/Range.js");
|
|
183147
|
-
/* harmony import */ var _ClipPlane__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClipPlane */ "../../core/geometry/lib/esm/clipping/ClipPlane.js");
|
|
183148
|
-
/* harmony import */ var _ClipUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ClipUtils */ "../../core/geometry/lib/esm/clipping/ClipUtils.js");
|
|
183149
183355
|
/* harmony import */ var _polyface_Polyface__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../polyface/Polyface */ "../../core/geometry/lib/esm/polyface/Polyface.js");
|
|
183150
183356
|
/* harmony import */ var _polyface_PolyfaceQuery__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../polyface/PolyfaceQuery */ "../../core/geometry/lib/esm/polyface/PolyfaceQuery.js");
|
|
183357
|
+
/* harmony import */ var _ClipPlane__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClipPlane */ "../../core/geometry/lib/esm/clipping/ClipPlane.js");
|
|
183358
|
+
/* harmony import */ var _ClipUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ClipUtils */ "../../core/geometry/lib/esm/clipping/ClipUtils.js");
|
|
183151
183359
|
/*---------------------------------------------------------------------------------------------
|
|
183152
183360
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
183153
183361
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -183372,17 +183580,19 @@ class ConvexClipPlaneSet {
|
|
|
183372
183580
|
get planes() {
|
|
183373
183581
|
return this._planes;
|
|
183374
183582
|
}
|
|
183375
|
-
/**
|
|
183583
|
+
/**
|
|
183584
|
+
* Test if there is any intersection with a ray defined by origin and direction.
|
|
183376
183585
|
* * Optionally record the range (null or otherwise) in caller-allocated result.
|
|
183377
|
-
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
183586
|
+
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
183587
|
+
* "Geometry.largeCoordinateResult" values
|
|
183378
183588
|
* * If no result is provide, there are no object allocations.
|
|
183379
183589
|
* @param result optional Range1d to receive parameters along the ray.
|
|
183380
183590
|
*/
|
|
183381
183591
|
hasIntersectionWithRay(ray, result, tolerance = _Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.smallMetricDistance) {
|
|
183382
183592
|
// form low and high values in locals that do not require allocation.
|
|
183383
183593
|
// transfer to caller-supplied result at end
|
|
183384
|
-
let t0 = -_Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.
|
|
183385
|
-
let t1 = _Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.
|
|
183594
|
+
let t0 = -_Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.largeCoordinateResult;
|
|
183595
|
+
let t1 = _Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.largeCoordinateResult;
|
|
183386
183596
|
if (result)
|
|
183387
183597
|
result.setNull();
|
|
183388
183598
|
const velocityTolerance = 1.0e-13;
|
|
@@ -183993,9 +184203,11 @@ class UnionOfConvexClipPlaneSets {
|
|
|
183993
184203
|
if (toAdd)
|
|
183994
184204
|
this._convexSets.push(toAdd);
|
|
183995
184205
|
}
|
|
183996
|
-
/**
|
|
184206
|
+
/**
|
|
184207
|
+
* Test if there is any intersection with a ray defined by origin and direction.
|
|
183997
184208
|
* * Optionally record the range (null or otherwise) in caller-allocated result.
|
|
183998
|
-
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
184209
|
+
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
184210
|
+
* "Geometry.largeCoordinateResult" values
|
|
183999
184211
|
* * If no result is provide, there are no object allocations.
|
|
184000
184212
|
* @param maximalRange optional Range1d to receive parameters along the ray.
|
|
184001
184213
|
*/
|
|
@@ -212159,32 +212371,40 @@ class Plane3dByOriginAndUnitNormal extends _Plane3d__WEBPACK_IMPORTED_MODULE_0__
|
|
|
212159
212371
|
return Plane3dByOriginAndUnitNormal._create(origin.x, origin.y, origin.z, 0, 1, 0);
|
|
212160
212372
|
return Plane3dByOriginAndUnitNormal._create(0, 0, 0, 0, 1, 0);
|
|
212161
212373
|
}
|
|
212162
|
-
/**
|
|
212374
|
+
/** Create a new Plane3dByOriginAndUnitNormal with given origin and normal.
|
|
212163
212375
|
* * The inputs are NOT captured.
|
|
212164
|
-
* * Returns undefined if
|
|
212376
|
+
* * Returns undefined if `normal.normalize()` returns undefined.
|
|
212165
212377
|
*/
|
|
212166
212378
|
static create(origin, normal, result) {
|
|
212167
|
-
const normalized = normal.normalize();
|
|
212168
|
-
if (!normalized)
|
|
212169
|
-
return undefined;
|
|
212170
212379
|
if (result) {
|
|
212171
|
-
result.
|
|
212380
|
+
if (normal.normalize(result._normal) === undefined)
|
|
212381
|
+
return undefined;
|
|
212382
|
+
origin.clone(result._origin);
|
|
212172
212383
|
return result;
|
|
212173
212384
|
}
|
|
212385
|
+
const normalized = normal.normalize();
|
|
212386
|
+
if (normalized === undefined)
|
|
212387
|
+
return undefined;
|
|
212174
212388
|
return new Plane3dByOriginAndUnitNormal(origin.clone(), normalized);
|
|
212175
212389
|
}
|
|
212176
|
-
/**
|
|
212390
|
+
/** Create a new Plane3dByOriginAndUnitNormal from a variety of plane types.
|
|
212177
212391
|
* * The inputs are NOT captured.
|
|
212178
|
-
* * Returns undefined if
|
|
212392
|
+
* * Returns undefined if `source.getUnitNormal()` returns undefined.
|
|
212179
212393
|
*/
|
|
212180
212394
|
static createFrom(source, result) {
|
|
212181
212395
|
if (source instanceof Plane3dByOriginAndUnitNormal)
|
|
212182
212396
|
return source.clone(result);
|
|
212397
|
+
if (result) {
|
|
212398
|
+
if (source.getUnitNormal(result._normal) === undefined)
|
|
212399
|
+
return undefined;
|
|
212400
|
+
source.getAnyPointOnPlane(result._origin);
|
|
212401
|
+
return result;
|
|
212402
|
+
}
|
|
212183
212403
|
const normal = source.getUnitNormal();
|
|
212184
212404
|
if (normal === undefined)
|
|
212185
212405
|
return undefined;
|
|
212186
212406
|
const origin = source.getAnyPointOnPlane();
|
|
212187
|
-
return
|
|
212407
|
+
return new Plane3dByOriginAndUnitNormal(origin, normal);
|
|
212188
212408
|
}
|
|
212189
212409
|
/** create a new Plane3dByOriginAndUnitNormal with direct coordinates of origin and normal.
|
|
212190
212410
|
* * Returns undefined if the normal vector is all zeros.
|
|
@@ -213343,7 +213563,7 @@ class Vector2d extends XY {
|
|
|
213343
213563
|
}
|
|
213344
213564
|
/** Return a unit vector in direction of this instance (undefined if this instance has near zero length) */
|
|
213345
213565
|
normalize(result) {
|
|
213346
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
213566
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(this.magnitude());
|
|
213347
213567
|
result = result ? result : new Vector2d();
|
|
213348
213568
|
return this.safeDivideOrNull(mag, result);
|
|
213349
213569
|
}
|
|
@@ -213488,7 +213708,7 @@ class Vector2d extends XY {
|
|
|
213488
213708
|
}
|
|
213489
213709
|
/** Return a vector parallel to this but with specified length */
|
|
213490
213710
|
scaleToLength(length, result) {
|
|
213491
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
213711
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(this.magnitude());
|
|
213492
213712
|
if (mag === 0)
|
|
213493
213713
|
return undefined;
|
|
213494
213714
|
return this.scale(length / mag, result);
|
|
@@ -214683,7 +214903,12 @@ class Vector3d extends XYZ {
|
|
|
214683
214903
|
static unitZ(scale = 1) {
|
|
214684
214904
|
return new Vector3d(0, 0, scale);
|
|
214685
214905
|
}
|
|
214686
|
-
/**
|
|
214906
|
+
/**
|
|
214907
|
+
* Scale the instance by 1.0/`denominator`.
|
|
214908
|
+
* @param denominator number by which to divide the coordinates of this instance
|
|
214909
|
+
* @param result optional pre-allocated object to return
|
|
214910
|
+
* @return scaled vector, or undefined if `denominator` is exactly zero (in which case instance is untouched).
|
|
214911
|
+
*/
|
|
214687
214912
|
safeDivideOrNull(denominator, result) {
|
|
214688
214913
|
if (denominator !== 0.0) {
|
|
214689
214914
|
return this.scale(1.0 / denominator, result);
|
|
@@ -214691,15 +214916,17 @@ class Vector3d extends XYZ {
|
|
|
214691
214916
|
return undefined;
|
|
214692
214917
|
}
|
|
214693
214918
|
/**
|
|
214694
|
-
* Return a
|
|
214695
|
-
*
|
|
214696
|
-
*
|
|
214697
|
-
*
|
|
214919
|
+
* Return a normalized instance and instance length.
|
|
214920
|
+
* @param result optional pre-allocated object to return as `v` property
|
|
214921
|
+
* @returns object containing the properties:
|
|
214922
|
+
* * `v`: unit vector in the direction of the instance, or undefined if `mag` is near zero
|
|
214923
|
+
* * `mag`: length of the instance prior to normalization
|
|
214698
214924
|
*/
|
|
214699
214925
|
normalizeWithLength(result) {
|
|
214700
|
-
const
|
|
214926
|
+
const originalMagnitude = this.magnitude();
|
|
214927
|
+
const correctedMagnitude = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(originalMagnitude);
|
|
214701
214928
|
result = result ? result : new Vector3d();
|
|
214702
|
-
return { v: this.safeDivideOrNull(
|
|
214929
|
+
return { v: this.safeDivideOrNull(correctedMagnitude, result), mag: originalMagnitude };
|
|
214703
214930
|
}
|
|
214704
214931
|
/**
|
|
214705
214932
|
* Return a unit vector parallel with this. Return undefined if this.magnitude is near zero.
|
|
@@ -214710,16 +214937,10 @@ class Vector3d extends XYZ {
|
|
|
214710
214937
|
}
|
|
214711
214938
|
/**
|
|
214712
214939
|
* If this vector has nonzero length, divide by the length to change to a unit vector.
|
|
214713
|
-
* @returns true if normalization
|
|
214940
|
+
* @returns true if normalization was successful
|
|
214714
214941
|
*/
|
|
214715
214942
|
normalizeInPlace() {
|
|
214716
|
-
|
|
214717
|
-
if (a === undefined)
|
|
214718
|
-
return false;
|
|
214719
|
-
this.x *= a;
|
|
214720
|
-
this.y *= a;
|
|
214721
|
-
this.z *= a;
|
|
214722
|
-
return true;
|
|
214943
|
+
return this.normalizeWithLength(this).v !== undefined;
|
|
214723
214944
|
}
|
|
214724
214945
|
/**
|
|
214725
214946
|
* Create a normalized vector from the inputs.
|
|
@@ -214739,7 +214960,7 @@ class Vector3d extends XYZ {
|
|
|
214739
214960
|
* Return fractional projection of this vector on the target vector.
|
|
214740
214961
|
* * It's returning the signed projection magnitude divided by the target magnitude.
|
|
214741
214962
|
* * To find the projection vector, scale the target vector by the value that this function is returning.
|
|
214742
|
-
* *
|
|
214963
|
+
* * Math details can be found at docs/learning/geometry/PointVector.md
|
|
214743
214964
|
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnVector
|
|
214744
214965
|
* and https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane
|
|
214745
214966
|
* @param target the target vector
|
|
@@ -214954,7 +215175,7 @@ class Vector3d extends XYZ {
|
|
|
214954
215175
|
* @param result optional preallocated result
|
|
214955
215176
|
*/
|
|
214956
215177
|
scaleToLength(length, result) {
|
|
214957
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
215178
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(this.magnitude());
|
|
214958
215179
|
if (mag === 0)
|
|
214959
215180
|
return undefined;
|
|
214960
215181
|
return this.scale(length / mag, result);
|
|
@@ -215005,7 +215226,7 @@ class Vector3d extends XYZ {
|
|
|
215005
215226
|
* @param smallestMagnitude smallest magnitude allowed as divisor.
|
|
215006
215227
|
* @returns false if magnitude is too small. In this case the vector is unchanged.
|
|
215007
215228
|
*/
|
|
215008
|
-
tryNormalizeInPlace(smallestMagnitude = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
215229
|
+
tryNormalizeInPlace(smallestMagnitude = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.smallFraction) {
|
|
215009
215230
|
const a = this.magnitude();
|
|
215010
215231
|
if (a < smallestMagnitude || a === 0.0)
|
|
215011
215232
|
return false;
|
|
@@ -223786,7 +224007,6 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
223786
224007
|
*/
|
|
223787
224008
|
static createPlaneFrom(source) {
|
|
223788
224009
|
return new Point4d(source.normalX(), source.normalY(), source.normalZ(), source.altitudeXYZ(0, 0, 0));
|
|
223789
|
-
return undefined;
|
|
223790
224010
|
}
|
|
223791
224011
|
/** Copy coordinates from `other`. */
|
|
223792
224012
|
setFrom(other) {
|
|
@@ -223929,7 +224149,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
223929
224149
|
* * other structure with members x,y and optional z,w
|
|
223930
224150
|
* * array of numbers
|
|
223931
224151
|
* * default z is 0.0
|
|
223932
|
-
* * default
|
|
224152
|
+
* * default w is 1.0 (array[3] can replace)
|
|
223933
224153
|
*/
|
|
223934
224154
|
static createFromPoint(point) {
|
|
223935
224155
|
if (point instanceof _geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_3__.Point2d)
|
|
@@ -223946,10 +224166,10 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
223946
224166
|
const w1 = point.length > 3 ? point[3] : 1.0;
|
|
223947
224167
|
return new Point4d(x1, y1, z1, w1);
|
|
223948
224168
|
}
|
|
223949
|
-
const x = point.
|
|
223950
|
-
const y = point.
|
|
224169
|
+
const x = point.x;
|
|
224170
|
+
const y = point.y;
|
|
223951
224171
|
const z = point.hasOwnProperty("z") ? point.z : 0.0;
|
|
223952
|
-
const w = point.hasOwnProperty("w") ? point.w :
|
|
224172
|
+
const w = point.hasOwnProperty("w") ? point.w : 1.0;
|
|
223953
224173
|
return new Point4d(x, y, z, w);
|
|
223954
224174
|
}
|
|
223955
224175
|
/** Return `point + vector * scalar` */
|
|
@@ -224076,7 +224296,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224076
224296
|
* @param result optional result
|
|
224077
224297
|
*/
|
|
224078
224298
|
normalizeWeight(result) {
|
|
224079
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224299
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
224080
224300
|
result = result ? result : new Point4d();
|
|
224081
224301
|
return this.safeDivideOrNull(mag, result);
|
|
224082
224302
|
}
|
|
@@ -224086,7 +224306,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224086
224306
|
* @param result optional result
|
|
224087
224307
|
*/
|
|
224088
224308
|
realPoint(result) {
|
|
224089
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224309
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
224090
224310
|
if (mag === 0.0)
|
|
224091
224311
|
return undefined;
|
|
224092
224312
|
const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.
|
|
@@ -224097,7 +224317,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224097
224317
|
* * If `this.w` is zero, return a Vector3d `(x,y,z)`
|
|
224098
224318
|
*/
|
|
224099
224319
|
realPointOrVector() {
|
|
224100
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224320
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
224101
224321
|
if (mag === 0.0)
|
|
224102
224322
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Vector3d.create(this.x, this.y, this.z);
|
|
224103
224323
|
const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.
|
|
@@ -224113,7 +224333,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224113
224333
|
* @param result optional result
|
|
224114
224334
|
*/
|
|
224115
224335
|
static createRealPoint3dDefault000(x, y, z, w, result) {
|
|
224116
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224336
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(w);
|
|
224117
224337
|
const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.
|
|
224118
224338
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Point3d.create(x * a, y * a, z * a, result);
|
|
224119
224339
|
}
|
|
@@ -224131,7 +224351,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224131
224351
|
* @param result optional result
|
|
224132
224352
|
*/
|
|
224133
224353
|
static createRealDerivativeRay3dDefault000(x, y, z, w, dx, dy, dz, dw, result) {
|
|
224134
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224354
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(w);
|
|
224135
224355
|
// real point is X/w.
|
|
224136
224356
|
// real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.
|
|
224137
224357
|
const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.
|
|
@@ -224152,7 +224372,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224152
224372
|
* @param result optional result
|
|
224153
224373
|
*/
|
|
224154
224374
|
static createRealDerivativePlane3dByOriginAndVectorsDefault000(x, y, z, w, dx, dy, dz, dw, ddx, ddy, ddz, ddw, result) {
|
|
224155
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224375
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(w);
|
|
224156
224376
|
// real point is X/w.
|
|
224157
224377
|
// real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.
|
|
224158
224378
|
const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.
|
|
@@ -224170,7 +224390,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224170
224390
|
* * If this.w is zero, return 000
|
|
224171
224391
|
*/
|
|
224172
224392
|
realPointDefault000(result) {
|
|
224173
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224393
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
224174
224394
|
if (mag === 0.0)
|
|
224175
224395
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Point3d.create(0, 0, 0, result);
|
|
224176
224396
|
result = result ? result : new _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Point3d();
|
|
@@ -224183,7 +224403,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
224183
224403
|
* * Use normalizeWeight to divide by the w component.
|
|
224184
224404
|
*/
|
|
224185
224405
|
normalizeXYZW(result) {
|
|
224186
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
224406
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.magnitudeXYZW());
|
|
224187
224407
|
result = result ? result : new Point4d();
|
|
224188
224408
|
return this.safeDivideOrNull(mag, result);
|
|
224189
224409
|
}
|
|
@@ -289137,7 +289357,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.21.4","description":"P
|
|
|
289137
289357
|
/***/ ((module) => {
|
|
289138
289358
|
|
|
289139
289359
|
"use strict";
|
|
289140
|
-
module.exports = JSON.parse('{"name":"@itwin/core-frontend","version":"4.0.0-dev.
|
|
289360
|
+
module.exports = JSON.parse('{"name":"@itwin/core-frontend","version":"4.0.0-dev.68","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2020 --outDir lib/esm","clean":"rimraf lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","docs":"betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/primitives,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-eslintrc -c \\"./node_modules/@itwin/eslint-plugin/dist/configs/extension-exports-config.js\\" \\"./src/**/*.ts\\" 1>&2","lint":"eslint -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run -s webpackTests && certa -r chrome","cover":"npm -s test","test:debug":"certa -r chrome --debug","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:^4.0.0-dev.68","@itwin/core-bentley":"workspace:^4.0.0-dev.68","@itwin/core-common":"workspace:^4.0.0-dev.68","@itwin/core-geometry":"workspace:^4.0.0-dev.68","@itwin/core-orbitgt":"workspace:^4.0.0-dev.68","@itwin/core-quantity":"workspace:^4.0.0-dev.68"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/certa":"workspace:*","@itwin/eslint-plugin":"^4.0.0-dev.32","@itwin/webgl-compatibility":"workspace:*","@types/chai":"4.3.1","@types/chai-as-promised":"^7","@types/deep-assign":"^0.1.0","@types/mocha":"^8.2.2","@types/node":"^18.11.5","@types/qs":"^6.5.0","@types/semver":"7.3.10","@types/superagent":"^4.1.14","@types/sinon":"^9.0.0","babel-loader":"~8.2.5","babel-plugin-istanbul":"~6.1.1","chai":"^4.1.2","chai-as-promised":"^7","cpx2":"^3.0.0","eslint":"^7.11.0","glob":"^7.1.2","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^3.0.2","sinon":"^9.0.2","source-map-loader":"^4.0.0","typescript":"~5.0.2","webpack":"^5.76.0"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/object-storage-azure":"^1.5.0","@itwin/cloud-agnostic-core":"^1.5.0","@itwin/object-storage-core":"^1.5.0","@itwin/core-i18n":"workspace:*","@itwin/core-telemetry":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^3.1.6","@loaders.gl/draco":"^3.1.6","deep-assign":"^2.0.0","fuse.js":"^3.3.0","qs":"^6.5.3","semver":"^7.3.5","superagent":"^7.1.5","wms-capabilities":"0.4.0","reflect-metadata":"0.1.13"},"nyc":{"extends":"./node_modules/@itwin/build-tools/.nycrc"},"eslintConfig":{"plugins":["@itwin"],"extends":"plugin:@itwin/itwinjs-recommended","rules":{"@itwin/no-internal-barrel-imports":["error",{"required-barrel-modules":["./src/tile/internal.ts"]}],"@itwin/public-extension-exports":["error",{"releaseTags":["public","preview"],"outputApiFile":false}]},"overrides":[{"files":["*.test.ts","*.test.tsx","**/test/**/*.ts"],"rules":{"@itwin/no-internal-barrel-imports":"off"}}]}}');
|
|
289141
289361
|
|
|
289142
289362
|
/***/ })
|
|
289143
289363
|
|