@thi.ng/math 5.9.1 → 5.10.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-02-10T08:59:56Z
3
+ - **Last updated**: 2024-02-16T20:01:44Z
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,12 @@ 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
+ ## [5.10.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.10.0) (2024-02-16)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add fromDMS()/toDMS() conversions ([1714067](https://github.com/thi-ng/umbrella/commit/1714067))
17
+
12
18
  ## [5.9.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.9.0) (2024-02-06)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -82,7 +82,7 @@ For Node.js REPL:
82
82
  const math = await import("@thi.ng/math");
83
83
  ```
84
84
 
85
- Package sizes (brotli'd, pre-treeshake): ESM: 4.63 KB
85
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.70 KB
86
86
 
87
87
  ## Dependencies
88
88
 
package/angle.d.ts CHANGED
@@ -101,4 +101,30 @@ export declare const fastCos: FnN;
101
101
  * @param theta - in radians
102
102
  */
103
103
  export declare const fastSin: FnN;
104
+ /**
105
+ * Converts angle from DMS to decimal.
106
+ *
107
+ * @remarks
108
+ * See {@link toDMS} for reverse op.
109
+ *
110
+ * Reference:
111
+ * https://en.wikipedia.org/wiki/Decimal_degrees
112
+ *
113
+ * @param deg
114
+ * @param min
115
+ * @param sec
116
+ */
117
+ export declare const fromDMS: (deg: number, min: number, sec: number) => number;
118
+ /**
119
+ * Converts decimal angle to DMS. Returns result as 3-tuple with the first item
120
+ * (degrees) having the same sign as the input.
121
+ *
122
+ * @remarks
123
+ * See {@link fromDMS} for reverse op.
124
+ *
125
+ * Reference: https://en.wikipedia.org/wiki/Decimal_degrees
126
+ *
127
+ * @param theta
128
+ */
129
+ export declare const toDMS: (theta: number) => number[];
104
130
  //# sourceMappingURL=angle.d.ts.map
package/angle.js CHANGED
@@ -41,6 +41,15 @@ const fastCos = (theta) => {
41
41
  }
42
42
  };
43
43
  const fastSin = (theta) => fastCos(HALF_PI - theta);
44
+ const fromDMS = (deg2, min, sec2) => deg2 + min / 60 + sec2 / 3600;
45
+ const toDMS = (theta) => {
46
+ const sign = Math.sign(theta);
47
+ theta = Math.abs(theta);
48
+ const deg2 = Math.trunc(theta);
49
+ theta = (theta - deg2) * 60;
50
+ const min = Math.trunc(theta);
51
+ return [deg2 * sign, min, (theta - min) * 60];
52
+ };
44
53
  export {
45
54
  absInnerAngle,
46
55
  absTheta,
@@ -52,10 +61,12 @@ export {
52
61
  deg,
53
62
  fastCos,
54
63
  fastSin,
64
+ fromDMS,
55
65
  loc,
56
66
  normCos,
57
67
  quadrant,
58
68
  rad,
59
69
  sec,
60
- sincos
70
+ sincos,
71
+ toDMS
61
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/math",
3
- "version": "5.9.1",
3
+ "version": "5.10.0",
4
4
  "description": "Assorted common math functions & utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -142,5 +142,5 @@
142
142
  "thi.ng": {
143
143
  "year": 2013
144
144
  },
145
- "gitHead": "e5e7d5c6ed2eadee7a91d59cbd0c86ce880ab1c5\n"
145
+ "gitHead": "25ee18f7db6d03f0b76787267ab071d16df94888\n"
146
146
  }