@thi.ng/distance 2.3.0 → 2.4.0

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
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-05-28T09:56:37Z
3
+ - **Last updated**: 2023-06-09T12:24:57Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [2.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/distance@2.4.0) (2023-06-09)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add INeighborhood.includesPosition() ([2018e41](https://github.com/thi-ng/umbrella/commit/2018e41))
17
+ - update all impls: Nearest/KNearest/Radial
18
+
12
19
  ## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/distance@2.3.0) (2023-05-28)
13
20
 
14
21
  #### 🚀 Features
package/api.d.ts CHANGED
@@ -51,6 +51,13 @@ export interface INeighborhood<P, T> extends IReset {
51
51
  * @param eucledian -
52
52
  */
53
53
  includesDistance(d: number, eucledian?: boolean): boolean;
54
+ /**
55
+ * Computes distance metric between `pos` and this neighborhood's target
56
+ * pos. Returns true if result is <= current radius.
57
+ *
58
+ * @param pos
59
+ */
60
+ includesPosition(pos: P): boolean;
54
61
  /**
55
62
  * Computes distance metric between `pos` and this neighborhood's target
56
63
  * pos. If result distance is <= current radius, adds `val` to neighborhood
package/knearest.d.ts CHANGED
@@ -62,6 +62,7 @@ export declare class KNearest<D, T> implements INeighborhood<D, T>, IDeref<Neigh
62
62
  */
63
63
  values(): T[];
64
64
  includesDistance(d: number, eucledian?: boolean): boolean;
65
+ includesPosition(pos: D): boolean;
65
66
  consider(pos: D, val: T): number;
66
67
  }
67
68
  /**
package/knearest.js CHANGED
@@ -85,6 +85,9 @@ export class KNearest {
85
85
  includesDistance(d, eucledian = true) {
86
86
  return (eucledian ? this.dist.to(d) : d) <= this._currR;
87
87
  }
88
+ includesPosition(pos) {
89
+ return this.dist.metric(this.target, pos) < this._currR;
90
+ }
88
91
  consider(pos, val) {
89
92
  const d = this.dist.metric(this.target, pos);
90
93
  if (d <= this._currR) {
package/nearest.d.ts CHANGED
@@ -23,6 +23,7 @@ export declare class Nearest<D, T> implements INeighborhood<D, T>, IDeref<Neighb
23
23
  */
24
24
  deref(): Neighbor<T> | undefined;
25
25
  includesDistance(d: number, eucledian?: boolean): boolean;
26
+ includesPosition(pos: D): boolean;
26
27
  consider(pos: D, val: T): number;
27
28
  }
28
29
  /**
package/nearest.js CHANGED
@@ -32,6 +32,9 @@ export class Nearest {
32
32
  includesDistance(d, eucledian = true) {
33
33
  return (eucledian ? this.dist.to(d) : d) <= this._currR;
34
34
  }
35
+ includesPosition(pos) {
36
+ return this.dist.metric(this.target, pos) < this._currR;
37
+ }
35
38
  consider(pos, val) {
36
39
  const d = this.dist.metric(this.target, pos);
37
40
  if (d <= this._currR) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/distance",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "N-dimensional distance metrics & K-nearest neighborhoods for point queries",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -112,5 +112,5 @@
112
112
  ],
113
113
  "year": 2021
114
114
  },
115
- "gitHead": "065e40c90123541fcb126b825a07f84975431fb6\n"
115
+ "gitHead": "31076ef846f8ddd076c7968aca8d6d5f5b9b9465\n"
116
116
  }
package/radial.d.ts CHANGED
@@ -51,6 +51,7 @@ export declare class Radial<D, T> implements INeighborhood<D, T>, IDeref<Neighbo
51
51
  */
52
52
  values(): T[];
53
53
  includesDistance(d: number, eucledian?: boolean): boolean;
54
+ includesPosition(pos: D): boolean;
54
55
  consider(pos: D, val: T): number;
55
56
  }
56
57
  /**
@@ -82,7 +83,7 @@ export declare const radial2: <T>(p: ReadonlyVec, r?: number, dist?: import("./s
82
83
  */
83
84
  export declare const radial3: <T>(p: ReadonlyVec, r?: number, dist?: import("./squared.js").Squared<ReadonlyVec>) => Radial<ReadonlyVec, T>;
84
85
  /**
85
- * Defines a {@link KNearest} instance for numeric positions and, by default,
86
+ * Defines a {@link Radial} instance for numeric positions and, by default,
86
87
  * using an infinite region radius and {@link DIST_SQ1} distance metric.
87
88
  *
88
89
  * @param p -
package/radial.js CHANGED
@@ -66,6 +66,9 @@ export class Radial {
66
66
  includesDistance(d, eucledian = true) {
67
67
  return (eucledian ? this.dist.to(d) : d) <= this._r;
68
68
  }
69
+ includesPosition(pos) {
70
+ return this.dist.metric(this.target, pos) < this._r;
71
+ }
69
72
  consider(pos, val) {
70
73
  const d = this.dist.metric(this.target, pos);
71
74
  if (d <= this._r) {
@@ -103,7 +106,7 @@ export const radial2 = (p, r, dist = DIST_SQ2) => new Radial(dist, p, r);
103
106
  */
104
107
  export const radial3 = (p, r, dist = DIST_SQ3) => new Radial(dist, p, r);
105
108
  /**
106
- * Defines a {@link KNearest} instance for numeric positions and, by default,
109
+ * Defines a {@link Radial} instance for numeric positions and, by default,
107
110
  * using an infinite region radius and {@link DIST_SQ1} distance metric.
108
111
  *
109
112
  * @param p -