@itwin/rpcinterface-full-stack-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 +591 -371
- 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 +13 -13
|
@@ -61961,27 +61961,63 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
61961
61961
|
* @module Geometry
|
|
61962
61962
|
*/
|
|
61963
61963
|
|
|
61964
|
+
/*
|
|
61965
|
+
The following visualizes the contents of frustum.points, which is sent to computeFrustumPlanes().
|
|
61966
|
+
The below numbers are the indices into that array.
|
|
61967
|
+
|
|
61968
|
+
2----------3
|
|
61969
|
+
/| /|
|
|
61970
|
+
/ 0--------/-1
|
|
61971
|
+
6----------7 /
|
|
61972
|
+
| / | /
|
|
61973
|
+
|/ |/
|
|
61974
|
+
4__________5
|
|
61975
|
+
|
|
61976
|
+
0 = left bottom rear
|
|
61977
|
+
1 = right bottom rear
|
|
61978
|
+
2 = left top right
|
|
61979
|
+
3 = right top rear
|
|
61980
|
+
4 = left bottom front
|
|
61981
|
+
5 = right bottom front
|
|
61982
|
+
6 = left top front
|
|
61983
|
+
7 = right top front
|
|
61984
|
+
*/
|
|
61985
|
+
// Ordering of sub-arrays is: [origin, a, b]
|
|
61964
61986
|
const planePointIndices = [
|
|
61965
|
-
[1,
|
|
61966
|
-
[0,
|
|
61967
|
-
[2,
|
|
61968
|
-
[0,
|
|
61969
|
-
[0,
|
|
61970
|
-
|
|
61987
|
+
[1, 5, 3],
|
|
61988
|
+
[0, 2, 4],
|
|
61989
|
+
[2, 3, 6],
|
|
61990
|
+
[0, 4, 1],
|
|
61991
|
+
[0, 1, 2], // back
|
|
61992
|
+
// Skip front plane because it can be too small. Instead derive it from back plane.
|
|
61993
|
+
// Otherwise, it would be: [4, 6, 5]
|
|
61971
61994
|
];
|
|
61972
61995
|
function computeFrustumPlanes(frustum) {
|
|
61973
61996
|
const planes = [];
|
|
61974
61997
|
const points = frustum.points;
|
|
61975
61998
|
const expandPlaneDistance = 1e-6;
|
|
61999
|
+
let normal;
|
|
61976
62000
|
for (const indices of planePointIndices) {
|
|
61977
62001
|
const i0 = indices[0], i1 = indices[1], i2 = indices[2];
|
|
61978
|
-
|
|
62002
|
+
normal = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_0__.Vector3d.createCrossProductToPoints(points[i0], points[i1], points[i2]);
|
|
61979
62003
|
normal.normalizeInPlace();
|
|
61980
62004
|
const plane = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_0__.ClipPlane.createNormalAndDistance(normal, normal.dotProduct(points[i0]) - expandPlaneDistance);
|
|
61981
62005
|
if (!plane)
|
|
61982
62006
|
return [];
|
|
61983
62007
|
planes.push(plane);
|
|
61984
62008
|
}
|
|
62009
|
+
// 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.
|
|
62010
|
+
// The back plane was the last plane processed above, so we can just consult the current value of `normal`.
|
|
62011
|
+
if (undefined !== normal) {
|
|
62012
|
+
normal.negate(normal); // negate the back plane
|
|
62013
|
+
// NB: Below, we make sure we calculate the distance based on a point on the front rect, not the rear rect!
|
|
62014
|
+
const plane = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_0__.ClipPlane.createNormalAndDistance(normal, normal.dotProduct(points[4]) - expandPlaneDistance);
|
|
62015
|
+
if (!plane)
|
|
62016
|
+
return [];
|
|
62017
|
+
planes.push(plane);
|
|
62018
|
+
}
|
|
62019
|
+
else
|
|
62020
|
+
return [];
|
|
61985
62021
|
return planes;
|
|
61986
62022
|
}
|
|
61987
62023
|
// Scratch variable used by FrustumPlanes.computeContainment.
|
|
@@ -61997,6 +62033,7 @@ class FrustumPlanes {
|
|
|
61997
62033
|
}
|
|
61998
62034
|
/** Compute the six planes of the specified frustum.
|
|
61999
62035
|
* If the frustum is degenerate - that is, its points do not represent a truncated pyramid - then the returned `FrustumPlanes` will contain zero planes.
|
|
62036
|
+
* @note This method assumes that the front plane is parallel to the back plane.
|
|
62000
62037
|
* @see [[isValid]] to test this condition.
|
|
62001
62038
|
*/
|
|
62002
62039
|
static fromFrustum(frustum) {
|
|
@@ -62023,6 +62060,7 @@ class FrustumPlanes {
|
|
|
62023
62060
|
}
|
|
62024
62061
|
/** Recompute the planes from the specified frustum.
|
|
62025
62062
|
* @returns true upon success, or false if the input frustum was degenerate, in which case [[isValid]] will be `false`.
|
|
62063
|
+
* @note This method assumes that the front plane is parallel to the back plane.
|
|
62026
62064
|
*/
|
|
62027
62065
|
init(frustum) {
|
|
62028
62066
|
this._planes = computeFrustumPlanes(frustum);
|
|
@@ -175832,7 +175870,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
175832
175870
|
/**
|
|
175833
175871
|
* Enumeration of the 6 possible orderings of XYZ axis order
|
|
175834
175872
|
* * **Note:** There are 3 axis order with right hand system (XYZ = 0, YZX = 1, ZXY = 2) and 3 axis order with
|
|
175835
|
-
* left hand system (XZY = 4, YXZ = 5, ZYX = 6). Note that AxisOrder is encoding the handedness as well. Cross
|
|
175873
|
+
* left hand system (XZY = 4, YXZ = 5, ZYX = 6). Note that `AxisOrder` is encoding the handedness as well. Cross
|
|
175836
175874
|
* 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
|
|
175837
175875
|
* axis in that ordering.
|
|
175838
175876
|
* @public
|
|
@@ -175865,7 +175903,8 @@ var AxisIndex;
|
|
|
175865
175903
|
/** 2 axis is index 2 */
|
|
175866
175904
|
AxisIndex[AxisIndex["Z"] = 2] = "Z";
|
|
175867
175905
|
})(AxisIndex || (AxisIndex = {}));
|
|
175868
|
-
/**
|
|
175906
|
+
/**
|
|
175907
|
+
* Standard views. Used in `Matrix3d.createStandardViewAxes(index: StandardViewIndex, invert: boolean)`
|
|
175869
175908
|
* @public
|
|
175870
175909
|
*/
|
|
175871
175910
|
var StandardViewIndex;
|
|
@@ -175874,20 +175913,21 @@ var StandardViewIndex;
|
|
|
175874
175913
|
StandardViewIndex[StandardViewIndex["Top"] = 1] = "Top";
|
|
175875
175914
|
/** X to right, negative Y up */
|
|
175876
175915
|
StandardViewIndex[StandardViewIndex["Bottom"] = 2] = "Bottom";
|
|
175877
|
-
/**
|
|
175916
|
+
/** Negative Y to right, Z up */
|
|
175878
175917
|
StandardViewIndex[StandardViewIndex["Left"] = 3] = "Left";
|
|
175879
|
-
/**
|
|
175918
|
+
/** Y to right, Z up */
|
|
175880
175919
|
StandardViewIndex[StandardViewIndex["Right"] = 4] = "Right";
|
|
175881
175920
|
/** X to right, Z up */
|
|
175882
175921
|
StandardViewIndex[StandardViewIndex["Front"] = 5] = "Front";
|
|
175883
|
-
/**
|
|
175922
|
+
/** Negative X to right, Z up */
|
|
175884
175923
|
StandardViewIndex[StandardViewIndex["Back"] = 6] = "Back";
|
|
175885
|
-
/**
|
|
175924
|
+
/** Isometric: view towards origin from (-1,-1,1) */
|
|
175886
175925
|
StandardViewIndex[StandardViewIndex["Iso"] = 7] = "Iso";
|
|
175887
|
-
/**
|
|
175926
|
+
/** Right isometric: view towards origin from (1,-1,1) */
|
|
175888
175927
|
StandardViewIndex[StandardViewIndex["RightIso"] = 8] = "RightIso";
|
|
175889
175928
|
})(StandardViewIndex || (StandardViewIndex = {}));
|
|
175890
|
-
/**
|
|
175929
|
+
/**
|
|
175930
|
+
* Enumeration among choice for how a coordinate transformation should incorporate scaling.
|
|
175891
175931
|
* @public
|
|
175892
175932
|
*/
|
|
175893
175933
|
var AxisScaleSelect;
|
|
@@ -175899,7 +175939,8 @@ var AxisScaleSelect;
|
|
|
175899
175939
|
/** On each axis, the vector length matches he length of the corresponding edge of the range. */
|
|
175900
175940
|
AxisScaleSelect[AxisScaleSelect["NonUniformRangeContainment"] = 2] = "NonUniformRangeContainment";
|
|
175901
175941
|
})(AxisScaleSelect || (AxisScaleSelect = {}));
|
|
175902
|
-
/**
|
|
175942
|
+
/**
|
|
175943
|
+
* Enumeration of possible locations of a point in the plane of a polygon.
|
|
175903
175944
|
* @public
|
|
175904
175945
|
*/
|
|
175905
175946
|
var PolygonLocation;
|
|
@@ -175932,18 +175973,26 @@ var PolygonLocation;
|
|
|
175932
175973
|
* @public
|
|
175933
175974
|
*/
|
|
175934
175975
|
class Geometry {
|
|
175935
|
-
/** Test if absolute value of x is
|
|
175936
|
-
|
|
175976
|
+
/** Test if absolute value of x is large (larger than `Geometry.largeCoordinateResult`) */
|
|
175977
|
+
static isLargeCoordinateResult(x) {
|
|
175978
|
+
return x > this.largeCoordinateResult || x < -this.largeCoordinateResult;
|
|
175979
|
+
}
|
|
175980
|
+
/**
|
|
175981
|
+
* Test if absolute value of x is large (larger than `Geometry.largeCoordinateResult`).
|
|
175982
|
+
* @deprecated in 4.x. Use `isLargeCoordinateResult`.
|
|
175937
175983
|
*/
|
|
175938
175984
|
static isHugeCoordinate(x) {
|
|
175939
|
-
return
|
|
175985
|
+
return Geometry.isLargeCoordinateResult(x);
|
|
175940
175986
|
}
|
|
175941
|
-
/** Test if a number is odd
|
|
175942
|
-
*/
|
|
175987
|
+
/** Test if a number is odd */
|
|
175943
175988
|
static isOdd(x) {
|
|
175944
|
-
return (x & (0x01)) === 1;
|
|
175989
|
+
return (x & (0x01)) === 1; // bitwise operation
|
|
175945
175990
|
}
|
|
175946
|
-
/**
|
|
175991
|
+
/**
|
|
175992
|
+
* Correct distance to zero.
|
|
175993
|
+
* * If `distance` magnitude is `undefined` or smaller than `smallMetricDistance`, then return `replacement`
|
|
175994
|
+
* (or 0 if replacement is not passed). Otherwise return `distance`.
|
|
175995
|
+
*/
|
|
175947
175996
|
static correctSmallMetricDistance(distance, replacement = 0.0) {
|
|
175948
175997
|
if (distance === undefined || Math.abs(distance) < Geometry.smallMetricDistance) {
|
|
175949
175998
|
return replacement;
|
|
@@ -175951,64 +176000,119 @@ class Geometry {
|
|
|
175951
176000
|
return distance;
|
|
175952
176001
|
}
|
|
175953
176002
|
/**
|
|
175954
|
-
|
|
175955
|
-
|
|
175956
|
-
|
|
175957
|
-
|
|
175958
|
-
|
|
176003
|
+
* Correct `fraction` to `replacement` if `fraction` is undefined or too small.
|
|
176004
|
+
* @param fraction number to test
|
|
176005
|
+
* @param replacement value to return if `fraction` is too small
|
|
176006
|
+
* @returns `fraction` if its absolute value is at least `Geometry.smallFraction`; otherwise returns `replacement`
|
|
176007
|
+
*/
|
|
176008
|
+
static correctSmallFraction(fraction, replacement = 0.0) {
|
|
176009
|
+
if (fraction === undefined || Math.abs(fraction) < Geometry.smallFraction) {
|
|
176010
|
+
return replacement;
|
|
176011
|
+
}
|
|
176012
|
+
return fraction;
|
|
175959
176013
|
}
|
|
175960
176014
|
/**
|
|
175961
|
-
*
|
|
175962
|
-
*
|
|
176015
|
+
* Return the inverse of `distance`.
|
|
176016
|
+
* * If `distance` magnitude is smaller than `smallMetricDistance` (i.e. distance is large enough for safe division),
|
|
176017
|
+
* then return `1/distance`. Otherwise return `undefined`.
|
|
175963
176018
|
*/
|
|
175964
|
-
static
|
|
175965
|
-
return (Math.abs(
|
|
176019
|
+
static inverseMetricDistance(distance) {
|
|
176020
|
+
return (Math.abs(distance) <= Geometry.smallMetricDistance) ? undefined : 1.0 / distance;
|
|
175966
176021
|
}
|
|
175967
176022
|
/**
|
|
175968
|
-
*
|
|
175969
|
-
* `
|
|
176023
|
+
* Return the inverse of `distanceSquared`.
|
|
176024
|
+
* * If `distanceSquared ` magnitude is smaller than `smallMetricDistanceSquared` (i.e. distanceSquared is large
|
|
176025
|
+
* enough for safe division), then return `1/distanceSquared `. Otherwise return `undefined`.
|
|
175970
176026
|
*/
|
|
175971
|
-
static
|
|
175972
|
-
|
|
175973
|
-
return Math.abs(x - y) < Math.abs(tol);
|
|
175974
|
-
return Math.abs(x - y) < Geometry.smallMetricDistance;
|
|
176027
|
+
static inverseMetricDistanceSquared(distanceSquared) {
|
|
176028
|
+
return (Math.abs(distanceSquared) <= Geometry.smallMetricDistanceSquared) ? undefined : 1.0 / distanceSquared;
|
|
175975
176029
|
}
|
|
175976
|
-
/**
|
|
176030
|
+
/**
|
|
176031
|
+
* Boolean test for metric coordinate near-equality (i.e., if `x` and `y` are almost equal) using `tolerance`.
|
|
176032
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176033
|
+
*/
|
|
176034
|
+
static isSameCoordinate(x, y, tolerance = Geometry.smallMetricDistance) {
|
|
176035
|
+
let d = x - y;
|
|
176036
|
+
if (d < 0)
|
|
176037
|
+
d = -d;
|
|
176038
|
+
return d <= tolerance;
|
|
176039
|
+
}
|
|
176040
|
+
/**
|
|
176041
|
+
* Boolean test for metric coordinate near-equality (i.e., if `x` and `y` are almost equal) using
|
|
176042
|
+
* `tolerance = toleranceFactor * smallMetricDistance`
|
|
176043
|
+
* */
|
|
175977
176044
|
static isSameCoordinateWithToleranceFactor(x, y, toleranceFactor) {
|
|
175978
176045
|
return Geometry.isSameCoordinate(x, y, toleranceFactor * Geometry.smallMetricDistance);
|
|
175979
176046
|
}
|
|
175980
|
-
/**
|
|
175981
|
-
|
|
176047
|
+
/**
|
|
176048
|
+
* Boolean test for metric coordinate pair near-equality (i.e., if `x0` and `x1` are almost equal
|
|
176049
|
+
* and `y0` and `y1` are almost equal) using `tolerance`.
|
|
176050
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176051
|
+
*/
|
|
176052
|
+
static isSameCoordinateXY(x0, y0, x1, y1, tolerance = Geometry.smallMetricDistance) {
|
|
175982
176053
|
let d = x1 - x0;
|
|
175983
176054
|
if (d < 0)
|
|
175984
176055
|
d = -d;
|
|
175985
|
-
if (d >
|
|
176056
|
+
if (d > tolerance)
|
|
175986
176057
|
return false;
|
|
175987
176058
|
d = y1 - y0;
|
|
175988
176059
|
if (d < 0)
|
|
175989
176060
|
d = -d;
|
|
175990
|
-
return d
|
|
175991
|
-
}
|
|
175992
|
-
/**
|
|
175993
|
-
|
|
175994
|
-
|
|
175995
|
-
|
|
175996
|
-
|
|
175997
|
-
static
|
|
175998
|
-
|
|
175999
|
-
|
|
176000
|
-
|
|
176001
|
-
|
|
176002
|
-
|
|
176003
|
-
|
|
176004
|
-
|
|
176005
|
-
|
|
176006
|
-
|
|
176007
|
-
|
|
176008
|
-
|
|
176009
|
-
|
|
176010
|
-
|
|
176011
|
-
|
|
176061
|
+
return d <= tolerance;
|
|
176062
|
+
}
|
|
176063
|
+
/**
|
|
176064
|
+
* Boolean test for squared metric coordinate near-equality (i.e., if `sqrt(x)` and `sqrt(y)` are
|
|
176065
|
+
* almost equal) using `tolerance`.
|
|
176066
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176067
|
+
*/
|
|
176068
|
+
static isSameCoordinateSquared(x, y, tolerance = Geometry.smallMetricDistance) {
|
|
176069
|
+
return Math.abs(Math.sqrt(x) - Math.sqrt(y)) <= tolerance;
|
|
176070
|
+
}
|
|
176071
|
+
/**
|
|
176072
|
+
* Boolean test for small `dataA.distance(dataB)` within `tolerance`.
|
|
176073
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176074
|
+
*/
|
|
176075
|
+
static isSamePoint3d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
176076
|
+
return dataA.distance(dataB) <= tolerance;
|
|
176077
|
+
}
|
|
176078
|
+
/**
|
|
176079
|
+
* Boolean test for small xyz-distance within `tolerance`.
|
|
176080
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176081
|
+
* * Note that Point3d and Vector3d are both derived from XYZ, so this method tolerates mixed types.
|
|
176082
|
+
*/
|
|
176083
|
+
static isSameXYZ(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
176084
|
+
return dataA.distance(dataB) <= tolerance;
|
|
176085
|
+
}
|
|
176086
|
+
/**
|
|
176087
|
+
* Boolean test for small xy-distance (ignoring z) within `tolerance`.
|
|
176088
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176089
|
+
*/
|
|
176090
|
+
static isSamePoint3dXY(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
176091
|
+
return dataA.distanceXY(dataB) <= tolerance;
|
|
176092
|
+
}
|
|
176093
|
+
/**
|
|
176094
|
+
* Boolean test for small xyz-distance within `tolerance`.
|
|
176095
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176096
|
+
*/
|
|
176097
|
+
static isSameVector3d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
176098
|
+
return dataA.distance(dataB) <= tolerance;
|
|
176099
|
+
}
|
|
176100
|
+
/**
|
|
176101
|
+
* Boolean test for small xy-distance within `tolerance`.
|
|
176102
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176103
|
+
*/
|
|
176104
|
+
static isSamePoint2d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
176105
|
+
return dataA.distance(dataB) <= tolerance;
|
|
176106
|
+
}
|
|
176107
|
+
/**
|
|
176108
|
+
* Boolean test for small xy-distance within `tolerance`.
|
|
176109
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176110
|
+
*/
|
|
176111
|
+
static isSameVector2d(dataA, dataB, tolerance = Geometry.smallMetricDistance) {
|
|
176112
|
+
return dataA.distance(dataB) <= tolerance;
|
|
176113
|
+
}
|
|
176114
|
+
/**
|
|
176115
|
+
* Lexical comparison of (a.x, a.y) and (b.x, b.y) with x as first test and y as second (z is ignored).
|
|
176012
176116
|
* * This is appropriate for a horizontal sweep in the plane.
|
|
176013
176117
|
*/
|
|
176014
176118
|
static lexicalXYLessThan(a, b) {
|
|
@@ -176023,7 +176127,7 @@ class Geometry {
|
|
|
176023
176127
|
return 0;
|
|
176024
176128
|
}
|
|
176025
176129
|
/**
|
|
176026
|
-
* Lexical comparison of (a.x,a.y) (b.x,b.y) with y as first test
|
|
176130
|
+
* Lexical comparison of (a.x, a.y) and (b.x, b.y) with y as first test and x as second (z is ignored).
|
|
176027
176131
|
* * This is appropriate for a vertical sweep in the plane.
|
|
176028
176132
|
*/
|
|
176029
176133
|
static lexicalYXLessThan(a, b) {
|
|
@@ -176037,9 +176141,7 @@ class Geometry {
|
|
|
176037
176141
|
return 1;
|
|
176038
176142
|
return 0;
|
|
176039
176143
|
}
|
|
176040
|
-
/**
|
|
176041
|
-
* Lexical test, based on x first, y second, z third.
|
|
176042
|
-
*/
|
|
176144
|
+
/** 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. */
|
|
176043
176145
|
static lexicalXYZLessThan(a, b) {
|
|
176044
176146
|
if (a.x < b.x)
|
|
176045
176147
|
return -1;
|
|
@@ -176055,19 +176157,21 @@ class Geometry {
|
|
|
176055
176157
|
return 1;
|
|
176056
176158
|
return 0;
|
|
176057
176159
|
}
|
|
176058
|
-
/**
|
|
176160
|
+
/**
|
|
176161
|
+
* Test if `value` is small compared to `smallFraction`.
|
|
176059
176162
|
* * This is appropriate if `value` is know to be a typical 0..1 fraction.
|
|
176060
176163
|
*/
|
|
176061
176164
|
static isSmallRelative(value) {
|
|
176062
|
-
return Math.abs(value) < Geometry.
|
|
176165
|
+
return Math.abs(value) < Geometry.smallFraction;
|
|
176063
176166
|
}
|
|
176064
176167
|
/** Test if `value` is small compared to `smallAngleRadians` */
|
|
176065
176168
|
static isSmallAngleRadians(value) {
|
|
176066
176169
|
return Math.abs(value) < Geometry.smallAngleRadians;
|
|
176067
176170
|
}
|
|
176068
|
-
/**
|
|
176069
|
-
*
|
|
176070
|
-
|
|
176171
|
+
/**
|
|
176172
|
+
* Returns `true` if both values are `undefined` or if both are defined and almost equal within tolerance.
|
|
176173
|
+
* If one is `undefined` and the other is not, then `false` is returned.
|
|
176174
|
+
*/
|
|
176071
176175
|
static isAlmostEqualOptional(a, b, tolerance) {
|
|
176072
176176
|
if (a !== undefined && b !== undefined) {
|
|
176073
176177
|
if (Math.abs(a - b) > tolerance)
|
|
@@ -176079,44 +176183,43 @@ class Geometry {
|
|
|
176079
176183
|
}
|
|
176080
176184
|
return true;
|
|
176081
176185
|
}
|
|
176082
|
-
/**
|
|
176083
|
-
*
|
|
176084
|
-
|
|
176085
|
-
|
|
176186
|
+
/**
|
|
176187
|
+
* Toleranced equality test using tolerance `tolerance * ( 1 + abs(a) + abs(b) )`.
|
|
176188
|
+
* * `Geometry.smallAngleRadians` is used if tolerance is `undefined`.
|
|
176189
|
+
*/
|
|
176190
|
+
static isAlmostEqualNumber(a, b, tolerance = Geometry.smallAngleRadians) {
|
|
176086
176191
|
const sumAbs = 1.0 + Math.abs(a) + Math.abs(b);
|
|
176087
|
-
return Math.abs(a - b) <=
|
|
176192
|
+
return Math.abs(a - b) <= tolerance * sumAbs;
|
|
176088
176193
|
}
|
|
176089
|
-
/**
|
|
176090
|
-
*
|
|
176091
|
-
|
|
176092
|
-
|
|
176093
|
-
|
|
176094
|
-
const
|
|
176095
|
-
return Math.abs(a.x - b.x) <=
|
|
176194
|
+
/**
|
|
176195
|
+
* Toleranced equality test using tolerance `tolerance * ( 1 + abs(a.x) + abs(a.y) + abs(b.x) + abs(b.y) )`.
|
|
176196
|
+
* * `Geometry.smallAngleRadians` is used if tolerance is `undefined`.
|
|
176197
|
+
*/
|
|
176198
|
+
static isAlmostEqualXAndY(a, b, tolerance = Geometry.smallAngleRadians) {
|
|
176199
|
+
const tol = tolerance * (1.0 + Math.abs(a.x) + Math.abs(b.x) + Math.abs(a.y) + Math.abs(b.y));
|
|
176200
|
+
return (Math.abs(a.x - b.x) <= tol) && (Math.abs(a.y - b.y) <= tol);
|
|
176096
176201
|
}
|
|
176097
176202
|
/**
|
|
176098
|
-
* Toleranced equality test
|
|
176099
|
-
*
|
|
176203
|
+
* Toleranced equality test using caller-supplied `tolerance`.
|
|
176204
|
+
* * `Geometry.smallMetricDistance` is used if tolerance is `undefined`.
|
|
176100
176205
|
*/
|
|
176101
|
-
static isDistanceWithinTol(distance,
|
|
176102
|
-
|
|
176103
|
-
return Math.abs(distance) <= Math.abs(tol);
|
|
176104
|
-
return Math.abs(distance) <= Geometry.smallMetricDistance;
|
|
176206
|
+
static isDistanceWithinTol(distance, tolerance = Geometry.smallMetricDistance) {
|
|
176207
|
+
return Math.abs(distance) <= tolerance;
|
|
176105
176208
|
}
|
|
176106
|
-
/** Toleranced equality test
|
|
176209
|
+
/** Toleranced equality test using `smallMetricDistance` tolerance. */
|
|
176107
176210
|
static isSmallMetricDistance(distance) {
|
|
176108
176211
|
return Math.abs(distance) <= Geometry.smallMetricDistance;
|
|
176109
176212
|
}
|
|
176110
|
-
/** Toleranced equality
|
|
176213
|
+
/** Toleranced equality test using `smallMetricDistanceSquared` tolerance. */
|
|
176111
176214
|
static isSmallMetricDistanceSquared(distanceSquared) {
|
|
176112
176215
|
return Math.abs(distanceSquared) <= Geometry.smallMetricDistanceSquared;
|
|
176113
176216
|
}
|
|
176114
176217
|
/**
|
|
176115
176218
|
* Return `axis modulo 3` with proper handling of negative indices
|
|
176116
176219
|
* ..., -3:x, -2:y, -1:z, 0:x, 1:y, 2:z, 3:x, 4:y, 5:z, 6:x, 7:y, 8:z, ...
|
|
176117
|
-
|
|
176220
|
+
*/
|
|
176118
176221
|
static cyclic3dAxis(axis) {
|
|
176119
|
-
/* Direct test for the most common cases
|
|
176222
|
+
/* Direct test for the most common cases to avoid more expensive modulo operation */
|
|
176120
176223
|
if (axis >= 0) {
|
|
176121
176224
|
if (axis < 3)
|
|
176122
176225
|
return axis;
|
|
@@ -176129,7 +176232,8 @@ class Geometry {
|
|
|
176129
176232
|
return j;
|
|
176130
176233
|
return 2 - ((-axis - 1) % 3);
|
|
176131
176234
|
}
|
|
176132
|
-
/**
|
|
176235
|
+
/**
|
|
176236
|
+
* Return the `AxisOrder` for which `axisIndex` is the first named axis.
|
|
176133
176237
|
* * `axisIndex === 0` returns `AxisOrder.XYZ`
|
|
176134
176238
|
* * `axisIndex === 1` returns `AxisOrder.YZX`
|
|
176135
176239
|
* * `axisIndex === 2` returns `AxisOrder.ZXY`
|
|
@@ -176143,32 +176247,55 @@ class Geometry {
|
|
|
176143
176247
|
return AxisOrder.ZXY;
|
|
176144
176248
|
return Geometry.axisIndexToRightHandedAxisOrder(Geometry.cyclic3dAxis(axisIndex));
|
|
176145
176249
|
}
|
|
176146
|
-
/** Return the largest
|
|
176147
|
-
static
|
|
176148
|
-
|
|
176250
|
+
/** Return the largest signed value among `a`, `b`, and `c` */
|
|
176251
|
+
static maxXYZ(a, b, c) {
|
|
176252
|
+
let max = a;
|
|
176253
|
+
if (b > max)
|
|
176254
|
+
max = b;
|
|
176255
|
+
if (c > max)
|
|
176256
|
+
max = c;
|
|
176257
|
+
return max;
|
|
176258
|
+
}
|
|
176259
|
+
/** Return the smallest signed value among `a`, `b`, and `c` */
|
|
176260
|
+
static minXYZ(a, b, c) {
|
|
176261
|
+
let min = a;
|
|
176262
|
+
if (b < min)
|
|
176263
|
+
min = b;
|
|
176264
|
+
if (c < min)
|
|
176265
|
+
min = c;
|
|
176266
|
+
return min;
|
|
176267
|
+
}
|
|
176268
|
+
/** Return the largest signed value among `a` and `b` */
|
|
176269
|
+
static maxXY(a, b) {
|
|
176270
|
+
let max = a;
|
|
176271
|
+
if (b > max)
|
|
176272
|
+
max = b;
|
|
176273
|
+
return max;
|
|
176149
176274
|
}
|
|
176150
|
-
/** Return the
|
|
176275
|
+
/** Return the smallest signed value among `a` and `b` */
|
|
176276
|
+
static minXY(a, b) {
|
|
176277
|
+
let min = a;
|
|
176278
|
+
if (b < min)
|
|
176279
|
+
min = b;
|
|
176280
|
+
return min;
|
|
176281
|
+
}
|
|
176282
|
+
/** Return the largest absolute value among `x`, `y`, and `z` */
|
|
176151
176283
|
static maxAbsXYZ(x, y, z) {
|
|
176152
176284
|
return Geometry.maxXYZ(Math.abs(x), Math.abs(y), Math.abs(z));
|
|
176153
176285
|
}
|
|
176154
|
-
/** Return the largest absolute
|
|
176286
|
+
/** Return the largest absolute value among `x` and `y` */
|
|
176155
176287
|
static maxAbsXY(x, y) {
|
|
176156
176288
|
return Geometry.maxXY(Math.abs(x), Math.abs(y));
|
|
176157
176289
|
}
|
|
176158
|
-
/** Return the largest
|
|
176159
|
-
static
|
|
176160
|
-
|
|
176161
|
-
if (b > q)
|
|
176162
|
-
q = b;
|
|
176163
|
-
if (c > q)
|
|
176164
|
-
q = c;
|
|
176165
|
-
return q;
|
|
176290
|
+
/** Return the largest absolute distance from `a` to either of `b0` or `b1` */
|
|
176291
|
+
static maxAbsDiff(a, b0, b1) {
|
|
176292
|
+
return Math.max(Math.abs(a - b0), Math.abs(a - b1));
|
|
176166
176293
|
}
|
|
176167
176294
|
/**
|
|
176168
|
-
* Examine the
|
|
176169
|
-
* * If x is negative, return outNegative
|
|
176170
|
-
* * If x is true zero, return outZero
|
|
176171
|
-
* * If x is positive, return outPositive
|
|
176295
|
+
* Examine the sign of `x`.
|
|
176296
|
+
* * If `x` is negative, return `outNegative`
|
|
176297
|
+
* * If `x` is true zero, return `outZero`
|
|
176298
|
+
* * If `x` is positive, return `outPositive`
|
|
176172
176299
|
*/
|
|
176173
176300
|
static split3WaySign(x, outNegative, outZero, outPositive) {
|
|
176174
176301
|
if (x < 0)
|
|
@@ -176190,45 +176317,40 @@ class Geometry {
|
|
|
176190
176317
|
return -1;
|
|
176191
176318
|
return 0;
|
|
176192
176319
|
}
|
|
176193
|
-
/** Return the
|
|
176194
|
-
static
|
|
176195
|
-
|
|
176196
|
-
if (b > q)
|
|
176197
|
-
q = b;
|
|
176198
|
-
return q;
|
|
176199
|
-
}
|
|
176200
|
-
/** Return the smallest signed value among a, b */
|
|
176201
|
-
static minXY(a, b) {
|
|
176202
|
-
let q = a;
|
|
176203
|
-
if (b < q)
|
|
176204
|
-
q = b;
|
|
176205
|
-
return q;
|
|
176320
|
+
/** Return the square of x */
|
|
176321
|
+
static square(x) {
|
|
176322
|
+
return x * x;
|
|
176206
176323
|
}
|
|
176207
|
-
/**
|
|
176324
|
+
/**
|
|
176325
|
+
* Return the hypotenuse (i.e., `sqrt(x*x + y*y)`).
|
|
176326
|
+
* * This is much faster than `Math.hypot(x,y)`.
|
|
176327
|
+
*/
|
|
176208
176328
|
static hypotenuseXY(x, y) {
|
|
176209
176329
|
return Math.sqrt(x * x + y * y);
|
|
176210
176330
|
}
|
|
176211
|
-
/** Return the squared
|
|
176331
|
+
/** Return the squared hypotenuse (i.e., `x*x + y*y`). */
|
|
176212
176332
|
static hypotenuseSquaredXY(x, y) {
|
|
176213
176333
|
return x * x + y * y;
|
|
176214
176334
|
}
|
|
176215
|
-
/**
|
|
176216
|
-
|
|
176217
|
-
|
|
176218
|
-
|
|
176219
|
-
/** Return the hypotenuse `sqrt(x*x + y*y + z*z)`. This is much faster than `Math.hypot(x,y,z)`. */
|
|
176335
|
+
/**
|
|
176336
|
+
* Return the hypotenuse (i.e., `sqrt(x*x + y*y + z*z)`).
|
|
176337
|
+
* * This is much faster than `Math.hypot(x,y,z)`.
|
|
176338
|
+
*/
|
|
176220
176339
|
static hypotenuseXYZ(x, y, z) {
|
|
176221
176340
|
return Math.sqrt(x * x + y * y + z * z);
|
|
176222
176341
|
}
|
|
176223
|
-
/** Return the squared hypotenuse `
|
|
176342
|
+
/** Return the squared hypotenuse (i.e., `x*x + y*y + z*z`). */
|
|
176224
176343
|
static hypotenuseSquaredXYZ(x, y, z) {
|
|
176225
176344
|
return x * x + y * y + z * z;
|
|
176226
176345
|
}
|
|
176227
|
-
/**
|
|
176346
|
+
/**
|
|
176347
|
+
* Return the full 4d hypotenuse (i.e., `sqrt(x*x + y*y + z*z + w*w)`).
|
|
176348
|
+
* * This is much faster than `Math.hypot(x,y,z,w)`.
|
|
176349
|
+
*/
|
|
176228
176350
|
static hypotenuseXYZW(x, y, z, w) {
|
|
176229
176351
|
return Math.sqrt(x * x + y * y + z * z + w * w);
|
|
176230
176352
|
}
|
|
176231
|
-
/** Return the squared hypotenuse `
|
|
176353
|
+
/** Return the squared hypotenuse (i.e., `x*x + y*y + z*z + w*w`). */
|
|
176232
176354
|
static hypotenuseSquaredXYZW(x, y, z, w) {
|
|
176233
176355
|
return x * x + y * y + z * z + w * w;
|
|
176234
176356
|
}
|
|
@@ -176254,8 +176376,8 @@ class Geometry {
|
|
|
176254
176376
|
static distanceXYZXYZ(x0, y0, z0, x1, y1, z1) {
|
|
176255
176377
|
return Geometry.hypotenuseXYZ(x1 - x0, y1 - y0, z1 - z0);
|
|
176256
176378
|
}
|
|
176257
|
-
/**
|
|
176258
|
-
*
|
|
176379
|
+
/**
|
|
176380
|
+
* Returns the triple product of 3 vectors provided as x,y,z number sequences.
|
|
176259
176381
|
* * The triple product is the determinant of the 3x3 matrix with the 9 numbers (3 vectors placed in 3 rows).
|
|
176260
176382
|
* * The triple product is positive if the 3 vectors form a right handed coordinate system.
|
|
176261
176383
|
* * The triple product is negative if the 3 vectors form a left handed coordinate system.
|
|
@@ -176263,170 +176385,196 @@ class Geometry {
|
|
|
176263
176385
|
* * U dot (V cross W)
|
|
176264
176386
|
* * V dot (W cross U)
|
|
176265
176387
|
* * W dot (U cross V)
|
|
176266
|
-
* *
|
|
176267
|
-
* *
|
|
176268
|
-
* *
|
|
176269
|
-
* *
|
|
176388
|
+
* * -U dot (W cross V)
|
|
176389
|
+
* * -V dot (U cross W)
|
|
176390
|
+
* * -W dot (V cross U)
|
|
176391
|
+
* * Note the negative in the last 3 formulas. Reversing cross product order changes the sign.
|
|
176392
|
+
* * The triple product is 6 times the (signed) volume of the tetrahedron with the three vectors as edges from a
|
|
176393
|
+
* common vertex.
|
|
176270
176394
|
*/
|
|
176271
176395
|
static tripleProduct(ux, uy, uz, vx, vy, vz, wx, wy, wz) {
|
|
176272
176396
|
return ux * (vy * wz - vz * wy)
|
|
176273
176397
|
+ uy * (vz * wx - vx * wz)
|
|
176274
176398
|
+ uz * (vx * wy - vy * wx);
|
|
176275
176399
|
}
|
|
176276
|
-
/** Returns the determinant of the 4x4 matrix unrolled as the 16 parameters
|
|
176277
|
-
*/
|
|
176400
|
+
/** Returns the determinant of the 4x4 matrix unrolled as the 16 parameters */
|
|
176278
176401
|
static determinant4x4(xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, wx, wy, wz, ww) {
|
|
176279
176402
|
return xx * this.tripleProduct(yy, yz, yw, zy, zz, zw, wy, wz, ww)
|
|
176280
176403
|
- yx * this.tripleProduct(xy, xz, xw, zy, zz, zw, wy, wz, ww)
|
|
176281
176404
|
+ zx * this.tripleProduct(xy, xz, xw, yy, yz, yw, wy, wz, ww)
|
|
176282
176405
|
- wx * this.tripleProduct(xy, xz, xw, yy, yz, yw, zy, zz, zw);
|
|
176283
176406
|
}
|
|
176284
|
-
/** Return the mean curvature for two radii, with 0 radius implying 0 curvature */
|
|
176285
|
-
static meanCurvatureOfRadii(r0, r1) {
|
|
176286
|
-
return 0.5 * (this.safeDivideFraction(1, r0, 0) + this.safeDivideFraction(1, r1, 0));
|
|
176287
|
-
}
|
|
176288
176407
|
/**
|
|
176289
|
-
|
|
176290
|
-
|
|
176291
|
-
|
|
176292
|
-
|
|
176293
|
-
|
|
176294
|
-
* @param vy second derivative y component
|
|
176295
|
-
* @param vz second derivative z component
|
|
176296
|
-
*/
|
|
176297
|
-
static curvatureMagnitude(ux, uy, uz, vx, vy, vz) {
|
|
176298
|
-
let q = uy * vz - uz * vy;
|
|
176299
|
-
let sum = q * q;
|
|
176300
|
-
q = uz * vx - ux * vz;
|
|
176301
|
-
sum += q * q;
|
|
176302
|
-
q = ux * vy - uy * vx;
|
|
176303
|
-
sum += q * q;
|
|
176304
|
-
const a = Math.sqrt(ux * ux + uy * uy + uz * uz);
|
|
176305
|
-
const b = Math.sqrt(sum);
|
|
176306
|
-
// (sum and a are both nonnegative)
|
|
176307
|
-
const aaa = a * a * a;
|
|
176308
|
-
// radius of curvature = aaa / b;
|
|
176309
|
-
// curvature = b/aaa
|
|
176310
|
-
const tol = Geometry.smallAngleRadians;
|
|
176311
|
-
if (aaa > tol * b)
|
|
176312
|
-
return b / aaa;
|
|
176313
|
-
return 0; // hm.. maybe should be infinite?
|
|
176314
|
-
}
|
|
176315
|
-
/** Returns the determinant of 3x3 matrix with x and y rows taken from 3 points, third row from corresponding numbers.
|
|
176316
|
-
*
|
|
176408
|
+
* Returns the determinant of 3x3 matrix with first and second rows created from the 3 xy points and the third
|
|
176409
|
+
* row created from the 3 numbers:
|
|
176410
|
+
* [columnA.x columnB.x columnC.x]
|
|
176411
|
+
* [columnA.y columnB.y columnC.y]
|
|
176412
|
+
* [ weightA weightB weightC ]
|
|
176317
176413
|
*/
|
|
176318
176414
|
static tripleProductXYW(columnA, weightA, columnB, weightB, columnC, weightC) {
|
|
176319
176415
|
return Geometry.tripleProduct(columnA.x, columnB.x, columnC.x, columnA.y, columnB.y, columnC.y, weightA, weightB, weightC);
|
|
176320
176416
|
}
|
|
176321
|
-
/**
|
|
176322
|
-
*
|
|
176417
|
+
/**
|
|
176418
|
+
* Returns the determinant of 3x3 matrix columns created by the given `Point4d` ignoring the z part:
|
|
176419
|
+
* [columnA.x columnB.x columnC.x]
|
|
176420
|
+
* [columnA.y columnB.y columnC.y]
|
|
176421
|
+
* [columnA.w columnB.w columnC.w]
|
|
176323
176422
|
*/
|
|
176324
176423
|
static tripleProductPoint4dXYW(columnA, columnB, columnC) {
|
|
176325
176424
|
return Geometry.tripleProduct(columnA.x, columnB.x, columnC.x, columnA.y, columnB.y, columnC.y, columnA.w, columnB.w, columnC.w);
|
|
176326
176425
|
}
|
|
176327
|
-
/** 2D cross product of vectors
|
|
176426
|
+
/** 2D cross product of vectors with the vectors presented as numbers. */
|
|
176328
176427
|
static crossProductXYXY(ux, uy, vx, vy) {
|
|
176329
176428
|
return ux * vy - uy * vx;
|
|
176330
176429
|
}
|
|
176331
|
-
/** 3D cross product of vectors
|
|
176430
|
+
/** 3D cross product of vectors with the vectors presented as numbers. */
|
|
176332
176431
|
static crossProductXYZXYZ(ux, uy, uz, vx, vy, vz, result) {
|
|
176333
176432
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_0__.Vector3d.create(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx, result);
|
|
176334
176433
|
}
|
|
176335
|
-
/**
|
|
176434
|
+
/** Magnitude of 3D cross product of vectors with the vectors presented as numbers. */
|
|
176336
176435
|
static crossProductMagnitude(ux, uy, uz, vx, vy, vz) {
|
|
176337
176436
|
return Geometry.hypotenuseXYZ(uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx);
|
|
176338
176437
|
}
|
|
176339
|
-
/**
|
|
176438
|
+
/** 2D dot product of vectors with the vectors presented as numbers. */
|
|
176439
|
+
static dotProductXYXY(ux, uy, vx, vy) {
|
|
176440
|
+
return ux * vx + uy * vy;
|
|
176441
|
+
}
|
|
176442
|
+
/** 3D dot product of vectors with the vectors presented as numbers. */
|
|
176340
176443
|
static dotProductXYZXYZ(ux, uy, uz, vx, vy, vz) {
|
|
176341
176444
|
return ux * vx + uy * vy + uz * vz;
|
|
176342
176445
|
}
|
|
176343
|
-
/**
|
|
176344
|
-
|
|
176345
|
-
|
|
176446
|
+
/**
|
|
176447
|
+
* Return the mean curvature for two radii.
|
|
176448
|
+
* * Curvature is the reciprocal of radius.
|
|
176449
|
+
* * 0 radius implies 0 curvature.
|
|
176450
|
+
* @param r0 first radius
|
|
176451
|
+
* @param r1 second radius
|
|
176452
|
+
*/
|
|
176453
|
+
static meanCurvatureOfRadii(r0, r1) {
|
|
176454
|
+
return 0.5 * (this.safeDivideFraction(1, r0, 0) + this.safeDivideFraction(1, r1, 0));
|
|
176346
176455
|
}
|
|
176347
176456
|
/**
|
|
176348
|
-
*
|
|
176349
|
-
* *
|
|
176350
|
-
*
|
|
176351
|
-
*
|
|
176352
|
-
* @param
|
|
176457
|
+
* Returns curvature from the first and second derivative vectors.
|
|
176458
|
+
* * If U is the first derivative and V is the second derivative, the curvature is defined as:
|
|
176459
|
+
* * `|| U x V || / || U ||^3`.
|
|
176460
|
+
* * Math details can be found at https://en.wikipedia.org/wiki/Curvature#General_expressions
|
|
176461
|
+
* @param ux first derivative x component
|
|
176462
|
+
* @param uy first derivative y component
|
|
176463
|
+
* @param uz first derivative z component
|
|
176464
|
+
* @param vx second derivative x component
|
|
176465
|
+
* @param vy second derivative y component
|
|
176466
|
+
* @param vz second derivative z component
|
|
176353
176467
|
*/
|
|
176354
|
-
static
|
|
176468
|
+
static curvatureMagnitude(ux, uy, uz, vx, vy, vz) {
|
|
176469
|
+
let q = uy * vz - uz * vy;
|
|
176470
|
+
let sum = q * q;
|
|
176471
|
+
q = uz * vx - ux * vz;
|
|
176472
|
+
sum += q * q;
|
|
176473
|
+
q = ux * vy - uy * vx;
|
|
176474
|
+
sum += q * q;
|
|
176475
|
+
const magUxV = Math.sqrt(sum);
|
|
176476
|
+
const magU = Math.sqrt(ux * ux + uy * uy + uz * uz);
|
|
176477
|
+
const magUCubed = magU * magU * magU;
|
|
176478
|
+
if (magUCubed > Geometry.smallAngleRadians * magUxV)
|
|
176479
|
+
return magUxV / magUCubed;
|
|
176480
|
+
return 0;
|
|
176481
|
+
}
|
|
176482
|
+
/**
|
|
176483
|
+
* Clamp to (min(a,b), max(a,b)).
|
|
176484
|
+
* * Always returns a number between `a` and `b`.
|
|
176485
|
+
* @param value value to clamp
|
|
176486
|
+
* @param a smallest allowed output if `a < b` or largest allowed output if `a > b`
|
|
176487
|
+
* @param b largest allowed output if `a < b` or smallest allowed output if `a > b`
|
|
176488
|
+
*/
|
|
176489
|
+
static clampToStartEnd(value, a, b) {
|
|
176355
176490
|
if (a > b)
|
|
176356
|
-
return Geometry.clampToStartEnd(
|
|
176357
|
-
if (
|
|
176491
|
+
return Geometry.clampToStartEnd(value, b, a);
|
|
176492
|
+
if (value < a)
|
|
176358
176493
|
return a;
|
|
176359
|
-
if (b <
|
|
176494
|
+
if (b < value)
|
|
176360
176495
|
return b;
|
|
176361
|
-
return
|
|
176496
|
+
return value;
|
|
176362
176497
|
}
|
|
176363
176498
|
/**
|
|
176364
|
-
* Clamp value to (min,max) with no test for order of (min,max)
|
|
176499
|
+
* Clamp value to (min, max) with no test for order of (min, max).
|
|
176500
|
+
* * Always returns a number between `min` and `max`.
|
|
176365
176501
|
* @param value value to clamp
|
|
176366
176502
|
* @param min smallest allowed output
|
|
176367
|
-
* @param max largest allowed
|
|
176503
|
+
* @param max largest allowed output
|
|
176368
176504
|
*/
|
|
176369
|
-
static clamp(value, min, max) {
|
|
176370
|
-
|
|
176505
|
+
static clamp(value, min, max) {
|
|
176506
|
+
return Math.max(min, Math.min(max, value));
|
|
176507
|
+
}
|
|
176508
|
+
/** If given a `value`, return it. If given `undefined`, return `defaultValue`. */
|
|
176371
176509
|
static resolveNumber(value, defaultValue = 0) {
|
|
176372
176510
|
return value !== undefined ? value : defaultValue;
|
|
176373
176511
|
}
|
|
176374
|
-
/** If given a value
|
|
176512
|
+
/** If given a `value`, return it. If given `undefined`, return `defaultValue`. */
|
|
176375
176513
|
static resolveValue(value, defaultValue) {
|
|
176376
176514
|
return value !== undefined ? value : defaultValue;
|
|
176377
176515
|
}
|
|
176378
|
-
/** If given value matches
|
|
176516
|
+
/** If given `value` matches the `targetValue`, return `undefined`. Otherwise return the `value`. */
|
|
176379
176517
|
static resolveToUndefined(value, targetValue) {
|
|
176380
176518
|
return value === targetValue ? undefined : value;
|
|
176381
176519
|
}
|
|
176382
176520
|
/**
|
|
176383
|
-
* Simple interpolation between values
|
|
176384
|
-
* point for maximum accuracy.
|
|
176521
|
+
* Simple interpolation between values `a` and `b` with fraction `f`.
|
|
176385
176522
|
* * If `f = 0`, then `a` is returned and if `f = 1`, then `b` is returned.
|
|
176523
|
+
* * For maximum accuracy, we choose `a` or `b` as starting point based on fraction `f`.
|
|
176386
176524
|
*/
|
|
176387
176525
|
static interpolate(a, f, b) {
|
|
176388
176526
|
return f <= 0.5 ? a + f * (b - a) : b - (1.0 - f) * (b - a);
|
|
176389
176527
|
}
|
|
176390
176528
|
/**
|
|
176391
|
-
* Given an axisOrder (e.g. XYZ, YZX, etc) and an index
|
|
176392
|
-
* * For example, if axisOrder = XYZ
|
|
176393
|
-
* Y (or axis
|
|
176394
|
-
*
|
|
176395
|
-
*
|
|
176396
|
-
*
|
|
176397
|
-
*
|
|
176529
|
+
* Given an `axisOrder` (e.g. XYZ, YZX, etc) and an `index`, return the `axis` at the given index.
|
|
176530
|
+
* * For example, if `axisOrder = XYZ`, then for index 0 return `X` (or axis 0), for index 1 return
|
|
176531
|
+
* `Y` (or axis 1), and for index 2 return `Z` (or axis 2).
|
|
176532
|
+
* * Another example: if `axisOrder = ZXY`, then for index 0 return `Z` (or axis 2), for index 1 return
|
|
176533
|
+
* `X` (or axis 0), and for index 2 return `Y` (or axis 1).
|
|
176534
|
+
* * For indexes greater than 2 or smaller than 0, it return cyclic axis. See [[Geometry.cyclic3dAxis]]
|
|
176535
|
+
* for more info.
|
|
176536
|
+
*/
|
|
176398
176537
|
static axisOrderToAxis(order, index) {
|
|
176399
176538
|
const axis = order <= AxisOrder.ZXY ? order + index : (order - AxisOrder.XZY) - index;
|
|
176400
176539
|
return Geometry.cyclic3dAxis(axis);
|
|
176401
176540
|
}
|
|
176402
|
-
/**
|
|
176541
|
+
/**
|
|
176542
|
+
* Return `a` modulo `period`.
|
|
176543
|
+
* * Both `a` and `period` can be negative.
|
|
176544
|
+
* * This function can be faster than the `%` operator for the common case when `p > 0` and `-p < a < 2p`.
|
|
176545
|
+
*/
|
|
176403
176546
|
static modulo(a, period) {
|
|
176547
|
+
// period is negative
|
|
176404
176548
|
if (period <= 0) {
|
|
176405
176549
|
if (period === 0)
|
|
176406
176550
|
return a;
|
|
176407
176551
|
return -Geometry.modulo(-a, -period);
|
|
176408
176552
|
}
|
|
176553
|
+
// period is positive
|
|
176409
176554
|
if (a >= 0) {
|
|
176410
|
-
if (a < period)
|
|
176555
|
+
if (a < period) // "0 < a < period"
|
|
176411
176556
|
return a;
|
|
176412
|
-
if (a < 2 * period)
|
|
176557
|
+
if (a < 2 * period) // "0 < period < a < 2*period"
|
|
176413
176558
|
return a - period;
|
|
176414
176559
|
}
|
|
176415
|
-
else {
|
|
176416
|
-
a += period;
|
|
176560
|
+
else { // "-period < a < 0"
|
|
176561
|
+
a += period;
|
|
176417
176562
|
if (a > 0)
|
|
176418
176563
|
return a;
|
|
176419
176564
|
}
|
|
176565
|
+
// "0 < 2*period < a" or "a < -period < 0"
|
|
176420
176566
|
const m = Math.floor(a / period);
|
|
176421
176567
|
return a - m * period;
|
|
176422
176568
|
}
|
|
176423
|
-
/**
|
|
176424
|
-
static defined01(value) {
|
|
176569
|
+
/** Return 0 if the value is `undefined` and 1 if the value is defined. */
|
|
176570
|
+
static defined01(value) {
|
|
176571
|
+
return value === undefined ? 0 : 1;
|
|
176572
|
+
}
|
|
176425
176573
|
/**
|
|
176426
|
-
* Return `numerator` divided by `denominator
|
|
176574
|
+
* Return `numerator` divided by `denominator`.
|
|
176427
176575
|
* @param numerator the numerator
|
|
176428
176576
|
* @param denominator the denominator
|
|
176429
|
-
* @returns return `numerator/denominator` but if the ratio
|
|
176577
|
+
* @returns return `numerator/denominator` but if the ratio exceeds `Geometry.largeFractionResult`,
|
|
176430
176578
|
* return `undefined`.
|
|
176431
176579
|
*/
|
|
176432
176580
|
static conditionalDivideFraction(numerator, denominator) {
|
|
@@ -176438,76 +176586,105 @@ class Geometry {
|
|
|
176438
176586
|
* Return `numerator` divided by `denominator`.
|
|
176439
176587
|
* @param numerator the numerator
|
|
176440
176588
|
* @param denominator the denominator
|
|
176441
|
-
* @returns return `numerator/denominator` but if the ratio
|
|
176589
|
+
* @returns return `numerator/denominator` but if the ratio exceeds `Geometry.largeFractionResult`,
|
|
176442
176590
|
* return `defaultResult`.
|
|
176443
176591
|
*/
|
|
176444
176592
|
static safeDivideFraction(numerator, denominator, defaultResult) {
|
|
176445
|
-
const
|
|
176446
|
-
if (
|
|
176447
|
-
return
|
|
176593
|
+
const ratio = Geometry.conditionalDivideFraction(numerator, denominator);
|
|
176594
|
+
if (ratio !== undefined)
|
|
176595
|
+
return ratio;
|
|
176448
176596
|
return defaultResult;
|
|
176449
176597
|
}
|
|
176450
176598
|
/**
|
|
176451
|
-
* Return `numerator` divided by `denominator` (with a given `largestResult`)
|
|
176599
|
+
* Return `numerator` divided by `denominator` (with a given `largestResult`).
|
|
176452
176600
|
* @param numerator the numerator
|
|
176453
176601
|
* @param denominator the denominator
|
|
176454
|
-
* @param largestResult the ratio threshold
|
|
176455
|
-
* @returns return `numerator/denominator` but if the ratio
|
|
176602
|
+
* @param largestResult the ratio threshold
|
|
176603
|
+
* @returns return `numerator/denominator` but if the ratio exceeds `largestResult`, return `undefined`.
|
|
176456
176604
|
*/
|
|
176457
176605
|
static conditionalDivideCoordinate(numerator, denominator, largestResult = Geometry.largeCoordinateResult) {
|
|
176458
176606
|
if (Math.abs(denominator * largestResult) > Math.abs(numerator))
|
|
176459
176607
|
return numerator / denominator;
|
|
176460
176608
|
return undefined;
|
|
176461
176609
|
}
|
|
176462
|
-
/**
|
|
176463
|
-
*
|
|
176464
|
-
*
|
|
176610
|
+
/**
|
|
176611
|
+
* Return solution(s) of equation `constCoff + cosCoff*c + sinCoff*s = 0` for `c` and `s` with the
|
|
176612
|
+
* constraint `c*c + s*s = 1`.
|
|
176613
|
+
* * There could be 0, 1, or 2 solutions. Return `undefined` if there is no solution.
|
|
176465
176614
|
*/
|
|
176466
176615
|
static solveTrigForm(constCoff, cosCoff, sinCoff) {
|
|
176467
|
-
|
|
176468
|
-
|
|
176469
|
-
|
|
176470
|
-
|
|
176471
|
-
|
|
176472
|
-
|
|
176473
|
-
|
|
176474
|
-
|
|
176475
|
-
|
|
176476
|
-
|
|
176477
|
-
|
|
176478
|
-
|
|
176479
|
-
|
|
176480
|
-
|
|
176481
|
-
|
|
176482
|
-
|
|
176483
|
-
|
|
176484
|
-
|
|
176485
|
-
|
|
176486
|
-
|
|
176487
|
-
|
|
176488
|
-
|
|
176489
|
-
|
|
176616
|
+
/**
|
|
176617
|
+
* Solutions can be found by finding the intersection of line "ax + by + d = 0" and unit circle "x^2 + y^2 = 1".
|
|
176618
|
+
* From the line equation we have "y = (-ax - d) / b". By replacing this into the circle equation we get
|
|
176619
|
+
* "x^2 + (ax+d)^2/b^2 = 1". If we solve this by quadratic formula we get
|
|
176620
|
+
* x = (-ad +- b*sqrt(a^2+b^2-d^2)) / (a^2+b^2)
|
|
176621
|
+
* y = (-ad -+ a*sqrt(a^2+b^2-d^2)) / (a^2+b^2)
|
|
176622
|
+
*
|
|
176623
|
+
* If "a^2+b^2-d^2 > 0" then there are two solutions (above).
|
|
176624
|
+
* 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)).
|
|
176625
|
+
* If "a^2+b^2-d^2 < 0" then there is no solution.
|
|
176626
|
+
*
|
|
176627
|
+
* Below in the code we have "a = cosCoff", "b = sinCoff", and "d = constCoff". Also equivalent criterion
|
|
176628
|
+
* 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".
|
|
176629
|
+
*/
|
|
176630
|
+
const a2b2 = cosCoff * cosCoff + sinCoff * sinCoff; // a^2+b^2
|
|
176631
|
+
const d2 = constCoff * constCoff; // d^2
|
|
176632
|
+
let result;
|
|
176633
|
+
if (a2b2 > 0.0) {
|
|
176634
|
+
const a2b2r = 1.0 / a2b2; // 1/(a^2+b^2)
|
|
176635
|
+
const d2a2b2 = d2 * a2b2r; // d^2/(a^2+b^2)
|
|
176636
|
+
const criteria = 1.0 - d2a2b2; // 1 - d^2/(a^2+b^2); the criteria to specify how many solutions we got
|
|
176637
|
+
if (criteria < -Geometry.smallMetricDistanceSquared) // nSolution = 0
|
|
176638
|
+
return result;
|
|
176639
|
+
const da2b2 = -constCoff * a2b2r; // -d/(a^2+b^2)
|
|
176640
|
+
const c0 = da2b2 * cosCoff; // -ad/(a^2+b^2)
|
|
176641
|
+
const s0 = da2b2 * sinCoff; // -bd/(a^2+b^2)
|
|
176642
|
+
if (criteria <= 0.0) { // nSolution = 1 (observed criteria = -2.22e-16 in rotated system)
|
|
176643
|
+
result = [_geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_1__.Vector2d.create(c0, s0)];
|
|
176644
|
+
}
|
|
176645
|
+
else if (criteria > 0.0) { // nSolution = 2
|
|
176646
|
+
const s = Math.sqrt(criteria * a2b2r); // sqrt(a^2+b^2-d^2)) / (a^2+b^2)
|
|
176647
|
+
result = [
|
|
176648
|
+
_geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_1__.Vector2d.create(c0 - s * sinCoff, s0 + s * cosCoff),
|
|
176649
|
+
_geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_1__.Vector2d.create(c0 + s * sinCoff, s0 - s * cosCoff),
|
|
176650
|
+
];
|
|
176490
176651
|
}
|
|
176491
|
-
return result;
|
|
176492
176652
|
}
|
|
176653
|
+
return result;
|
|
176493
176654
|
}
|
|
176494
|
-
/**
|
|
176495
|
-
|
|
176496
|
-
|
|
176497
|
-
|
|
176498
|
-
|
|
176655
|
+
/**
|
|
176656
|
+
* For a line `f(x)` where `f(x0) = f0` and `f(x1) = f1`, return the `x` value at which `f(x) = fTarget`
|
|
176657
|
+
* Return `defaultResult` if `(fTarget - f0) / (f1 - f0)` exceeds `Geometry.largeFractionResult`
|
|
176658
|
+
*/
|
|
176659
|
+
static inverseInterpolate(x0, f0, x1, f1, fTarget = 0, defaultResult) {
|
|
176660
|
+
/**
|
|
176661
|
+
* Line equation is "fTarget-f0 = (f1-f0)/(x1-x0) * (x-x0)" or "(fTarget-f0)/(f1-f0) = (x-x0)/(x1-x0)".
|
|
176662
|
+
* The left hand side is known so if we call it "fr" (short for "fraction") we get "fr = (x-x0)/(x1-x0)".
|
|
176663
|
+
* Therefore, "x = x0*(1-fr) + x1*fr". This is same as interpolation between "x0" and "x1" with fraction "fr".
|
|
176664
|
+
*/
|
|
176665
|
+
const fr = Geometry.conditionalDivideFraction(fTarget - f0, f1 - f0); // (fTarget-f0)/(f1-f0)
|
|
176666
|
+
if (fr !== undefined)
|
|
176667
|
+
return Geometry.interpolate(x0, fr, x1); // x = x0*(1-fr) + x1*fr
|
|
176499
176668
|
return defaultResult;
|
|
176500
176669
|
}
|
|
176501
|
-
/**
|
|
176502
|
-
|
|
176503
|
-
|
|
176670
|
+
/**
|
|
176671
|
+
* For a line `f(x)` where `f(0) = f0` and `f(1) = f1`, return the `x` value at which `f(x) = fTarget`
|
|
176672
|
+
* Return `undefined` if `(fTarget - f0) / (f1 - f0)` exceeds `Geometry.largeFractionResult`
|
|
176673
|
+
*/
|
|
176674
|
+
static inverseInterpolate01(f0, f1, fTarget = 0) {
|
|
176675
|
+
/**
|
|
176676
|
+
* Line equation is "fTarget-f0 = (f1-f0)*x" so "x = (fTarget-f0)/(f1-f0)"
|
|
176677
|
+
*/
|
|
176678
|
+
return Geometry.conditionalDivideFraction(fTarget - f0, f1 - f0); // x = (fTarget-f0)/(f1-f0)
|
|
176504
176679
|
}
|
|
176505
|
-
/**
|
|
176680
|
+
/**
|
|
176681
|
+
* Return `true` if `json` is an array with at least `minEntries` entries and all entries are numbers (including
|
|
176682
|
+
* those beyond minEntries).
|
|
176683
|
+
*/
|
|
176506
176684
|
static isNumberArray(json, minEntries = 0) {
|
|
176507
176685
|
if (Array.isArray(json) && json.length >= minEntries) {
|
|
176508
176686
|
let entry;
|
|
176509
176687
|
for (entry of json) {
|
|
176510
|
-
// if (!(entry as number) && entry !== 0.0)
|
|
176511
176688
|
if (!Number.isFinite(entry))
|
|
176512
176689
|
return false;
|
|
176513
176690
|
}
|
|
@@ -176515,10 +176692,12 @@ class Geometry {
|
|
|
176515
176692
|
}
|
|
176516
176693
|
return false;
|
|
176517
176694
|
}
|
|
176518
|
-
/**
|
|
176695
|
+
/**
|
|
176696
|
+
* Return `true` if `json` is an array of at least `minArrays` arrays with at least `minEntries` entries in
|
|
176697
|
+
* each array and all entries are numbers (including those beyond minEntries).
|
|
176519
176698
|
*/
|
|
176520
|
-
static isArrayOfNumberArray(json,
|
|
176521
|
-
if (Array.isArray(json) && json.length >=
|
|
176699
|
+
static isArrayOfNumberArray(json, minArrays, minEntries = 0) {
|
|
176700
|
+
if (Array.isArray(json) && json.length >= minArrays) {
|
|
176522
176701
|
let entry;
|
|
176523
176702
|
for (entry of json)
|
|
176524
176703
|
if (!Geometry.isNumberArray(entry, minEntries))
|
|
@@ -176527,36 +176706,53 @@ class Geometry {
|
|
|
176527
176706
|
}
|
|
176528
176707
|
return false;
|
|
176529
176708
|
}
|
|
176530
|
-
/**
|
|
176531
|
-
*
|
|
176532
|
-
*
|
|
176533
|
-
|
|
176709
|
+
/**
|
|
176710
|
+
* Return the number of steps to take so that `numSteps * stepSize >= total`.
|
|
176711
|
+
* * `minCount` is returned in the following 3 cases:
|
|
176712
|
+
* * (a) `stepSize <= 0`
|
|
176713
|
+
* * (b) `stepSize >= total`
|
|
176714
|
+
* * (b) `numSteps < minCount`
|
|
176715
|
+
* * `maxCount` is returned if `numSteps > maxCount`.
|
|
176716
|
+
*/
|
|
176534
176717
|
static stepCount(stepSize, total, minCount = 1, maxCount = 101) {
|
|
176535
176718
|
if (stepSize <= 0)
|
|
176536
176719
|
return minCount;
|
|
176537
176720
|
total = Math.abs(total);
|
|
176538
176721
|
if (stepSize >= total)
|
|
176539
176722
|
return minCount;
|
|
176540
|
-
|
|
176541
|
-
|
|
176723
|
+
/**
|
|
176724
|
+
* 0.999999 is multiplied so we return the same "numSteps" if
|
|
176725
|
+
* stepSize*(numSteps-1) < total <= stepSize*numSteps.
|
|
176726
|
+
* For example, if "stepSize = 2" then we return "numSteps = 5" if 8 < total <= 10.
|
|
176727
|
+
*/
|
|
176728
|
+
const numSteps = Math.floor((total + 0.999999 * stepSize) / stepSize);
|
|
176729
|
+
if (numSteps < minCount)
|
|
176542
176730
|
return minCount;
|
|
176543
|
-
if (
|
|
176731
|
+
if (numSteps > maxCount)
|
|
176544
176732
|
return maxCount;
|
|
176545
|
-
return
|
|
176733
|
+
return numSteps;
|
|
176546
176734
|
}
|
|
176547
|
-
/**
|
|
176735
|
+
/**
|
|
176736
|
+
* Test if `x` is in the interval [0,1] (but skip the test if `apply01 = false`).
|
|
176737
|
+
* * This odd behavior is very convenient for code that sometimes does not do the filtering.
|
|
176548
176738
|
* @param x value to test.
|
|
176549
|
-
* @param apply01 if false,
|
|
176739
|
+
* @param apply01 if false, return `true` for all values of `x`.
|
|
176550
176740
|
*/
|
|
176551
|
-
static isIn01(x, apply01 = true) {
|
|
176552
|
-
|
|
176741
|
+
static isIn01(x, apply01 = true) {
|
|
176742
|
+
return apply01 ? x >= 0.0 && x <= 1.0 : true;
|
|
176743
|
+
}
|
|
176744
|
+
/**
|
|
176745
|
+
* Test if `x` is in the interval [0,1] for a given positive `tolerance`.
|
|
176746
|
+
* * Make sure to pass a positive `tolerance` because there is no check for that in the code.
|
|
176553
176747
|
* @param x value to test.
|
|
176554
|
-
* @param
|
|
176748
|
+
* @param tolerance the tolerance.
|
|
176555
176749
|
*/
|
|
176556
|
-
static isIn01WithTolerance(x, tolerance) {
|
|
176750
|
+
static isIn01WithTolerance(x, tolerance) {
|
|
176751
|
+
return x + tolerance >= 0.0 && x - tolerance <= 1.0;
|
|
176752
|
+
}
|
|
176557
176753
|
/**
|
|
176558
|
-
*
|
|
176559
|
-
* @param x
|
|
176754
|
+
* Restrict x so it is in the interval `[a,b]` (allowing `a` and `b` to be in either order).
|
|
176755
|
+
* @param x value to restrict
|
|
176560
176756
|
* @param a (usually the lower) interval limit
|
|
176561
176757
|
* @param b (usually the upper) interval limit
|
|
176562
176758
|
*/
|
|
@@ -176568,7 +176764,7 @@ class Geometry {
|
|
|
176568
176764
|
return b;
|
|
176569
176765
|
return x;
|
|
176570
176766
|
}
|
|
176571
|
-
// reversed interval
|
|
176767
|
+
// reversed interval
|
|
176572
176768
|
if (x < b)
|
|
176573
176769
|
return b;
|
|
176574
176770
|
if (x > a)
|
|
@@ -176577,12 +176773,15 @@ class Geometry {
|
|
|
176577
176773
|
}
|
|
176578
176774
|
/**
|
|
176579
176775
|
* Case-insensitive string comparison.
|
|
176580
|
-
* * Return true if the toUpperCase values match.
|
|
176776
|
+
* * Return `true` if the `toUpperCase` values of `string1` and `string2` match.
|
|
176581
176777
|
*/
|
|
176582
176778
|
static equalStringNoCase(string1, string2) {
|
|
176583
176779
|
return string1.toUpperCase() === string2.toUpperCase();
|
|
176584
176780
|
}
|
|
176585
|
-
/**
|
|
176781
|
+
/**
|
|
176782
|
+
* Test for exact match of two number arrays.
|
|
176783
|
+
* Returns `true` if both arrays have the same length and entries, or if both arrays are empty or `undefined`.
|
|
176784
|
+
*/
|
|
176586
176785
|
static exactEqualNumberArrays(a, b) {
|
|
176587
176786
|
if (Array.isArray(a) && a.length === 0)
|
|
176588
176787
|
a = undefined;
|
|
@@ -176600,7 +176799,10 @@ class Geometry {
|
|
|
176600
176799
|
}
|
|
176601
176800
|
return false;
|
|
176602
176801
|
}
|
|
176603
|
-
/**
|
|
176802
|
+
/**
|
|
176803
|
+
* Test for match of two arrays of type `T`.
|
|
176804
|
+
* Returns `true` if both arrays have the same length and have the same entries (or both are empty arrays).
|
|
176805
|
+
*/
|
|
176604
176806
|
static almostEqualArrays(a, b, testFunction) {
|
|
176605
176807
|
if (Array.isArray(a) && a.length === 0)
|
|
176606
176808
|
a = undefined;
|
|
@@ -176619,7 +176821,10 @@ class Geometry {
|
|
|
176619
176821
|
}
|
|
176620
176822
|
return false;
|
|
176621
176823
|
}
|
|
176622
|
-
/**
|
|
176824
|
+
/**
|
|
176825
|
+
* Test for match of two arrays of type number or Float64Array.
|
|
176826
|
+
* Returns `true` if both arrays have the same length and have the same entries (or both are empty arrays).
|
|
176827
|
+
*/
|
|
176623
176828
|
static almostEqualNumberArrays(a, b, testFunction) {
|
|
176624
176829
|
if (Array.isArray(a) && a.length === 0)
|
|
176625
176830
|
a = undefined;
|
|
@@ -176639,15 +176844,12 @@ class Geometry {
|
|
|
176639
176844
|
return false;
|
|
176640
176845
|
}
|
|
176641
176846
|
/**
|
|
176642
|
-
*
|
|
176643
|
-
* * true if both values are defined and equal (with ===).
|
|
176644
|
-
* * false if both defined by not equal
|
|
176645
|
-
* * return (option arg) resultIfBothUndefined when both are undefined.
|
|
176646
|
-
* * return false if one is defined and the other undefined
|
|
176847
|
+
* Test for match of two values of type `T`.
|
|
176647
176848
|
* @param a first value
|
|
176648
176849
|
* @param b second value
|
|
176649
|
-
* @param resultIfBothUndefined
|
|
176650
|
-
* @returns
|
|
176850
|
+
* @param resultIfBothUndefined returned value when both are `undefined`
|
|
176851
|
+
* @returns `true` if both values are defined and equal (with ===) and `false` if both values are defined
|
|
176852
|
+
* but not equal or if one is defined and the other undefined.
|
|
176651
176853
|
*/
|
|
176652
176854
|
static areEqualAllowUndefined(a, b, resultIfBothUndefined = true) {
|
|
176653
176855
|
if (a === undefined && b === undefined)
|
|
@@ -176656,47 +176858,53 @@ class Geometry {
|
|
|
176656
176858
|
return a === b;
|
|
176657
176859
|
return false;
|
|
176658
176860
|
}
|
|
176659
|
-
/**
|
|
176660
|
-
*
|
|
176661
|
-
|
|
176662
|
-
|
|
176663
|
-
|
|
176861
|
+
/**
|
|
176862
|
+
* Clone an array whose members have type `T`, which implements the clone method.
|
|
176863
|
+
* * If the clone method returns `undefined`, then `undefined` is forced into the cloned array.
|
|
176864
|
+
*/
|
|
176865
|
+
static cloneMembers(array) {
|
|
176866
|
+
if (array === undefined)
|
|
176664
176867
|
return undefined;
|
|
176665
|
-
const
|
|
176666
|
-
for (const
|
|
176667
|
-
|
|
176868
|
+
const clonedArray = [];
|
|
176869
|
+
for (const element of array) {
|
|
176870
|
+
clonedArray.push(element.clone());
|
|
176668
176871
|
}
|
|
176669
|
-
return
|
|
176872
|
+
return clonedArray;
|
|
176670
176873
|
}
|
|
176671
176874
|
}
|
|
176672
|
-
/** Tolerance for small distances in metric coordinates */
|
|
176875
|
+
/** Tolerance for small distances in metric coordinates. */
|
|
176673
176876
|
Geometry.smallMetricDistance = 1.0e-6;
|
|
176674
|
-
/** Square of `
|
|
176877
|
+
/** Square of `smallMetricDistance`. */
|
|
176675
176878
|
Geometry.smallMetricDistanceSquared = 1.0e-12;
|
|
176676
|
-
/**
|
|
176879
|
+
/** Tolerance for small angle measured in radians. */
|
|
176677
176880
|
Geometry.smallAngleRadians = 1.0e-12;
|
|
176678
|
-
/**
|
|
176881
|
+
/** Square of `smallAngleRadians`. */
|
|
176679
176882
|
Geometry.smallAngleRadiansSquared = 1.0e-24;
|
|
176680
|
-
/**
|
|
176883
|
+
/** Tolerance for small angle measured in degrees. */
|
|
176681
176884
|
Geometry.smallAngleDegrees = 5.7e-11;
|
|
176682
|
-
/**
|
|
176885
|
+
/** Tolerance for small angle measured in arc-seconds. */
|
|
176683
176886
|
Geometry.smallAngleSeconds = 2e-7;
|
|
176684
|
-
/**
|
|
176685
|
-
|
|
176887
|
+
/** Numeric value that may be considered zero for fractions between 0 and 1. */
|
|
176888
|
+
Geometry.smallFraction = 1.0e-10;
|
|
176889
|
+
/** Radians value for full circle 2PI radians minus `smallAngleRadians`. */
|
|
176890
|
+
Geometry.fullCircleRadiansMinusSmallAngle = 2.0 * Math.PI - Geometry.smallAngleRadians;
|
|
176891
|
+
/**
|
|
176892
|
+
* Numeric value that may be considered large for a ratio of numbers.
|
|
176893
|
+
* * Note that the allowed result value is vastly larger than 1.
|
|
176686
176894
|
*/
|
|
176687
176895
|
Geometry.largeFractionResult = 1.0e10;
|
|
176688
|
-
/**
|
|
176689
|
-
|
|
176690
|
-
/** numeric value that may considered huge for numbers expected to be coordinates.
|
|
176896
|
+
/**
|
|
176897
|
+
* Numeric value that may considered large for numbers expected to be coordinates.
|
|
176691
176898
|
* * This allows larger results than `largeFractionResult`.
|
|
176692
176899
|
*/
|
|
176693
176900
|
Geometry.largeCoordinateResult = 1.0e13;
|
|
176694
|
-
/**
|
|
176695
|
-
*
|
|
176901
|
+
/**
|
|
176902
|
+
* Numeric value that may considered infinite for metric coordinates.
|
|
176903
|
+
* @deprecated in 4.x. Use `largeCoordinateResult`.
|
|
176904
|
+
* * This coordinate should be used only as a placeholder indicating "at infinity" -- computing actual
|
|
176905
|
+
* points at this coordinate invites numerical problems.
|
|
176696
176906
|
*/
|
|
176697
176907
|
Geometry.hugeCoordinate = 1.0e12;
|
|
176698
|
-
/** Radians value for full circle 2PI radians minus `smallAngleRadians` */
|
|
176699
|
-
Geometry.fullCircleRadiansMinusSmallAngle = 2.0 * Math.PI - 1.0e-12; // smallAngleRadians less than 360degrees
|
|
176700
176908
|
|
|
176701
176909
|
|
|
176702
176910
|
|
|
@@ -185724,17 +185932,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
185724
185932
|
/* harmony export */ "ConvexClipPlaneSet": () => (/* binding */ ConvexClipPlaneSet)
|
|
185725
185933
|
/* harmony export */ });
|
|
185726
185934
|
/* harmony import */ var _Geometry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Geometry */ "../../core/geometry/lib/esm/Geometry.js");
|
|
185727
|
-
/* harmony import */ var _geometry3d_Plane3dByOriginAndUnitNormal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geometry3d/Plane3dByOriginAndUnitNormal */ "../../core/geometry/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js");
|
|
185728
185935
|
/* harmony import */ var _geometry3d_GrowableFloat64Array__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../geometry3d/GrowableFloat64Array */ "../../core/geometry/lib/esm/geometry3d/GrowableFloat64Array.js");
|
|
185729
185936
|
/* harmony import */ var _geometry3d_GrowableXYZArray__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../geometry3d/GrowableXYZArray */ "../../core/geometry/lib/esm/geometry3d/GrowableXYZArray.js");
|
|
185730
185937
|
/* harmony import */ var _geometry3d_Matrix3d__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../geometry3d/Matrix3d */ "../../core/geometry/lib/esm/geometry3d/Matrix3d.js");
|
|
185938
|
+
/* harmony import */ var _geometry3d_Plane3dByOriginAndUnitNormal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geometry3d/Plane3dByOriginAndUnitNormal */ "../../core/geometry/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js");
|
|
185731
185939
|
/* harmony import */ var _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../geometry3d/Point3dVector3d */ "../../core/geometry/lib/esm/geometry3d/Point3dVector3d.js");
|
|
185732
185940
|
/* harmony import */ var _geometry3d_PolygonOps__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../geometry3d/PolygonOps */ "../../core/geometry/lib/esm/geometry3d/PolygonOps.js");
|
|
185733
185941
|
/* harmony import */ var _geometry3d_Range__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../geometry3d/Range */ "../../core/geometry/lib/esm/geometry3d/Range.js");
|
|
185734
|
-
/* harmony import */ var _ClipPlane__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClipPlane */ "../../core/geometry/lib/esm/clipping/ClipPlane.js");
|
|
185735
|
-
/* harmony import */ var _ClipUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ClipUtils */ "../../core/geometry/lib/esm/clipping/ClipUtils.js");
|
|
185736
185942
|
/* harmony import */ var _polyface_Polyface__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../polyface/Polyface */ "../../core/geometry/lib/esm/polyface/Polyface.js");
|
|
185737
185943
|
/* harmony import */ var _polyface_PolyfaceQuery__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../polyface/PolyfaceQuery */ "../../core/geometry/lib/esm/polyface/PolyfaceQuery.js");
|
|
185944
|
+
/* harmony import */ var _ClipPlane__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClipPlane */ "../../core/geometry/lib/esm/clipping/ClipPlane.js");
|
|
185945
|
+
/* harmony import */ var _ClipUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ClipUtils */ "../../core/geometry/lib/esm/clipping/ClipUtils.js");
|
|
185738
185946
|
/*---------------------------------------------------------------------------------------------
|
|
185739
185947
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
185740
185948
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -185959,17 +186167,19 @@ class ConvexClipPlaneSet {
|
|
|
185959
186167
|
get planes() {
|
|
185960
186168
|
return this._planes;
|
|
185961
186169
|
}
|
|
185962
|
-
/**
|
|
186170
|
+
/**
|
|
186171
|
+
* Test if there is any intersection with a ray defined by origin and direction.
|
|
185963
186172
|
* * Optionally record the range (null or otherwise) in caller-allocated result.
|
|
185964
|
-
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
186173
|
+
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
186174
|
+
* "Geometry.largeCoordinateResult" values
|
|
185965
186175
|
* * If no result is provide, there are no object allocations.
|
|
185966
186176
|
* @param result optional Range1d to receive parameters along the ray.
|
|
185967
186177
|
*/
|
|
185968
186178
|
hasIntersectionWithRay(ray, result, tolerance = _Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.smallMetricDistance) {
|
|
185969
186179
|
// form low and high values in locals that do not require allocation.
|
|
185970
186180
|
// transfer to caller-supplied result at end
|
|
185971
|
-
let t0 = -_Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.
|
|
185972
|
-
let t1 = _Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.
|
|
186181
|
+
let t0 = -_Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.largeCoordinateResult;
|
|
186182
|
+
let t1 = _Geometry__WEBPACK_IMPORTED_MODULE_3__.Geometry.largeCoordinateResult;
|
|
185973
186183
|
if (result)
|
|
185974
186184
|
result.setNull();
|
|
185975
186185
|
const velocityTolerance = 1.0e-13;
|
|
@@ -186580,9 +186790,11 @@ class UnionOfConvexClipPlaneSets {
|
|
|
186580
186790
|
if (toAdd)
|
|
186581
186791
|
this._convexSets.push(toAdd);
|
|
186582
186792
|
}
|
|
186583
|
-
/**
|
|
186793
|
+
/**
|
|
186794
|
+
* Test if there is any intersection with a ray defined by origin and direction.
|
|
186584
186795
|
* * Optionally record the range (null or otherwise) in caller-allocated result.
|
|
186585
|
-
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
186796
|
+
* * If the ray is unbounded inside the clip, result can contain positive or negative
|
|
186797
|
+
* "Geometry.largeCoordinateResult" values
|
|
186586
186798
|
* * If no result is provide, there are no object allocations.
|
|
186587
186799
|
* @param maximalRange optional Range1d to receive parameters along the ray.
|
|
186588
186800
|
*/
|
|
@@ -214746,32 +214958,40 @@ class Plane3dByOriginAndUnitNormal extends _Plane3d__WEBPACK_IMPORTED_MODULE_0__
|
|
|
214746
214958
|
return Plane3dByOriginAndUnitNormal._create(origin.x, origin.y, origin.z, 0, 1, 0);
|
|
214747
214959
|
return Plane3dByOriginAndUnitNormal._create(0, 0, 0, 0, 1, 0);
|
|
214748
214960
|
}
|
|
214749
|
-
/**
|
|
214961
|
+
/** Create a new Plane3dByOriginAndUnitNormal with given origin and normal.
|
|
214750
214962
|
* * The inputs are NOT captured.
|
|
214751
|
-
* * Returns undefined if
|
|
214963
|
+
* * Returns undefined if `normal.normalize()` returns undefined.
|
|
214752
214964
|
*/
|
|
214753
214965
|
static create(origin, normal, result) {
|
|
214754
|
-
const normalized = normal.normalize();
|
|
214755
|
-
if (!normalized)
|
|
214756
|
-
return undefined;
|
|
214757
214966
|
if (result) {
|
|
214758
|
-
result.
|
|
214967
|
+
if (normal.normalize(result._normal) === undefined)
|
|
214968
|
+
return undefined;
|
|
214969
|
+
origin.clone(result._origin);
|
|
214759
214970
|
return result;
|
|
214760
214971
|
}
|
|
214972
|
+
const normalized = normal.normalize();
|
|
214973
|
+
if (normalized === undefined)
|
|
214974
|
+
return undefined;
|
|
214761
214975
|
return new Plane3dByOriginAndUnitNormal(origin.clone(), normalized);
|
|
214762
214976
|
}
|
|
214763
|
-
/**
|
|
214977
|
+
/** Create a new Plane3dByOriginAndUnitNormal from a variety of plane types.
|
|
214764
214978
|
* * The inputs are NOT captured.
|
|
214765
|
-
* * Returns undefined if
|
|
214979
|
+
* * Returns undefined if `source.getUnitNormal()` returns undefined.
|
|
214766
214980
|
*/
|
|
214767
214981
|
static createFrom(source, result) {
|
|
214768
214982
|
if (source instanceof Plane3dByOriginAndUnitNormal)
|
|
214769
214983
|
return source.clone(result);
|
|
214984
|
+
if (result) {
|
|
214985
|
+
if (source.getUnitNormal(result._normal) === undefined)
|
|
214986
|
+
return undefined;
|
|
214987
|
+
source.getAnyPointOnPlane(result._origin);
|
|
214988
|
+
return result;
|
|
214989
|
+
}
|
|
214770
214990
|
const normal = source.getUnitNormal();
|
|
214771
214991
|
if (normal === undefined)
|
|
214772
214992
|
return undefined;
|
|
214773
214993
|
const origin = source.getAnyPointOnPlane();
|
|
214774
|
-
return
|
|
214994
|
+
return new Plane3dByOriginAndUnitNormal(origin, normal);
|
|
214775
214995
|
}
|
|
214776
214996
|
/** create a new Plane3dByOriginAndUnitNormal with direct coordinates of origin and normal.
|
|
214777
214997
|
* * Returns undefined if the normal vector is all zeros.
|
|
@@ -215930,7 +216150,7 @@ class Vector2d extends XY {
|
|
|
215930
216150
|
}
|
|
215931
216151
|
/** Return a unit vector in direction of this instance (undefined if this instance has near zero length) */
|
|
215932
216152
|
normalize(result) {
|
|
215933
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
216153
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(this.magnitude());
|
|
215934
216154
|
result = result ? result : new Vector2d();
|
|
215935
216155
|
return this.safeDivideOrNull(mag, result);
|
|
215936
216156
|
}
|
|
@@ -216075,7 +216295,7 @@ class Vector2d extends XY {
|
|
|
216075
216295
|
}
|
|
216076
216296
|
/** Return a vector parallel to this but with specified length */
|
|
216077
216297
|
scaleToLength(length, result) {
|
|
216078
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
216298
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(this.magnitude());
|
|
216079
216299
|
if (mag === 0)
|
|
216080
216300
|
return undefined;
|
|
216081
216301
|
return this.scale(length / mag, result);
|
|
@@ -217270,7 +217490,12 @@ class Vector3d extends XYZ {
|
|
|
217270
217490
|
static unitZ(scale = 1) {
|
|
217271
217491
|
return new Vector3d(0, 0, scale);
|
|
217272
217492
|
}
|
|
217273
|
-
/**
|
|
217493
|
+
/**
|
|
217494
|
+
* Scale the instance by 1.0/`denominator`.
|
|
217495
|
+
* @param denominator number by which to divide the coordinates of this instance
|
|
217496
|
+
* @param result optional pre-allocated object to return
|
|
217497
|
+
* @return scaled vector, or undefined if `denominator` is exactly zero (in which case instance is untouched).
|
|
217498
|
+
*/
|
|
217274
217499
|
safeDivideOrNull(denominator, result) {
|
|
217275
217500
|
if (denominator !== 0.0) {
|
|
217276
217501
|
return this.scale(1.0 / denominator, result);
|
|
@@ -217278,15 +217503,17 @@ class Vector3d extends XYZ {
|
|
|
217278
217503
|
return undefined;
|
|
217279
217504
|
}
|
|
217280
217505
|
/**
|
|
217281
|
-
* Return a
|
|
217282
|
-
*
|
|
217283
|
-
*
|
|
217284
|
-
*
|
|
217506
|
+
* Return a normalized instance and instance length.
|
|
217507
|
+
* @param result optional pre-allocated object to return as `v` property
|
|
217508
|
+
* @returns object containing the properties:
|
|
217509
|
+
* * `v`: unit vector in the direction of the instance, or undefined if `mag` is near zero
|
|
217510
|
+
* * `mag`: length of the instance prior to normalization
|
|
217285
217511
|
*/
|
|
217286
217512
|
normalizeWithLength(result) {
|
|
217287
|
-
const
|
|
217513
|
+
const originalMagnitude = this.magnitude();
|
|
217514
|
+
const correctedMagnitude = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(originalMagnitude);
|
|
217288
217515
|
result = result ? result : new Vector3d();
|
|
217289
|
-
return { v: this.safeDivideOrNull(
|
|
217516
|
+
return { v: this.safeDivideOrNull(correctedMagnitude, result), mag: originalMagnitude };
|
|
217290
217517
|
}
|
|
217291
217518
|
/**
|
|
217292
217519
|
* Return a unit vector parallel with this. Return undefined if this.magnitude is near zero.
|
|
@@ -217297,16 +217524,10 @@ class Vector3d extends XYZ {
|
|
|
217297
217524
|
}
|
|
217298
217525
|
/**
|
|
217299
217526
|
* If this vector has nonzero length, divide by the length to change to a unit vector.
|
|
217300
|
-
* @returns true if normalization
|
|
217527
|
+
* @returns true if normalization was successful
|
|
217301
217528
|
*/
|
|
217302
217529
|
normalizeInPlace() {
|
|
217303
|
-
|
|
217304
|
-
if (a === undefined)
|
|
217305
|
-
return false;
|
|
217306
|
-
this.x *= a;
|
|
217307
|
-
this.y *= a;
|
|
217308
|
-
this.z *= a;
|
|
217309
|
-
return true;
|
|
217530
|
+
return this.normalizeWithLength(this).v !== undefined;
|
|
217310
217531
|
}
|
|
217311
217532
|
/**
|
|
217312
217533
|
* Create a normalized vector from the inputs.
|
|
@@ -217326,7 +217547,7 @@ class Vector3d extends XYZ {
|
|
|
217326
217547
|
* Return fractional projection of this vector on the target vector.
|
|
217327
217548
|
* * It's returning the signed projection magnitude divided by the target magnitude.
|
|
217328
217549
|
* * To find the projection vector, scale the target vector by the value that this function is returning.
|
|
217329
|
-
* *
|
|
217550
|
+
* * Math details can be found at docs/learning/geometry/PointVector.md
|
|
217330
217551
|
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnVector
|
|
217331
217552
|
* and https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane
|
|
217332
217553
|
* @param target the target vector
|
|
@@ -217541,7 +217762,7 @@ class Vector3d extends XYZ {
|
|
|
217541
217762
|
* @param result optional preallocated result
|
|
217542
217763
|
*/
|
|
217543
217764
|
scaleToLength(length, result) {
|
|
217544
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
217765
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.correctSmallFraction(this.magnitude());
|
|
217545
217766
|
if (mag === 0)
|
|
217546
217767
|
return undefined;
|
|
217547
217768
|
return this.scale(length / mag, result);
|
|
@@ -217592,7 +217813,7 @@ class Vector3d extends XYZ {
|
|
|
217592
217813
|
* @param smallestMagnitude smallest magnitude allowed as divisor.
|
|
217593
217814
|
* @returns false if magnitude is too small. In this case the vector is unchanged.
|
|
217594
217815
|
*/
|
|
217595
|
-
tryNormalizeInPlace(smallestMagnitude = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.
|
|
217816
|
+
tryNormalizeInPlace(smallestMagnitude = _Geometry__WEBPACK_IMPORTED_MODULE_0__.Geometry.smallFraction) {
|
|
217596
217817
|
const a = this.magnitude();
|
|
217597
217818
|
if (a < smallestMagnitude || a === 0.0)
|
|
217598
217819
|
return false;
|
|
@@ -226373,7 +226594,6 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226373
226594
|
*/
|
|
226374
226595
|
static createPlaneFrom(source) {
|
|
226375
226596
|
return new Point4d(source.normalX(), source.normalY(), source.normalZ(), source.altitudeXYZ(0, 0, 0));
|
|
226376
|
-
return undefined;
|
|
226377
226597
|
}
|
|
226378
226598
|
/** Copy coordinates from `other`. */
|
|
226379
226599
|
setFrom(other) {
|
|
@@ -226516,7 +226736,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226516
226736
|
* * other structure with members x,y and optional z,w
|
|
226517
226737
|
* * array of numbers
|
|
226518
226738
|
* * default z is 0.0
|
|
226519
|
-
* * default
|
|
226739
|
+
* * default w is 1.0 (array[3] can replace)
|
|
226520
226740
|
*/
|
|
226521
226741
|
static createFromPoint(point) {
|
|
226522
226742
|
if (point instanceof _geometry3d_Point2dVector2d__WEBPACK_IMPORTED_MODULE_3__.Point2d)
|
|
@@ -226533,10 +226753,10 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226533
226753
|
const w1 = point.length > 3 ? point[3] : 1.0;
|
|
226534
226754
|
return new Point4d(x1, y1, z1, w1);
|
|
226535
226755
|
}
|
|
226536
|
-
const x = point.
|
|
226537
|
-
const y = point.
|
|
226756
|
+
const x = point.x;
|
|
226757
|
+
const y = point.y;
|
|
226538
226758
|
const z = point.hasOwnProperty("z") ? point.z : 0.0;
|
|
226539
|
-
const w = point.hasOwnProperty("w") ? point.w :
|
|
226759
|
+
const w = point.hasOwnProperty("w") ? point.w : 1.0;
|
|
226540
226760
|
return new Point4d(x, y, z, w);
|
|
226541
226761
|
}
|
|
226542
226762
|
/** Return `point + vector * scalar` */
|
|
@@ -226663,7 +226883,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226663
226883
|
* @param result optional result
|
|
226664
226884
|
*/
|
|
226665
226885
|
normalizeWeight(result) {
|
|
226666
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226886
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
226667
226887
|
result = result ? result : new Point4d();
|
|
226668
226888
|
return this.safeDivideOrNull(mag, result);
|
|
226669
226889
|
}
|
|
@@ -226673,7 +226893,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226673
226893
|
* @param result optional result
|
|
226674
226894
|
*/
|
|
226675
226895
|
realPoint(result) {
|
|
226676
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226896
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
226677
226897
|
if (mag === 0.0)
|
|
226678
226898
|
return undefined;
|
|
226679
226899
|
const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.
|
|
@@ -226684,7 +226904,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226684
226904
|
* * If `this.w` is zero, return a Vector3d `(x,y,z)`
|
|
226685
226905
|
*/
|
|
226686
226906
|
realPointOrVector() {
|
|
226687
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226907
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
226688
226908
|
if (mag === 0.0)
|
|
226689
226909
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Vector3d.create(this.x, this.y, this.z);
|
|
226690
226910
|
const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.
|
|
@@ -226700,7 +226920,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226700
226920
|
* @param result optional result
|
|
226701
226921
|
*/
|
|
226702
226922
|
static createRealPoint3dDefault000(x, y, z, w, result) {
|
|
226703
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226923
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(w);
|
|
226704
226924
|
const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.
|
|
226705
226925
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Point3d.create(x * a, y * a, z * a, result);
|
|
226706
226926
|
}
|
|
@@ -226718,7 +226938,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226718
226938
|
* @param result optional result
|
|
226719
226939
|
*/
|
|
226720
226940
|
static createRealDerivativeRay3dDefault000(x, y, z, w, dx, dy, dz, dw, result) {
|
|
226721
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226941
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(w);
|
|
226722
226942
|
// real point is X/w.
|
|
226723
226943
|
// real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.
|
|
226724
226944
|
const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.
|
|
@@ -226739,7 +226959,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226739
226959
|
* @param result optional result
|
|
226740
226960
|
*/
|
|
226741
226961
|
static createRealDerivativePlane3dByOriginAndVectorsDefault000(x, y, z, w, dx, dy, dz, dw, ddx, ddy, ddz, ddw, result) {
|
|
226742
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226962
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(w);
|
|
226743
226963
|
// real point is X/w.
|
|
226744
226964
|
// real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.
|
|
226745
226965
|
const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.
|
|
@@ -226757,7 +226977,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226757
226977
|
* * If this.w is zero, return 000
|
|
226758
226978
|
*/
|
|
226759
226979
|
realPointDefault000(result) {
|
|
226760
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226980
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.xyzw[3]);
|
|
226761
226981
|
if (mag === 0.0)
|
|
226762
226982
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Point3d.create(0, 0, 0, result);
|
|
226763
226983
|
result = result ? result : new _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_2__.Point3d();
|
|
@@ -226770,7 +226990,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
|
|
|
226770
226990
|
* * Use normalizeWeight to divide by the w component.
|
|
226771
226991
|
*/
|
|
226772
226992
|
normalizeXYZW(result) {
|
|
226773
|
-
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.
|
|
226993
|
+
const mag = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.correctSmallFraction(this.magnitudeXYZW());
|
|
226774
226994
|
result = result ? result : new Point4d();
|
|
226775
226995
|
return this.safeDivideOrNull(mag, result);
|
|
226776
226996
|
}
|
|
@@ -281396,7 +281616,7 @@ class TestContext {
|
|
|
281396
281616
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
281397
281617
|
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
|
|
281398
281618
|
await core_frontend_1.NoRenderApp.startup({
|
|
281399
|
-
applicationVersion: "4.0.0-dev.
|
|
281619
|
+
applicationVersion: "4.0.0-dev.68",
|
|
281400
281620
|
applicationId: this.settings.gprid,
|
|
281401
281621
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.adminUserAccessToken),
|
|
281402
281622
|
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
@@ -300969,7 +301189,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.21.4","description":"P
|
|
|
300969
301189
|
/***/ ((module) => {
|
|
300970
301190
|
|
|
300971
301191
|
"use strict";
|
|
300972
|
-
module.exports = JSON.parse('{"name":"@itwin/core-frontend","version":"4.0.0-dev.
|
|
301192
|
+
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"}}]}}');
|
|
300973
301193
|
|
|
300974
301194
|
/***/ }),
|
|
300975
301195
|
|