@thi.ng/geom-closest-point 1.0.4 → 2.0.3

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [1.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@1.0.3...@thi.ng/geom-closest-point@1.0.4) (2021-08-19)
6
+ ## [2.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@2.0.2...@thi.ng/geom-closest-point@2.0.3) (2021-10-15)
7
7
 
8
8
  **Note:** Version bump only for package @thi.ng/geom-closest-point
9
9
 
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
14
- ## [1.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@1.0.2...@thi.ng/geom-closest-point@1.0.3) (2021-08-19)
14
+ ## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@2.0.1...@thi.ng/geom-closest-point@2.0.2) (2021-10-15)
15
15
 
16
16
  **Note:** Version bump only for package @thi.ng/geom-closest-point
17
17
 
@@ -19,7 +19,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
19
19
 
20
20
 
21
21
 
22
- ## [1.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@1.0.1...@thi.ng/geom-closest-point@1.0.2) (2021-08-17)
22
+ ## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@2.0.0...@thi.ng/geom-closest-point@2.0.1) (2021-10-13)
23
23
 
24
24
  **Note:** Version bump only for package @thi.ng/geom-closest-point
25
25
 
@@ -27,120 +27,85 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
27
27
 
28
28
 
29
29
 
30
- ## [1.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.5.31...@thi.ng/geom-closest-point@1.0.1) (2021-08-08)
31
-
32
- **Note:** Version bump only for package @thi.ng/geom-closest-point
33
-
34
-
35
-
36
-
37
-
38
- ## [0.5.31](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.5.30...@thi.ng/geom-closest-point@0.5.31) (2021-08-08)
39
-
40
- **Note:** Version bump only for package @thi.ng/geom-closest-point
41
-
42
-
43
-
44
-
45
-
46
- ## [0.5.30](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.5.29...@thi.ng/geom-closest-point@0.5.30) (2021-08-04)
47
-
48
- **Note:** Version bump only for package @thi.ng/geom-closest-point
49
-
50
-
51
-
52
-
53
-
54
- ## [0.5.29](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.5.28...@thi.ng/geom-closest-point@0.5.29) (2021-08-04)
55
-
56
- **Note:** Version bump only for package @thi.ng/geom-closest-point
57
-
58
-
59
-
60
-
61
-
62
- ## [0.5.28](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.5.27...@thi.ng/geom-closest-point@0.5.28) (2021-07-27)
63
-
64
- **Note:** Version bump only for package @thi.ng/geom-closest-point
65
-
66
-
67
-
68
-
69
-
70
- ## [0.5.27](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.5.26...@thi.ng/geom-closest-point@0.5.27) (2021-07-01)
71
-
72
- **Note:** Version bump only for package @thi.ng/geom-closest-point
73
-
74
-
75
-
76
-
77
-
78
- ## [0.5.26](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.5.25...@thi.ng/geom-closest-point@0.5.26) (2021-06-08)
79
-
80
- **Note:** Version bump only for package @thi.ng/geom-closest-point
81
-
30
+ # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@1.0.5...@thi.ng/geom-closest-point@2.0.0) (2021-10-12)
82
31
 
83
32
 
33
+ ### Build System
84
34
 
35
+ * major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
85
36
 
86
- # [0.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.4.0...@thi.ng/geom-closest-point@0.5.0) (2020-09-22)
87
37
 
38
+ ### BREAKING CHANGES
88
39
 
89
- ### Bug Fixes
40
+ * discontinue CommonJS & UMD versions
90
41
 
