@thi.ng/geom-closest-point 2.0.8 → 2.1.2
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/CHANGELOG.md +88 -52
- package/README.md +1 -1
- package/ellipse.js +1 -1
- package/package.json +99 -94
- package/points.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,103 +1,139 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## [2.0.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@2.0.7...@thi.ng/geom-closest-point@2.0.8) (2021-11-04)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @thi.ng/geom-closest-point
|
|
9
|
-
|
|
3
|
+
- **Last updated**: 2021-11-21T17:09:28Z
|
|
4
|
+
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
10
5
|
|
|
6
|
+
All notable changes to this project will be documented in this file.
|
|
7
|
+
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
11
8
|
|
|
9
|
+
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
|
+
and/or version bumps of transitive dependencies.
|
|
12
11
|
|
|
12
|
+
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@2.1.0) (2021-11-17)
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
#### 🚀 Features
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
- Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
|
|
17
|
+
Improving the overall build ergonomics
|
|
18
|
+
- introduced a tools workspaces
|
|
19
|
+
- imported it in all needed packages/examples
|
|
20
|
+
- inclusive project root
|
|
17
21
|
|
|
22
|
+
#### ♻️ Refactoring
|
|
18
23
|
|
|
24
|
+
- testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
|
|
25
|
+
this commit reverts (partly) changes made in:
|
|
26
|
+
ef346d7a8753590dc9094108a3d861a8dbd5dd2c
|
|
27
|
+
overall purpose is better testament ergonomics:
|
|
28
|
+
instead of having to pass NODE_OPTIONS with every invocation
|
|
29
|
+
having a binary to handle this for us.
|
|
19
30
|
|
|
31
|
+
### [2.0.9](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@2.0.9) (2021-11-10)
|
|
20
32
|
|
|
33
|
+
#### ♻️ Refactoring
|
|
21
34
|
|
|
22
|
-
|
|
35
|
+
- update all countdown loops ([a5f374b](https://github.com/thi-ng/umbrella/commit/a5f374b))
|
|
23
36
|
|
|
37
|
+
### [2.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@2.0.1) (2021-10-13)
|
|
24
38
|
|
|
25
|
-
|
|
39
|
+
#### ♻️ Refactoring
|
|
26
40
|
|
|
27
|
-
|
|
41
|
+
- update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
|
|
42
|
+
- update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
|
|
43
|
+
- add .js suffix for all relative imports
|
|
28
44
|
|
|
45
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@2.0.0) (2021-10-12)
|
|
29
46
|
|
|
30
|
-
|
|
47
|
+
#### 🛑 Breaking changes
|
|
31
48
|
|
|
32
|
-
|
|
49
|
+
- major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
|
|
50
|
+
- BREAKING CHANGE: discontinue CommonJS & UMD versions
|
|
51
|
+
- only ESM modules will be published from now on
|
|
52
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
53
|
+
- i.e. launch NodeJS via:
|
|
54
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
55
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
56
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
57
|
+
Also:
|
|
58
|
+
- normalize/restructure/reorg all package.json files
|
|
59
|
+
- cleanup all build scripts, remove obsolete
|
|
60
|
+
- switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
|
|
33
61
|
|
|
34
|
-
|
|
35
|
-
- CJS obsolete due to ESM support in recent versions of node:
|
|
36
|
-
- i.e. launch NodeJS via:
|
|
37
|
-
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
38
|
-
- in the node REPL use `await import(...)` instead of `require()`
|
|
39
|
-
- UMD obsolete due to widespread browser support for ESM
|
|
62
|
+
#### ♻️ Refactoring
|
|
40
63
|
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
64
|
+
- update imports ([a2f825d](https://github.com/thi-ng/umbrella/commit/a2f825d))
|
|
65
|
+
- update all test stubs ([f2d6d53](https://github.com/thi-ng/umbrella/commit/f2d6d53))
|
|
66
|
+
- update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
|
|
67
|
+
- update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
|
|
45
68
|
|
|
69
|
+
### [0.5.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@0.5.4) (2020-12-07)
|
|
46
70
|
|
|
71
|
+
#### ♻️ Refactoring
|
|
47
72
|
|
|
73
|
+
- update type-only imports in various tests/pkgs ([3fd9c24](https://github.com/thi-ng/umbrella/commit/3fd9c24))
|
|
48
74
|
|
|
75
|
+
## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@0.5.0) (2020-09-22)
|
|
49
76
|
|
|
77
|
+
#### 🚀 Features
|
|
50
78
|
|
|
51
|
-
|
|
79
|
+
- add support for custom dist fn ([95557f6](https://github.com/thi-ng/umbrella/commit/95557f6))
|
|
52
80
|
|
|
53
|
-
|
|
81
|
+
#### 🩹 Bug fixes
|
|
54
82
|
|
|
55
|
-
|
|
83
|
+
- update closestPointPolyline() ([1358bac](https://github.com/thi-ng/umbrella/commit/1358bac))
|
|
84
|
+
- add check if at least a single closest point has been found
|
|
56
85
|
|
|
57
|
-
|
|
86
|
+
## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@0.4.0) (2020-09-13)
|
|
58
87
|
|
|
59
|
-
|
|
88
|
+
#### 🚀 Features
|
|
60
89
|
|
|
61
|
-
|
|
90
|
+
- add ellipse support, restructure pkg ([d331b26](https://github.com/thi-ng/umbrella/commit/d331b26))
|
|
91
|
+
- add `closestPointEllipse()`
|
|
62
92
|
|
|
63
|
-
|
|
93
|
+
#### 🩹 Bug fixes
|
|
64
94
|
|
|
65
|
-
|
|
95
|
+
- use alt algorithm closestPointEllipse() ([6b3d00f](https://github.com/thi-ng/umbrella/commit/6b3d00f))
|
|
96
|
+
- new approach has no weird edge cases as previous
|
|
66
97
|
|
|
67
|
-
|
|
98
|
+
#### ♻️ Refactoring
|
|
68
99
|
|
|
69
|
-
-
|
|
100
|
+
- update deps, imports, use new Fn types ([dcef770](https://github.com/thi-ng/umbrella/commit/dcef770))
|
|
70
101
|
|
|
71
|
-
###
|
|
102
|
+
### [0.3.7](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@0.3.7) (2019-08-21)
|
|
72
103
|
|
|
73
|
-
|
|
104
|
+
#### ♻️ Refactoring
|
|
74
105
|
|
|
75
|
-
|
|
106
|
+
- update closestPointRect/AABB (re-use) ([0c33878](https://github.com/thi-ng/umbrella/commit/0c33878))
|
|
107
|
+
- extract closestBoxEdge()
|
|
76
108
|
|
|
77
|
-
|
|
109
|
+
## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@0.3.0) (2019-07-07)
|
|
78
110
|
|
|
79
|
-
|
|
80
|
-
- **geom-closest-point:** update polyline & point array fns ([c5b4757](https://github.com/thi-ng/umbrella/commit/c5b4757))
|
|
111
|
+
#### 🚀 Features
|
|
81
112
|
|
|
82
|
-
|
|
113
|
+
- enable TS strict compiler flags (refactor) ([b6b69e6](https://github.com/thi-ng/umbrella/commit/b6b69e6))
|
|
83
114
|
|
|
84
|
-
|
|
115
|
+
#### 🩹 Bug fixes
|
|
85
116
|
|
|
86
|
-
|
|
117
|
+
- type hints (TS 3.5.2) ([fa146d7](https://github.com/thi-ng/umbrella/commit/fa146d7))
|
|
118
|
+
- update polyline & point array fns ([c5b4757](https://github.com/thi-ng/umbrella/commit/c5b4757))
|
|
87
119
|
|
|
88
|
-
|
|
120
|
+
#### ♻️ Refactoring
|
|
89
121
|
|
|
90
|
-
-
|
|
122
|
+
- TS strictNullChecks, update return types ([f1b8ef9](https://github.com/thi-ng/umbrella/commit/f1b8ef9))
|
|
91
123
|
|
|
92
|
-
|
|
124
|
+
### [0.2.3](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@0.2.3) (2019-05-22)
|
|
93
125
|
|
|
94
|
-
|
|
126
|
+
#### 🩹 Bug fixes
|
|
95
127
|
|
|
96
|
-
-
|
|
128
|
+
- flip sign of plane W component, extract distToPlane() ([74dbcb0](https://github.com/thi-ng/umbrella/commit/74dbcb0))
|
|
97
129
|
|
|
98
|
-
|
|
130
|
+
## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-closest-point@0.2.0) (2019-04-15)
|
|
99
131
|
|
|
100
|
-
|
|
132
|
+
#### 🚀 Features
|
|
101
133
|
|
|
102
|
-
-
|
|
103
|
-
-
|
|
134
|
+
- add fns for more shape types ([5ae2887](https://github.com/thi-ng/umbrella/commit/5ae2887))
|
|
135
|
+
- closestPointLine
|
|
136
|
+
- distToLine
|
|
137
|
+
- closestPointPlane
|
|
138
|
+
- closestPointCircle/Sphere
|
|
139
|
+
- closestPointAABB/Rect
|
package/README.md
CHANGED
package/ellipse.js
CHANGED
|
@@ -22,7 +22,7 @@ export const closestPointEllipse = ([px, py], [ex, ey], [rx, ry], n = 3) => {
|
|
|
22
22
|
const ba = (ry * ry - rx * rx) / ry;
|
|
23
23
|
let tx = SQRT2_2;
|
|
24
24
|
let ty = tx;
|
|
25
|
-
for (; --
|
|
25
|
+
for (; n-- > 0;) {
|
|
26
26
|
const _ex = ab * tx * tx * tx;
|
|
27
27
|
const _ey = ba * ty * ty * ty;
|
|
28
28
|
const qx = apx - _ex;
|
package/package.json
CHANGED
|
@@ -1,102 +1,107 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"name": "@thi.ng/geom-closest-point",
|
|
3
|
+
"version": "2.1.2",
|
|
4
|
+
"description": "2D / 3D closest point / proximity helpers",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/geom-closest-point#readme",
|
|
14
|
+
"funding": [
|
|
15
|
+
{
|
|
16
|
+
"type": "github",
|
|
17
|
+
"url": "https://github.com/sponsors/postspectacular"
|
|
12
18
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
{
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://patreon.com/thing_umbrella"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
|
+
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
31
|
+
"doc:readme": "yarn doc:stats && tools:readme",
|
|
32
|
+
"doc:stats": "tools:module-stats",
|
|
33
|
+
"pub": "yarn npm publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@thi.ng/api": "^8.3.2",
|
|
38
|
+
"@thi.ng/math": "^5.1.2",
|
|
39
|
+
"@thi.ng/vectors": "^7.2.2"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@microsoft/api-extractor": "^7.18.19",
|
|
43
|
+
"@thi.ng/testament": "^0.2.2",
|
|
44
|
+
"rimraf": "^3.0.2",
|
|
45
|
+
"tools": "^0.0.1",
|
|
46
|
+
"typedoc": "^0.22.9",
|
|
47
|
+
"typescript": "^4.5.2"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"2d",
|
|
51
|
+
"3d",
|
|
52
|
+
"bbox",
|
|
53
|
+
"circle",
|
|
54
|
+
"distance",
|
|
55
|
+
"ellipse",
|
|
56
|
+
"geometry",
|
|
57
|
+
"line",
|
|
58
|
+
"points",
|
|
59
|
+
"polygon",
|
|
60
|
+
"polyline",
|
|
61
|
+
"proximity",
|
|
62
|
+
"rect",
|
|
63
|
+
"typescript"
|
|
64
|
+
],
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=12.7"
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"*.js",
|
|
73
|
+
"*.d.ts"
|
|
74
|
+
],
|
|
75
|
+
"exports": {
|
|
76
|
+
".": {
|
|
77
|
+
"import": "./index.js"
|
|
35
78
|
},
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"@thi.ng/math": "^5.0.7",
|
|
39
|
-
"@thi.ng/vectors": "^7.1.0"
|
|
79
|
+
"./box": {
|
|
80
|
+
"import": "./box.js"
|
|
40
81
|
},
|
|
41
|
-
"
|
|
42
|
-
|
|
82
|
+
"./circle": {
|
|
83
|
+
"import": "./circle.js"
|
|
43
84
|
},
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
"3d",
|
|
47
|
-
"bbox",
|
|
48
|
-
"circle",
|
|
49
|
-
"distance",
|
|
50
|
-
"ellipse",
|
|
51
|
-
"geometry",
|
|
52
|
-
"line",
|
|
53
|
-
"points",
|
|
54
|
-
"polygon",
|
|
55
|
-
"polyline",
|
|
56
|
-
"proximity",
|
|
57
|
-
"rect",
|
|
58
|
-
"typescript"
|
|
59
|
-
],
|
|
60
|
-
"publishConfig": {
|
|
61
|
-
"access": "public"
|
|
85
|
+
"./ellipse": {
|
|
86
|
+
"import": "./ellipse.js"
|
|
62
87
|
},
|
|
63
|
-
"
|
|
64
|
-
|
|
88
|
+
"./line": {
|
|
89
|
+
"import": "./line.js"
|
|
65
90
|
},
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
"*.d.ts"
|
|
69
|
-
],
|
|
70
|
-
"exports": {
|
|
71
|
-
".": {
|
|
72
|
-
"import": "./index.js"
|
|
73
|
-
},
|
|
74
|
-
"./box": {
|
|
75
|
-
"import": "./box.js"
|
|
76
|
-
},
|
|
77
|
-
"./circle": {
|
|
78
|
-
"import": "./circle.js"
|
|
79
|
-
},
|
|
80
|
-
"./ellipse": {
|
|
81
|
-
"import": "./ellipse.js"
|
|
82
|
-
},
|
|
83
|
-
"./line": {
|
|
84
|
-
"import": "./line.js"
|
|
85
|
-
},
|
|
86
|
-
"./plane": {
|
|
87
|
-
"import": "./plane.js"
|
|
88
|
-
},
|
|
89
|
-
"./points": {
|
|
90
|
-
"import": "./points.js"
|
|
91
|
-
}
|
|
91
|
+
"./plane": {
|
|
92
|
+
"import": "./plane.js"
|
|
92
93
|
},
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
"./points": {
|
|
95
|
+
"import": "./points.js"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"thi.ng": {
|
|
99
|
+
"parent": "@thi.ng/geom",
|
|
100
|
+
"related": [
|
|
101
|
+
"geom-isec",
|
|
102
|
+
"geom-resample"
|
|
103
|
+
],
|
|
104
|
+
"year": 2018
|
|
105
|
+
},
|
|
106
|
+
"gitHead": "e8a7c2a40191b391cef182c2978e5a6c85987a87\n"
|
|
107
|
+
}
|
package/points.js
CHANGED
|
@@ -12,7 +12,7 @@ import { set } from "@thi.ng/vectors/set";
|
|
|
12
12
|
export const closestPointArray = (p, pts, out = [], dist = distSq) => {
|
|
13
13
|
let minD = Infinity;
|
|
14
14
|
let closest;
|
|
15
|
-
for (let i = pts.length; --
|
|
15
|
+
for (let i = pts.length; i-- > 0;) {
|
|
16
16
|
const d = dist(pts[i], p);
|
|
17
17
|
if (d < minD) {
|
|
18
18
|
minD = d;
|