geometrix 1.0.11 → 1.0.13

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/dist/index.d.ts CHANGED
@@ -384,7 +384,7 @@ declare class Contour extends AContour {
384
384
  extractSkeleton(): Contour;
385
385
  generateContour(): Contour;
386
386
  generatePoints(dnb: number): Point[];
387
- getOrientation(iPts: Point[], extremX: number): boolean;
387
+ getOrientation(iPts: Point[], extremX: number, theMax: boolean): boolean;
388
388
  getEnvelop(): tEnvelop;
389
389
  generateLines(): Line[];
390
390
  /** @internal */
package/dist/index.js CHANGED
@@ -2267,27 +2267,32 @@ var Contour = class _Contour extends AContour {
2267
2267
  }
2268
2268
  return rPoints;
2269
2269
  }
2270
- getOrientation(iPts, extremX) {
2270
+ getOrientation(iPts, extremX, theMax) {
2271
+ const epsilon = 10 ** -3;
2271
2272
  const pts = iPts.slice(1);
2272
2273
  let sign = 0;
2273
2274
  let pt1 = pts.at(-3);
2274
2275
  let pt2 = pts.at(-2);
2275
2276
  let pt3 = pts.at(-1);
2276
- for (const pt of pts) {
2277
+ let foundIdx = -1;
2278
+ for (const [idx, pt] of pts.entries()) {
2277
2279
  pt1 = pt2;
2278
2280
  pt2 = pt3;
2279
2281
  pt3 = pt;
2280
- if (pt2.cx === extremX) {
2282
+ const extrem = theMax ? pt2.cx > extremX - epsilon : pt2.cx < extremX + epsilon;
2283
+ const lastExtrem = theMax ? pt1.cx > extremX - epsilon : pt1.cx < extremX + epsilon;
2284
+ if (extrem && !lastExtrem) {
2281
2285
  const vx = pt1.cx - pt2.cx;
2282
2286
  const vy = pt1.cy - pt2.cy;
2283
2287
  const ux = pt3.cx - pt2.cx;
2284
2288
  const uy = pt3.cy - pt2.cy;
2285
2289
  const pv = ux * vy - uy * vx;
2286
2290
  sign = Math.sign(pv);
2291
+ foundIdx = idx;
2287
2292
  }
2288
2293
  }
2289
2294
  if (0 === sign) {
2290
- throw `err299: Orientation not found at point ${pts.length} ${ffix(pt1.cx)} ${ffix(pt1.cy)} ${ffix(pt2.cx)} ${ffix(pt2.cy)} ${ffix(pt3.cx)} ${ffix(pt3.cy)}`;
2295
+ throw `err299: Orientation not found with ${pts.length} points and foundIdx ${foundIdx}`;
2291
2296
  }
2292
2297
  const rOrientation = sign > 0 ? true : false;
2293
2298
  return rOrientation;
@@ -2304,8 +2309,8 @@ var Contour = class _Contour extends AContour {
2304
2309
  const rXmax = Math.max(...lx);
2305
2310
  const rYmin = Math.min(...ly);
2306
2311
  const rYmax = Math.max(...ly);
2307
- const rOrientation = this.getOrientation(pts, rXmin);
2308
- const orient2 = this.getOrientation(pts, rXmax);
2312
+ const rOrientation = this.getOrientation(pts, rXmin, false);
2313
+ const orient2 = this.getOrientation(pts, rXmax, true);
2309
2314
  if (orient2 !== rOrientation) {
2310
2315
  throw `err390: orientation unstable ${rOrientation} ${orient2} with ${pts.length} points`;
2311
2316
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geometrix",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "The 2D geometry engine of the parametrix",
5
5
  "private": false,
6
6
  "repository": {
@@ -69,15 +69,15 @@
69
69
  "devDependencies": {
70
70
  "@eslint/js": "^9.10.0",
71
71
  "@types/eslint__js": "^8.42.3",
72
- "@types/node": "^22.13.5",
72
+ "@types/node": "^22.13.8",
73
73
  "eslint": "^9.21.0",
74
- "eslint-config-prettier": "^10.0.1",
74
+ "eslint-config-prettier": "^10.0.2",
75
75
  "npm-run-all2": "^7.0.2",
76
76
  "prettier": "^3.5.2",
77
77
  "rimraf": "^6.0.1",
78
- "tsup": "^8.3.6",
78
+ "tsup": "^8.4.0",
79
79
  "typescript": "^5.7.3",
80
- "typescript-eslint": "^8.24.1",
81
- "vitest": "^3.0.6"
80
+ "typescript-eslint": "^8.25.0",
81
+ "vitest": "^3.0.7"
82
82
  }
83
83
  }