geometrix 1.0.10 → 1.0.12
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 +1 -1
- package/dist/index.js +10 -6
- package/package.json +2 -2
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,31 @@ 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
|
-
|
|
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
|
-
|
|
2282
|
+
const extrem = theMax ? pt2.cx > extremX - epsilon : pt2.cx < extremX + epsilon;
|
|
2283
|
+
if (extrem) {
|
|
2281
2284
|
const vx = pt1.cx - pt2.cx;
|
|
2282
2285
|
const vy = pt1.cy - pt2.cy;
|
|
2283
2286
|
const ux = pt3.cx - pt2.cx;
|
|
2284
2287
|
const uy = pt3.cy - pt2.cy;
|
|
2285
2288
|
const pv = ux * vy - uy * vx;
|
|
2286
2289
|
sign = Math.sign(pv);
|
|
2290
|
+
foundIdx = idx;
|
|
2287
2291
|
}
|
|
2288
2292
|
}
|
|
2289
2293
|
if (0 === sign) {
|
|
2290
|
-
throw `err299: Orientation
|
|
2294
|
+
throw `err299: Orientation not found with ${pts.length} points and foundIdx ${foundIdx}`;
|
|
2291
2295
|
}
|
|
2292
2296
|
const rOrientation = sign > 0 ? true : false;
|
|
2293
2297
|
return rOrientation;
|
|
@@ -2304,8 +2308,8 @@ var Contour = class _Contour extends AContour {
|
|
|
2304
2308
|
const rXmax = Math.max(...lx);
|
|
2305
2309
|
const rYmin = Math.min(...ly);
|
|
2306
2310
|
const rYmax = Math.max(...ly);
|
|
2307
|
-
const rOrientation = this.getOrientation(pts, rXmin);
|
|
2308
|
-
const orient2 = this.getOrientation(pts, rXmax);
|
|
2311
|
+
const rOrientation = this.getOrientation(pts, rXmin, false);
|
|
2312
|
+
const orient2 = this.getOrientation(pts, rXmax, true);
|
|
2309
2313
|
if (orient2 !== rOrientation) {
|
|
2310
2314
|
throw `err390: orientation unstable ${rOrientation} ${orient2} with ${pts.length} points`;
|
|
2311
2315
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geometrix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "The 2D geometry engine of the parametrix",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"eslint": "^9.21.0",
|
|
74
74
|
"eslint-config-prettier": "^10.0.1",
|
|
75
75
|
"npm-run-all2": "^7.0.2",
|
|
76
|
-
"prettier": "^3.5.
|
|
76
|
+
"prettier": "^3.5.2",
|
|
77
77
|
"rimraf": "^6.0.1",
|
|
78
78
|
"tsup": "^8.3.6",
|
|
79
79
|
"typescript": "^5.7.3",
|