@thi.ng/geom 8.0.6 → 8.1.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**: 2024-07-22T13:15:57Z
3
+ - **Last updated**: 2024-08-10T15:03:07Z
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
+ ## [8.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@8.1.0) (2024-08-10)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add circle inversion functions ([bb3a322](https://github.com/thi-ng/umbrella/commit/bb3a322))
17
+ - add invertCircle(), invertCirclePoint()
18
+
12
19
  ### [8.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@8.0.1) (2024-06-29)
13
20
 
14
21
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -258,6 +258,8 @@ the following additional shape creation helpers are provided:
258
258
 
259
259
  - [circleFrom2Points()](https://docs.thi.ng/umbrella/geom/functions/circleFrom2Points.html)
260
260
  - [circleFrom3Points()](https://docs.thi.ng/umbrella/geom/functions/circleFrom3Points.html)
261
+ - [invertCircle()](https://docs.thi.ng/umbrella/geom/functions/invertCircle.html)
262
+ - [invertCirclePoint()](https://docs.thi.ng/umbrella/geom/functions/invertCirclePoint.html)
261
263
 
262
264
  #### Cubic
263
265
 
@@ -449,7 +451,7 @@ For Node.js REPL:
449
451
  const geom = await import("@thi.ng/geom");
450
452
  ```
451
453
 
452
- Package sizes (brotli'd, pre-treeshake): ESM: 17.32 KB
454
+ Package sizes (brotli'd, pre-treeshake): ESM: 17.47 KB
453
455
 
454
456
  ## Dependencies
455
457
 
package/circle.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Attribs } from "./api.js";
2
1
  import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
2
+ import type { Attribs } from "./api.js";
3
3
  import { Circle } from "./api/circle.js";
4
4
  export declare function circle(pos: Vec, r: number, attribs?: Attribs): Circle;
5
5
  export declare function circle(pos: Vec, attribs?: Attribs): Circle;
package/index.d.ts CHANGED
@@ -96,6 +96,7 @@ export * from "./fit-into-bounds.js";
96
96
  export * from "./flip.js";
97
97
  export * from "./from-tessellation.js";
98
98
  export * from "./intersects.js";
99
+ export * from "./invert-circle.js";
99
100
  export * from "./map-point.js";
100
101
  export * from "./offset.js";
101
102
  export * from "./point-at.js";
package/index.js CHANGED
@@ -96,6 +96,7 @@ export * from "./fit-into-bounds.js";
96
96
  export * from "./flip.js";
97
97
  export * from "./from-tessellation.js";
98
98
  export * from "./intersects.js";
99
+ export * from "./invert-circle.js";
99
100
  export * from "./map-point.js";
100
101
  export * from "./offset.js";
101
102
  export * from "./point-at.js";
@@ -0,0 +1,30 @@
1
+ import type { ReadonlyVec } from "@thi.ng/vectors";
2
+ import type { Circle } from "./api/circle.js";
3
+ /**
4
+ * Inverts circle `c` in regards to reference circle `ref`. Mutates `c` in place
5
+ * and returns it.
6
+ *
7
+ * @remarks
8
+ * Reference:
9
+ * https://en.wikipedia.org/wiki/Inversive_geometry#Inversion_in_a_circle
10
+ *
11
+ * @param c
12
+ * @param ref
13
+ */
14
+ export declare const invertCircle: (c: Circle, ref: Circle) => Circle;
15
+ /**
16
+ * Applies inversion of point `p` in regards to reference circle `ref`.
17
+ *
18
+ * @remarks
19
+ * From Wikipedia: "[...]for a point inside the circle, the nearer the point to
20
+ * the center, the further away its transformation. While for any point (inside
21
+ * or outside the circle), the nearer the point to the circle, the closer its
22
+ * transformation."
23
+ *
24
+ * https://en.wikipedia.org/wiki/Inversive_geometry#Inversion_in_a_circle
25
+ *
26
+ * @param p
27
+ * @param ref
28
+ */
29
+ export declare const invertCirclePoint: (p: ReadonlyVec, ref: Circle) => import("@thi.ng/vectors").Vec;
30
+ //# sourceMappingURL=invert-circle.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { maddN2 } from "@thi.ng/vectors/maddn";
2
+ import { magSq2 } from "@thi.ng/vectors/magsq";
3
+ import { sub2 } from "@thi.ng/vectors/sub";
4
+ const invertCircle = (c, ref) => {
5
+ const delta = sub2([], c.pos, ref.pos);
6
+ const len2 = magSq2(delta);
7
+ const l = Math.sqrt(len2) + 1e-6;
8
+ const ra2 = c.r * c.r;
9
+ const rb2 = ref.r * ref.r;
10
+ const s = l * rb2 / (len2 - ra2);
11
+ c.pos = maddN2(null, delta, s / l, ref.pos);
12
+ c.r = Math.abs(rb2 * c.r / (len2 - ra2));
13
+ return c;
14
+ };
15
+ const invertCirclePoint = (p, ref) => {
16
+ const d = sub2([], p, ref.pos);
17
+ return maddN2([], d, ref.r * ref.r / magSq2(d), ref.pos);
18
+ };
19
+ export {
20
+ invertCircle,
21
+ invertCirclePoint
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/geom",
3
- "version": "8.0.6",
3
+ "version": "8.1.0",
4
4
  "description": "Functional, polymorphic API for 2D geometry types & SVG generation",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,39 +37,39 @@
37
37
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
38
38
  },
39
39
  "dependencies": {
40
- "@thi.ng/adjacency": "^3.0.1",
41
- "@thi.ng/api": "^8.11.7",
42
- "@thi.ng/arrays": "^2.9.13",
43
- "@thi.ng/checks": "^3.6.9",
44
- "@thi.ng/defmulti": "^3.0.45",
45
- "@thi.ng/equiv": "^2.1.63",
46
- "@thi.ng/errors": "^2.5.13",
47
- "@thi.ng/geom-arc": "^2.1.139",
48
- "@thi.ng/geom-clip-line": "^2.3.96",
49
- "@thi.ng/geom-clip-poly": "^2.1.138",
50
- "@thi.ng/geom-closest-point": "^2.1.134",
51
- "@thi.ng/geom-hull": "^2.1.134",
52
- "@thi.ng/geom-isec": "^4.0.6",
53
- "@thi.ng/geom-poly-utils": "^3.0.6",
54
- "@thi.ng/geom-resample": "^3.0.6",
55
- "@thi.ng/geom-splines": "^2.3.6",
56
- "@thi.ng/geom-subdiv-curve": "^3.0.6",
57
- "@thi.ng/geom-tessellate": "^3.0.6",
58
- "@thi.ng/hiccup": "^5.2.7",
59
- "@thi.ng/hiccup-svg": "^5.3.6",
60
- "@thi.ng/math": "^5.11.5",
61
- "@thi.ng/matrices": "^2.4.6",
62
- "@thi.ng/object-utils": "^1.1.0",
63
- "@thi.ng/random": "^4.0.1",
64
- "@thi.ng/strings": "^3.8.1",
65
- "@thi.ng/transducers": "^9.0.12",
66
- "@thi.ng/vectors": "^7.11.6"
40
+ "@thi.ng/adjacency": "^3.0.2",
41
+ "@thi.ng/api": "^8.11.8",
42
+ "@thi.ng/arrays": "^2.9.14",
43
+ "@thi.ng/checks": "^3.6.10",
44
+ "@thi.ng/defmulti": "^3.0.46",
45
+ "@thi.ng/equiv": "^2.1.64",
46
+ "@thi.ng/errors": "^2.5.14",
47
+ "@thi.ng/geom-arc": "^2.1.140",
48
+ "@thi.ng/geom-clip-line": "^2.3.97",
49
+ "@thi.ng/geom-clip-poly": "^2.1.139",
50
+ "@thi.ng/geom-closest-point": "^2.1.135",
51
+ "@thi.ng/geom-hull": "^2.1.135",
52
+ "@thi.ng/geom-isec": "^4.0.7",
53
+ "@thi.ng/geom-poly-utils": "^3.0.7",
54
+ "@thi.ng/geom-resample": "^3.0.7",
55
+ "@thi.ng/geom-splines": "^2.3.7",
56
+ "@thi.ng/geom-subdiv-curve": "^3.0.7",
57
+ "@thi.ng/geom-tessellate": "^3.0.7",
58
+ "@thi.ng/hiccup": "^5.2.8",
59
+ "@thi.ng/hiccup-svg": "^5.3.7",
60
+ "@thi.ng/math": "^5.11.6",
61
+ "@thi.ng/matrices": "^2.4.7",
62
+ "@thi.ng/object-utils": "^1.1.1",
63
+ "@thi.ng/random": "^4.0.2",
64
+ "@thi.ng/strings": "^3.8.2",
65
+ "@thi.ng/transducers": "^9.0.13",
66
+ "@thi.ng/vectors": "^7.11.7"
67
67
  },
68
68
  "devDependencies": {
69
- "@microsoft/api-extractor": "^7.47.0",
69
+ "@microsoft/api-extractor": "^7.47.5",
70
70
  "esbuild": "^0.23.0",
71
- "typedoc": "^0.26.3",
72
- "typescript": "^5.5.3"
71
+ "typedoc": "^0.26.5",
72
+ "typescript": "^5.5.4"
73
73
  },
74
74
  "keywords": [
75
75
  "2d",
@@ -101,8 +101,8 @@
101
101
  "shape",
102
102
  "spline",
103
103
  "svg",
104
- "triangulation",
105
104
  "tessellation",
105
+ "triangulation",
106
106
  "typescript"
107
107
  ],
108
108
  "publishConfig": {
@@ -349,6 +349,9 @@
349
349
  "./intersects": {
350
350
  "default": "./intersects.js"
351
351
  },
352
+ "./invert-circle": {
353
+ "default": "./invert-circle.js"
354
+ },
352
355
  "./line": {
353
356
  "default": "./line.js"
354
357
  },
@@ -527,5 +530,5 @@
527
530
  ],
528
531
  "year": 2013
529
532
  },
530
- "gitHead": "bd22b0826134b79064169371665b4d6caa9b6066\n"
533
+ "gitHead": "ec78f98d015e4d214a0b840e72e497407807daf3\n"
531
534
  }