@vertexvis/geometry 0.13.2-canary.9 → 0.14.0

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/README.md CHANGED
@@ -24,7 +24,7 @@ viewer.
24
24
  </head>
25
25
  <body>
26
26
  <script type="module">
27
- import { Vector3 } from 'https://unpkg.com/@vertexvis/geometry@0.13.1/dist/cdn/bundle.esm.js';
27
+ import { Vector3 } from 'https://unpkg.com/@vertexvis/geometry@0.14.0/dist/cdn/bundle.esm.js';
28
28
 
29
29
  async function main() {
30
30
  const viewer = document.querySelector('#viewer');
@@ -19,6 +19,15 @@ export declare const fromVectors: (vectors: Vector3.Vector3[]) => BoundingBox |
19
19
  * Returns the center point of the given `BoundingBox`.
20
20
  */
21
21
  export declare const center: (boundingBox: BoundingBox) => Vector3.Vector3;
22
+ /**
23
+ * Returns the diagonal vector between the `min` and `max` vectors of the
24
+ * given `BoundingBox`.
25
+ */
26
+ export declare const diagonal: (boundingBox: BoundingBox) => Vector3.Vector3;
27
+ /**
28
+ * Returns a floating-point spatial error tolerance based on the extents of the box.
29
+ */
30
+ export declare const epsilon: (boundingBox: BoundingBox) => number;
22
31
  /**
23
32
  * Combine two or more bounding boxes into a new minimal bounding box that
24
33
  * contains both.
@@ -1149,6 +1149,19 @@ var fromVectors = function (vectors) {
1149
1149
  var center$3 = function (boundingBox) {
1150
1150
  return scale$2(0.5, add(boundingBox.min, boundingBox.max));
1151
1151
  };
1152
+ /**
1153
+ * Returns the diagonal vector between the `min` and `max` vectors of the
1154
+ * given `BoundingBox`.
1155
+ */
1156
+ var diagonal = function (boundingBox) {
1157
+ return subtract(boundingBox.max, boundingBox.min);
1158
+ };
1159
+ /**
1160
+ * Returns a floating-point spatial error tolerance based on the extents of the box.
1161
+ */
1162
+ var epsilon = function (boundingBox) {
1163
+ return (Math.max(Math.max(magnitude(boundingBox.max), magnitude(boundingBox.min)), magnitude(diagonal(boundingBox))) * 1e-6);
1164
+ };
1152
1165
  function union(box) {
1153
1166
  var rest = [];
1154
1167
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -1166,6 +1179,8 @@ var boundingBox = /*#__PURE__*/Object.freeze({
1166
1179
  create: create$a,
1167
1180
  fromVectors: fromVectors,
1168
1181
  center: center$3,
1182
+ diagonal: diagonal,
1183
+ epsilon: epsilon,
1169
1184
  union: union
1170
1185
  });
1171
1186
 
@@ -1342,6 +1357,24 @@ function isSquare(rect) {
1342
1357
  function pad(rect, padding) {
1343
1358
  return create$8(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1344
1359
  }
1360
+ /**
1361
+ * Returns `true` if the given rectangle contains all the given `points`.
1362
+ *
1363
+ * @param rect The rectangle to check against.
1364
+ * @param points The points to check.
1365
+ */
1366
+ function containsPoints(rect) {
1367
+ var points = [];
1368
+ for (var _i = 1; _i < arguments.length; _i++) {
1369
+ points[_i - 1] = arguments[_i];
1370
+ }
1371
+ return points.every(function (point) {
1372
+ return (rect.x <= point.x &&
1373
+ rect.x + rect.width >= point.x &&
1374
+ rect.y <= point.y &&
1375
+ rect.y + rect.height >= point.y);
1376
+ });
1377
+ }
1345
1378
  /**
1346
1379
  * Parses a JSON string representation of a Rectangle and returns an object.
1347
1380
  *
@@ -1380,6 +1413,7 @@ var rectangle = /*#__PURE__*/Object.freeze({
1380
1413
  isLandscape: isLandscape,
1381
1414
  isSquare: isSquare,
1382
1415
  pad: pad,
1416
+ containsPoints: containsPoints,
1383
1417
  fromJson: fromJson$2
1384
1418
  });
1385
1419
 
@@ -2037,7 +2071,7 @@ function fromMatrixRotation(matrix) {
2037
2071
  x: 0.25 * s,
2038
2072
  y: (sm12 + sm21) / s,
2039
2073
  z: (sm31 + sm13) / s,
2040
- w: s,
2074
+ w: (sm23 - sm32) / s,
2041
2075
  };
2042
2076
  }
2043
2077
  else if (sm22 > sm33) {