dgeoutils 2.3.6 → 2.4.1

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.
@@ -147,3 +147,16 @@ export const createCanvas = (a, b, c) => {
147
147
  };
148
148
  const f = (a, b) => [].concat(...a.map((c) => b.map((d) => [].concat(c, d))));
149
149
  export const cartesianProduct = (a, b, ...c) => b ? cartesianProduct(f(a, b), ...c) : a;
150
+ export const getCombinations = (arr) => {
151
+ if (arr.length === 1) {
152
+ return arr[0];
153
+ }
154
+ const ans = [];
155
+ const otherCases = getCombinations(arr.slice(1));
156
+ for (let i = 0; i < otherCases.length; i++) {
157
+ for (let j = 0; j < arr[0].length; j++) {
158
+ ans.push([arr[0][j], ...otherCases[i]]);
159
+ }
160
+ }
161
+ return ans;
162
+ };
@@ -958,8 +958,9 @@ var DPolygon = (function () {
958
958
  DPolygon.prototype.toArrayOfCoords = function () {
959
959
  return this.mapArray(function (r) { return r.toCoords(); });
960
960
  };
961
- DPolygon.prototype.divideToPieces = function (piecesCount) {
961
+ DPolygon.prototype.divideToPieces = function (piecesCount, withAltitude) {
962
962
  var e_13, _a;
963
+ if (withAltitude === void 0) { withAltitude = false; }
963
964
  var fullLength = this.fullLength;
964
965
  var pieceLength = fullLength / piecesCount;
965
966
  var currentPieceLength = pieceLength;
@@ -976,6 +977,10 @@ var DPolygon = (function () {
976
977
  .filter(function (p) { return line_1.inRange(p, CLOSE_TO_INTERSECTION_DISTANCE); })[0];
977
978
  intersectionPoint.properties.pieceBorder = true;
978
979
  this_1.insertAfter(i, intersectionPoint);
980
+ if (withAltitude) {
981
+ var p1z = p1.z;
982
+ intersectionPoint.z = p1z - (p1z - p2.z) * (p1.distance(intersectionPoint) / d);
983
+ }
979
984
  currentPieceLength = pieceLength;
980
985
  }
981
986
  else {
package/dist/esm/index.js CHANGED
@@ -7,4 +7,4 @@ export * from './FastSearch';
7
7
  export * from './TraceMatrix';
8
8
  export * from './DPolygonLoop';
9
9
  export * from './DPlane';
10
- export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, DGeo } from './utils';
10
+ export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, getCombinations, DGeo } from './utils';
package/dist/esm/utils.js CHANGED
@@ -189,3 +189,16 @@ export var cartesianProduct = function (a, b) {
189
189
  }
190
190
  return b ? cartesianProduct.apply(void 0, __spreadArray([f(a, b)], __read(c), false)) : a;
191
191
  };
192
+ export var getCombinations = function (arr) {
193
+ if (arr.length === 1) {
194
+ return arr[0];
195
+ }
196
+ var ans = [];
197
+ var otherCases = getCombinations(arr.slice(1));
198
+ for (var i = 0; i < otherCases.length; i++) {
199
+ for (var j = 0; j < arr[0].length; j++) {
200
+ ans.push(__spreadArray([arr[0][j]], __read(otherCases[i]), false));
201
+ }
202
+ }
203
+ return ans;
204
+ };