91
- * **geom-closest-point:** update closestPointPolyline() ([1358bac](https://github.com/thi-ng/umbrella/commit/1358bac1a95359340b19adb91b1813edf3e1645a))
42
+ - only ESM modules will be published from now on
43
+ - CJS obsolete due to ESM support in recent versions of node:
44
+ - i.e. launch NodeJS via:
45
+ - `node --experimental-specifier-resolution=node --experimental-repl-await`
46
+ - in the node REPL use `await import(...)` instead of `require()`
47
+ - UMD obsolete due to widespread browser support for ESM
92
48
 
49
+ Also:
50
+ - normalize/restructure/reorg all package.json files
51
+ - cleanup all build scripts, remove obsolete
52
+ - switch from mocha to @thi.ng/testament for all tests
93
53
 
94
- ### Features
95
54
 
96
- * **geom-closest-point:** add support for custom dist fn ([95557f6](https://github.com/thi-ng/umbrella/commit/95557f6716071a92433868ce8536ca1c38a54073))
97
55
 
98
56
 
99
57
 
100
58
 
59
+ ## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@1.0.4...@thi.ng/geom-closest-point@1.0.5) (2021-09-03)
101
60
 
102
- # [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.3.44...@thi.ng/geom-closest-point@0.4.0) (2020-09-13)
61
+ **Note:** Version bump only for package @thi.ng/geom-closest-point
103
62
 
63
+ # [0.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.4.0...@thi.ng/geom-closest-point@0.5.0) (2020-09-22)
104
64
 
105
- ### Bug Fixes
65
+ ### Bug Fixes
106
66
 
107
- * **geom-closest-point:** use alt algorithm closestPointEllipse() ([6b3d00f](https://github.com/thi-ng/umbrella/commit/6b3d00ff84aba9a430e50e2a0a9d7e0e15e95d02))
67
+ - **geom-closest-point:** update closestPointPolyline() ([1358bac](https://github.com/thi-ng/umbrella/commit/1358bac1a95359340b19adb91b1813edf3e1645a))
108
68
 
69
+ ### Features
109
70
 
110
- ### Features
71
+ - **geom-closest-point:** add support for custom dist fn ([95557f6](https://github.com/thi-ng/umbrella/commit/95557f6716071a92433868ce8536ca1c38a54073))
111
72
 
112
- * **geom-closest-point:** add ellipse support, restructure pkg ([d331b26](https://github.com/thi-ng/umbrella/commit/d331b26fc0a0d16ed2775a784ab709ab3b6dcf60))
73
+ # [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.3.44...@thi.ng/geom-closest-point@0.4.0) (2020-09-13)
113
74
 
75
+ ### Bug Fixes
114
76
 
77
+ - **geom-closest-point:** use alt algorithm closestPointEllipse() ([6b3d00f](https://github.com/thi-ng/umbrella/commit/6b3d00ff84aba9a430e50e2a0a9d7e0e15e95d02))
115
78
 
79
+ ### Features
116
80
 
81
+ - **geom-closest-point:** add ellipse support, restructure pkg ([d331b26](https://github.com/thi-ng/umbrella/commit/d331b26fc0a0d16ed2775a784ab709ab3b6dcf60))
117
82
 
118
- # [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.2.3...@thi.ng/geom-closest-point@0.3.0) (2019-07-07)
83
+ # [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.2.3...@thi.ng/geom-closest-point@0.3.0) (2019-07-07)
119
84
 
120
- ### Bug Fixes
85
+ ### Bug Fixes
121
86
 
122
- * **geom-closest-point:** type hints (TS 3.5.2) ([fa146d7](https://github.com/thi-ng/umbrella/commit/fa146d7))
123
- * **geom-closest-point:** update polyline & point array fns ([c5b4757](https://github.com/thi-ng/umbrella/commit/c5b4757))
87
+ - **geom-closest-point:** type hints (TS 3.5.2) ([fa146d7](https://github.com/thi-ng/umbrella/commit/fa146d7))
88
+ - **geom-closest-point:** update polyline & point array fns ([c5b4757](https://github.com/thi-ng/umbrella/commit/c5b4757))
124
89
 
125
- ### Features
90
+ ### Features
126
91
 
127
- * **geom-clostest-point:** enable TS strict compiler flags (refactor) ([b6b69e6](https://github.com/thi-ng/umbrella/commit/b6b69e6))
92
+ - **geom-clostest-point:** enable TS strict compiler flags (refactor) ([b6b69e6](https://github.com/thi-ng/umbrella/commit/b6b69e6))
128
93
 
129
- ## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.2.2...@thi.ng/geom-closest-point@0.2.3) (2019-05-22)
94
+ ## [0.2.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.2.2...@thi.ng/geom-closest-point@0.2.3) (2019-05-22)
130
95
 
131
- ### Bug Fixes
96
+ ### Bug Fixes
132
97
 
133
- * **geom-closest-point:** flip sign of plane W component, extract distToPlane() ([74dbcb0](https://github.com/thi-ng/umbrella/commit/74dbcb0))
98
+ - **geom-closest-point:** flip sign of plane W component, extract distToPlane() ([74dbcb0](https://github.com/thi-ng/umbrella/commit/74dbcb0))
134
99
 
135
- # [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.13...@thi.ng/geom-closest-point@0.2.0) (2019-04-15)
100
+ # [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-closest-point@0.1.13...@thi.ng/geom-closest-point@0.2.0) (2019-04-15)
136
101
 
137
- ### Features
102
+ ### Features
138
103
 
139
- * **geom-closest-point:** add fns for more shape types ([5ae2887](https://github.com/thi-ng/umbrella/commit/5ae2887))
104
+ - **geom-closest-point:** add fns for more shape types ([5ae2887](https://github.com/thi-ng/umbrella/commit/5ae2887))
140
105
 
141
- # 0.1.0 (2019-02-05)
106
+ # 0.1.0 (2019-02-05)
142
107
 
143
- ### Features
108
+ ### Features
144
109
 
145
- * **geom-closest-point:** add more fns, update pkg ([798de06](https://github.com/thi-ng/umbrella/commit/798de06))
146
- * **geom-closest-point:** extract from geom as new package ([4ff5005](https://github.com/thi-ng/umbrella/commit/4ff5005))
110
+ - **geom-closest-point:** add more fns, update pkg ([798de06](https://github.com/thi-ng/umbrella/commit/798de06))
111
+ - **geom-closest-point:** extract from geom as new package ([4ff5005](https://github.com/thi-ng/umbrella/commit/4ff5005))
package/README.md CHANGED
@@ -44,15 +44,24 @@ Current implementations partially based on
44
44
  yarn add @thi.ng/geom-closest-point
45
45
  ```
46
46
 
47
+ ES module import:
48
+
47
49
  ```html
48
- // ES module
49
- <script type="module" src="https://unpkg.com/@thi.ng/geom-closest-point?module" crossorigin></script>
50
+ <script type="module" src="https://cdn.skypack.dev/@thi.ng/geom-closest-point"></script>
51
+ ```
52
+
53
+ [Skypack documentation](https://docs.skypack.dev/)
54
+
55
+ For Node.js REPL:
56
+
57
+ ```text
58
+ # with flag only for < v16
59
+ node --experimental-repl-await
50
60
 
51
- // UMD
52
- <script src="https://unpkg.com/@thi.ng/geom-closest-point/lib/index.umd.js" crossorigin></script>
61
+ > const geomClosestPoint = await import("@thi.ng/geom-closest-point");
53
62
  ```
54
63
 
55
- Package sizes (gzipped, pre-treeshake): ESM: 1.01 KB / CJS: 1.10 KB / UMD: 1.14 KB
64
+ Package sizes (gzipped, pre-treeshake): ESM: 1.07 KB
56
65
 
57
66
  ## Dependencies
58
67
 
@@ -69,7 +78,7 @@ directory are using this package.
69
78
  A selection:
70
79
 
71
80
  | Screenshot | Description | Live demo | Source |
72
- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------ |
81
+ |:-------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------|:--------------------------------------------------------|:-------------------------------------------------------------------------------------|
73
82
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/ellipse-proximity.png" width="240"/> | Interactive visualization of closest points on ellipses | [Demo](https://demo.thi.ng/umbrella/ellipse-proximity/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/ellipse-proximity) |
74
83
 
75
84
  ## API
package/box.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReadonlyVec, Vec } from "@thi.ng/vectors";
1
+ import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
2
2
  export declare const closestPointRect: (p: ReadonlyVec, bmin: ReadonlyVec, bmax: ReadonlyVec, out?: Vec) => Vec;
3
3
  export declare const closestPointAABB: (p: ReadonlyVec, bmin: ReadonlyVec, bmax: ReadonlyVec, out?: Vec) => Vec;
4
4
  //# sourceMappingURL=box.d.ts.map
package/box.js CHANGED
@@ -1,5 +1,5 @@
1
- import { clamp } from "@thi.ng/math";
2
- import { setC2, setC3 } from "@thi.ng/vectors";
1
+ import { clamp } from "@thi.ng/math/interval";
2
+ import { setC2, setC3 } from "@thi.ng/vectors/setc";
3
3
  export const closestPointRect = (p, bmin, bmax, out = []) => {
4
4
  const [minID, minW] = closestBoxEdge(p, bmin, bmax, 4);
5
5
  return minID === 0
package/circle.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReadonlyVec, Vec } from "@thi.ng/vectors";
1
+ import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
2
2
  /**
3
3
  * Returns closest point to `p` on circle defined by origin `c` and radius `r`.
4
4
  *
package/circle.js CHANGED
@@ -1,4 +1,5 @@
1
- import { add, direction } from "@thi.ng/vectors";
1
+ import { add } from "@thi.ng/vectors/add";
2
+ import { direction } from "@thi.ng/vectors/direction";
2
3
  /**
3
4
  * Returns closest point to `p` on circle defined by origin `c` and radius `r`.
4
5
  *
package/ellipse.js CHANGED
@@ -1,4 +1,5 @@
1
- import { clamp01, SQRT2_2 } from "@thi.ng/math";
1
+ import { SQRT2_2 } from "@thi.ng/math/api";
2
+ import { clamp01 } from "@thi.ng/math/interval";
2
3
  /**
3
4
  * @remarks
4
5
  * Based on iterative solution by Luc Maisonobe:
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from "./box";
2
- export * from "./circle";
3
- export * from "./ellipse";
4
- export * from "./line";
5
- export * from "./plane";
6
- export * from "./points";
1
+ export * from "./box.js";
2
+ export * from "./circle.js";
3
+ export * from "./ellipse.js";
4
+ export * from "./line.js";
5
+ export * from "./plane.js";
6
+ export * from "./points.js";
7
7
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./box";
2
- export * from "./circle";
3
- export * from "./ellipse";
4
- export * from "./line";
5
- export * from "./plane";
6
- export * from "./points";
1
+ export * from "./box.js";
2
+ export * from "./circle.js";
3
+ export * from "./ellipse.js";
4
+ export * from "./line.js";
5
+ export * from "./plane.js";
6
+ export * from "./points.js";
package/line.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { FnU3 } from "@thi.ng/api";
2
- import { ReadonlyVec, Vec } from "@thi.ng/vectors";
2
+ import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
3
3
  /**
4
4
  * Computes the parametric distance `t` of point `p` projected onto line
5
5
  * `a` -> `b`, relative to `a`. I.e. the projection of `p` can then be
package/line.js CHANGED
@@ -1,4 +1,11 @@
1
- import { dist, distSq, dot, empty, magSq, mixN, set, sub, } from "@thi.ng/vectors";
1
+ import { dist } from "@thi.ng/vectors/dist";
2
+ import { distSq } from "@thi.ng/vectors/distsq";
3
+ import { dot } from "@thi.ng/vectors/dot";
4
+ import { empty } from "@thi.ng/vectors/empty";
5
+ import { magSq } from "@thi.ng/vectors/magsq";
6
+ import { mixN } from "@thi.ng/vectors/mixn";
7
+ import { set } from "@thi.ng/vectors/set";
8
+ import { sub } from "@thi.ng/vectors/sub";
2
9
  /**
3
10
  * Computes the parametric distance `t` of point `p` projected onto line
4
11
  * `a` -> `b`, relative to `a`. I.e. the projection of `p` can then be
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@thi.ng/geom-closest-point",
3
- "version": "1.0.4",
3
+ "version": "2.0.3",
4
4
  "description": "2D / 3D closest point / proximity helpers",
5
+ "type": "module",
5
6
  "module": "./index.js",
6
- "main": "./lib/index.js",
7
- "umd:main": "./lib/index.umd.js",
8
7
  "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
@@ -24,29 +24,23 @@
24
24
  "author": "Karsten Schmidt <k+npm@thi.ng>",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module",
28
- "build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all",
29
- "build:es6": "tsc --declaration",
30
- "build:test": "rimraf build && tsc -p test/tsconfig.json",
31
- "build:check": "tsc --isolatedModules --noEmit",
32
- "test": "mocha test",
33
- "cover": "nyc mocha test && nyc report --reporter=lcov",
34
- "clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
35
- "doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
36
- "doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
27
+ "build": "yarn clean && tsc --declaration",
28
+ "clean": "rimraf *.js *.d.ts *.map doc",
29
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
37
30
  "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
38
- "pub": "yarn build:release && yarn publish --access public"
31
+ "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
32
+ "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
33
+ "pub": "yarn build && yarn publish --access public",
34
+ "test": "testament test"
39
35
  },
40
36
  "dependencies": {
41
- "@thi.ng/api": "^7.1.9",
42
- "@thi.ng/math": "^4.0.5",
43
- "@thi.ng/vectors": "^6.1.2"
37
+ "@thi.ng/api": "^8.0.3",
38
+ "@thi.ng/math": "^5.0.3",
39
+ "@thi.ng/vectors": "^7.0.3"
40
+ },
41
+ "devDependencies": {
42
+ "@thi.ng/testament": "^0.1.3"
44
43
  },
45
- "files": [
46
- "*.js",
47
- "*.d.ts",
48
- "lib"
49
- ],
50
44
  "keywords": [
51
45
  "2d",
52
46
  "3d",
@@ -66,7 +60,36 @@
66
60
  "publishConfig": {
67
61
  "access": "public"
68
62
  },
69
- "sideEffects": false,
63
+ "engines": {
64
+ "node": ">=12.7"
65
+ },
66
+ "files": [
67
+ "*.js",
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
+ }
92
+ },
70
93
  "thi.ng": {
71
94
  "parent": "@thi.ng/geom",
72
95
  "related": [
@@ -75,5 +98,5 @@
75
98
  ],
76
99
  "year": 2018
77
100
  },
78
- "gitHead": "84a067278ef79ccd538eeb652046eb8e03f3e34e"
101
+ "gitHead": "1fb38cac74d6c009d96855c28784a267a81badf1"
79
102
  }
package/plane.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReadonlyVec, Vec } from "@thi.ng/vectors";
1
+ import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
2
2
  /**
3
3
  * Returns signed distance between point `p` and plane defined by normal `n` and
4
4
  * `w`. In 2D this also works for lines.
package/plane.js CHANGED
@@ -1,4 +1,6 @@
1
- import { dot, normalize, sub } from "@thi.ng/vectors";
1
+ import { dot } from "@thi.ng/vectors/dot";
2
+ import { normalize } from "@thi.ng/vectors/normalize";
3
+ import { sub } from "@thi.ng/vectors/sub";
2
4
  /**
3
5
  * Returns signed distance between point `p` and plane defined by normal `n` and
4
6
  * `w`. In 2D this also works for lines.
package/points.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { FnU2 } from "@thi.ng/api";
2
- import { ReadonlyVec, Vec } from "@thi.ng/vectors";
2
+ import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
3
3
  /**
4
4
  * Returns closest point to `p` in given point array, optionally using custom
5
5
  * distance function `dist` (default: {@link @thi.ng/vectors#distSq}).
package/points.js CHANGED
@@ -1,4 +1,5 @@
1
- import { distSq, set } from "@thi.ng/vectors";
1
+ import { distSq } from "@thi.ng/vectors/distsq";
2
+ import { set } from "@thi.ng/vectors/set";
2
3
  /**
3
4
  * Returns closest point to `p` in given point array, optionally using custom
4
5
  * distance function `dist` (default: {@link @thi.ng/vectors#distSq}).
package/lib/index.js DELETED
@@ -1,149 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var math = require('@thi.ng/math');
6
- var vectors = require('@thi.ng/vectors');
7
-
8
- const closestPointRect = (p, bmin, bmax, out = []) => {
9
- const [minID, minW] = closestBoxEdge(p, bmin, bmax, 4);
10
- return minID === 0
11
- ? vectors.setC2(out, minW, math.clamp(p[1], bmin[1], bmax[1]))
12
- : vectors.setC2(out, math.clamp(p[0], bmin[0], bmax[0]), minW);
13
- };
14
- const closestPointAABB = (p, bmin, bmax, out = []) => {
15
- const [minID, minW] = closestBoxEdge(p, bmin, bmax, 6);
16
- return minID === 0
17
- ? vectors.setC3(out, minW, math.clamp(p[1], bmin[1], bmax[1]), math.clamp(p[2], bmin[2], bmax[2]))
18
- : minID === 1
19
- ? vectors.setC3(out, math.clamp(p[0], bmin[0], bmax[0]), minW, math.clamp(p[2], bmin[2], bmax[2]))
20
- : vectors.setC3(out, math.clamp(p[0], bmin[0], bmax[0]), math.clamp(p[1], bmin[1], bmax[1]), minW);
21
- };
22
- const closestBoxEdge = (p, bmin, bmax, n) => {
23
- let minD = Infinity;
24
- let minID;
25
- let minW;
26
- for (let i = 0; i < n; i++) {
27
- const j = i >> 1;
28
- const w = (i & 1 ? bmax : bmin)[j];
29
- const d = Math.abs(p[j] - w);
30
- if (d < minD) {
31
- minD = d;
32
- minID = j;
33
- minW = w;
34
- }
35
- }
36
- return [minID, minW];
37
- };
38
-
39
- const closestPointCircle = (p, c, r, out = []) => vectors.add(out, c, vectors.direction(out, c, p, r));
40
- const closestPointSphere = closestPointCircle;
41
-
42
- const closestPointEllipse = ([px, py], [ex, ey], [rx, ry], n = 3) => {
43
- const apx = Math.abs(px - ex);
44
- const apy = Math.abs(py - ey);
45
- const ab = (rx * rx - ry * ry) / rx;
46
- const ba = (ry * ry - rx * rx) / ry;
47
- let tx = math.SQRT2_2;
48
- let ty = tx;
49
- for (; --n >= 0;) {
50
- const _ex = ab * tx * tx * tx;
51
- const _ey = ba * ty * ty * ty;
52
- const qx = apx - _ex;
53
- const qy = apy - _ey;
54
- const q = Math.hypot(rx * tx - _ex, ry * ty - _ey) / Math.hypot(qx, qy);
55
- tx = math.clamp01((qx * q + _ex) / rx);
56
- ty = math.clamp01((qy * q + _ey) / ry);
57
- const t = Math.hypot(tx, ty);
58
- tx /= t;
59
- ty /= t;
60
- }
61
- return [rx * (px < ex ? -tx : tx) + ex, ry * (py < ey ? -ty : ty) + ey];
62
- };
63
-
64
- const closestT = (p, a, b) => {
65
- const d = vectors.sub([], b, a);
66
- const l = vectors.magSq(d);
67
- return l > 1e-6 ? vectors.dot(vectors.sub([], p, a), d) / l : undefined;
68
- };
69
- const closestPointLine = (p, a, b) => vectors.mixN([], a, b, closestT(p, a, b) || 0);
70
- const distToLine = (p, a, b) => vectors.dist(p, closestPointLine(p, a, b) || a);
71
- const closestPointSegment = (p, a, b, out, insideOnly = false, eps = 0) => {
72
- const t = closestT(p, a, b);
73
- if (t !== undefined && (!insideOnly || (t >= eps && t <= 1 - eps))) {
74
- out = out || vectors.empty(p);
75
- return t <= 0 ? vectors.set(out, a) : t >= 1 ? vectors.set(out, b) : vectors.mixN(out, a, b, t);
76
- }
77
- };
78
- const distToSegment = (p, a, b) => vectors.dist(p, closestPointSegment(p, a, b) || a);
79
- const closestPointPolyline = (p, pts, closed = false, out = []) => {
80
- if (!pts.length)
81
- return;
82
- const tmp = [];
83
- const n = pts.length - 1;
84
- let minD = Infinity, i, j;
85
- if (closed) {
86
- i = n;
87
- j = 0;
88
- }
89
- else {
90
- i = 0;
91
- j = 1;
92
- }
93
- for (; j <= n; i = j, j++) {
94
- if (closestPointSegment(p, pts[i], pts[j], tmp)) {
95
- const d = vectors.distSq(p, tmp);
96
- if (d < minD) {
97
- minD = d;
98
- vectors.set(out, tmp);
99
- }
100
- }
101
- }
102
- return minD < Infinity ? out : undefined;
103
- };
104
- const farthestPointSegment = (a, b, points, from = 0, to = points.length) => {
105
- let maxD = -1;
106
- let maxIdx = -1;
107
- const tmp = vectors.empty(a);
108
- for (let i = from; i < to; i++) {
109
- const p = points[i];
110
- const d = vectors.distSq(p, closestPointSegment(p, a, b, tmp) || a);
111
- if (d > maxD) {
112
- maxD = d;
113
- maxIdx = i;
114
- }
115
- }
116
- return [maxIdx, Math.sqrt(maxD)];
117
- };
118
-
119
- const distToPlane = (p, n, w) => vectors.dot(n, p) - w;
120
- const closestPointPlane = (p, normal, w, out = []) => vectors.sub(out, p, vectors.normalize(out, normal, distToPlane(p, normal, w)));
121
-
122
- const closestPointArray = (p, pts, out = [], dist = vectors.distSq) => {
123
- let minD = Infinity;
124
- let closest;
125
- for (let i = pts.length; --i >= 0;) {
126
- const d = dist(pts[i], p);
127
- if (d < minD) {
128
- minD = d;
129
- closest = pts[i];
130
- }
131
- }
132
- return closest ? vectors.set(out, closest) : undefined;
133
- };
134
-
135
- exports.closestPointAABB = closestPointAABB;
136
- exports.closestPointArray = closestPointArray;
137
- exports.closestPointCircle = closestPointCircle;
138
- exports.closestPointEllipse = closestPointEllipse;
139
- exports.closestPointLine = closestPointLine;
140
- exports.closestPointPlane = closestPointPlane;
141
- exports.closestPointPolyline = closestPointPolyline;
142
- exports.closestPointRect = closestPointRect;
143
- exports.closestPointSegment = closestPointSegment;
144
- exports.closestPointSphere = closestPointSphere;
145
- exports.closestT = closestT;
146
- exports.distToLine = distToLine;
147
- exports.distToPlane = distToPlane;
148
- exports.distToSegment = distToSegment;
149
- exports.farthestPointSegment = farthestPointSegment;
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../box.js","../circle.js","../ellipse.js","../line.js","../plane.js","../points.js"],"sourcesContent":null,"names":["setC2","clamp","setC3","add","direction","SQRT2_2","clamp01","sub","magSq","dot","mixN","dist","empty","set","distSq","normalize"],"mappings":";;;;;;;AAEY,MAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,KAAK;AAC7D,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3D,IAAI,OAAO,KAAK,KAAK,CAAC;AACtB,UAAUA,aAAK,CAAC,GAAG,EAAE,IAAI,EAAEC,UAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,UAAUD,aAAK,CAAC,GAAG,EAAEC,UAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC1D,EAAE;AACU,MAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,KAAK;AAC7D,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3D,IAAI,OAAO,KAAK,KAAK,CAAC;A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,EAAE,GAAG,GAAG,EAAE,EAAE,IAAI,GAAGD,cAAM,KAAK;AACtE,IAAI,IAAI,IAAI,GAAG,QAAQ,CAAC;AACxB,IAAI,IAAI,OAAO,CAAC;AAChB,IAAI,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG;AACxC,QAAQ,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClC,QAAQ,IAAI,CAAC,GAAG,IAAI,EAAE;AACtB,YAAY,IAAI,GAAG,CAAC,CAAC;AACrB,YAAY,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7B,SAAS;AACT,KAAK;AACL,IAAI,OAAO,OAAO,GAAGD,WAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;AACnD;;;;;;;;;;;;;;;;;;"}
package/lib/index.umd.js DELETED
@@ -1 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@thi.ng/math"),require("@thi.ng/vectors")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/math","@thi.ng/vectors"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.geomClosestPoint={}),t.thi.ng.math,t.thi.ng.vectors)}(this,(function(t,e,o){"use strict";const s=(t,e,o,s)=>{let n,i,l=1/0;for(let c=0;c<s;c++){const s=c>>1,r=(1&c?o:e)[s],a=Math.abs(t[s]-r);a<l&&(l=a,n=s,i=r)}return[n,i]},n=(t,e,s,n=[])=>o.add(n,e,o.direction(n,e,t,s)),i=n,l=(t,e,s)=>{const n=o.sub([],s,e),i=o.magSq(n);return i>1e-6?o.dot(o.sub([],t,e),n)/i:void 0},c=(t,e,s)=>o.mixN([],e,s,l(t,e,s)||0),r=(t,e,s,n,i=!1,c=0)=>{const r=l(t,e,s);if(void 0!==r&&(!i||r>=c&&r<=1-c))return n=n||o.empty(t),r<=0?o.set(n,e):r>=1?o.set(n,s):o.mixN(n,e,s,r)},a=(t,e,s)=>o.dot(e,t)-s;t.closestPointAABB=(t,n,i,l=[])=>{const[c,r]=s(t,n,i,6);return 0===c?o.setC3(l,r,e.clamp(t[1],n[1],i[1]),e.clamp(t[2],n[2],i[2])):1===c?o.setC3(l,e.clamp(t[0],n[0],i[0]),r,e.clamp(t[2],n[2],i[2])):o.setC3(l,e.clamp(t[0],n[0],i[0]),e.clamp(t[1],n[1],i[1]),r)},t.closestPointArray=(t,e,s=[],n=o.distSq)=>{let i,l=1/0;for(let o=e.length;--o>=0;){const s=n(e[o],t);s<l&&(l=s,i=e[o])}return i?o.set(s,i):void 0},t.closestPointCircle=n,t.closestPointEllipse=([t,o],[s,n],[i,l],c=3)=>{const r=Math.abs(t-s),a=Math.abs(o-n),h=(i*i-l*l)/i,d=(l*l-i*i)/l;let m=e.SQRT2_2,p=m;for(;--c>=0;){const t=h*m*m*m,o=d*p*p*p,s=r-t,n=a-o,c=Math.hypot(i*m-t,l*p-o)/Math.hypot(s,n);m=e.clamp01((s*c+t)/i),p=e.clamp01((n*c+o)/l);const u=Math.hypot(m,p);m/=u,p/=u}return[i*(t<s?-m:m)+s,l*(o<n?-p:p)+n]},t.closestPointLine=c,t.closestPointPlane=(t,e,s,n=[])=>o.sub(n,t,o.normalize(n,e,a(t,e,s))),t.closestPointPolyline=(t,e,s=!1,n=[])=>{if(!e.length)return;const i=[],l=e.length-1;let c,a,h=1/0;for(s?(c=l,a=0):(c=0,a=1);a<=l;c=a,a++)if(r(t,e[c],e[a],i)){const e=o.distSq(t,i);e<h&&(h=e,o.set(n,i))}return h<1/0?n:void 0},t.closestPointRect=(t,n,i,l=[])=>{const[c,r]=s(t,n,i,4);return 0===c?o.setC2(l,r,e.clamp(t[1],n[1],i[1])):o.setC2(l,e.clamp(t[0],n[0],i[0]),r)},t.closestPointSegment=r,t.closestPointSphere=i,t.closestT=l,t.distToLine=(t,e,s)=>o.dist(t,c(t,e,s)||e),t.distToPlane=a,t.distToSegment=(t,e,s)=>o.dist(t,r(t,e,s)||e),t.farthestPointSegment=(t,e,s,n=0,i=s.length)=>{let l=-1,c=-1;const a=o.empty(t);for(let h=n;h<i;h++){const n=s[h],i=o.distSq(n,r(n,t,e,a)||t);i>l&&(l=i,c=h)}return[c,Math.sqrt(l)]},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../box.js","../circle.js","../ellipse.js","../line.js","../plane.js","../points.js"],"sourcesContent":null,"names":["setC2","clamp","setC3","add","direction","SQRT2_2","clamp01","sub","magSq","dot","mixN","dist","empty","set","distSq","normalize"],"mappings":";;;;;;AAEY,UAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,KAAK;IAC7D,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,OAAO,KAAK,KAAK,CAAC;IACtB,UAAUA,aAAK,CAAC,GAAG,EAAE,IAAI,EAAEC,UAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,UAAUD,aAAK,CAAC,GAAG,EAAEC,UAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1D,EAAE;AACU,UAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,KAAK;IAC7D,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,EA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