@fluixi/utils 1.0.0-alpha.100
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/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/index.cjs +2858 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +2838 -0
- package/dist/lib/array/advanced.cjs +2227 -0
- package/dist/lib/array/advanced.d.ts +1116 -0
- package/dist/lib/array/advanced.d.ts.map +1 -0
- package/dist/lib/array/advanced.js +2429 -0
- package/dist/lib/array/advanced.mjs +2204 -0
- package/dist/lib/array/array.cjs +57 -0
- package/dist/lib/array/array.d.ts +6 -0
- package/dist/lib/array/array.d.ts.map +1 -0
- package/dist/lib/array/array.js +31 -0
- package/dist/lib/array/array.mjs +36 -0
- package/dist/lib/array/index.cjs +2344 -0
- package/dist/lib/array/index.d.ts +4 -0
- package/dist/lib/array/index.d.ts.map +1 -0
- package/dist/lib/array/index.js +3 -0
- package/dist/lib/array/index.mjs +2322 -0
- package/dist/lib/array/utils.cjs +103 -0
- package/dist/lib/array/utils.d.ts +100 -0
- package/dist/lib/array/utils.d.ts.map +1 -0
- package/dist/lib/array/utils.js +165 -0
- package/dist/lib/array/utils.mjs +82 -0
- package/dist/lib/color/color.cjs +2190 -0
- package/dist/lib/color/color.d.ts +366 -0
- package/dist/lib/color/color.d.ts.map +1 -0
- package/dist/lib/color/color.js +722 -0
- package/dist/lib/color/color.mjs +2167 -0
- package/dist/lib/color/constants.cjs +380 -0
- package/dist/lib/color/constants.d.ts +361 -0
- package/dist/lib/color/constants.d.ts.map +1 -0
- package/dist/lib/color/constants.js +358 -0
- package/dist/lib/color/constants.mjs +359 -0
- package/dist/lib/color/conversions.cjs +629 -0
- package/dist/lib/color/conversions.d.ts +166 -0
- package/dist/lib/color/conversions.d.ts.map +1 -0
- package/dist/lib/color/conversions.js +766 -0
- package/dist/lib/color/conversions.mjs +608 -0
- package/dist/lib/color/helpers.cjs +2534 -0
- package/dist/lib/color/helpers.d.ts +75 -0
- package/dist/lib/color/helpers.d.ts.map +1 -0
- package/dist/lib/color/helpers.js +419 -0
- package/dist/lib/color/helpers.mjs +2511 -0
- package/dist/lib/color/index.cjs +2641 -0
- package/dist/lib/color/index.d.ts +12 -0
- package/dist/lib/color/index.d.ts.map +1 -0
- package/dist/lib/color/index.js +15 -0
- package/dist/lib/color/index.mjs +2619 -0
- package/dist/lib/color/types.cjs +18 -0
- package/dist/lib/color/types.d.ts +179 -0
- package/dist/lib/color/types.d.ts.map +1 -0
- package/dist/lib/color/types.js +1 -0
- package/dist/lib/color/types.mjs +0 -0
- package/dist/lib/color/utils.cjs +962 -0
- package/dist/lib/color/utils.d.ts +199 -0
- package/dist/lib/color/utils.d.ts.map +1 -0
- package/dist/lib/color/utils.js +858 -0
- package/dist/lib/color/utils.mjs +939 -0
- package/dist/lib/compare/comparators.cjs +171 -0
- package/dist/lib/compare/comparators.d.ts +65 -0
- package/dist/lib/compare/comparators.d.ts.map +1 -0
- package/dist/lib/compare/comparators.js +210 -0
- package/dist/lib/compare/comparators.mjs +150 -0
- package/dist/lib/compare/index.cjs +172 -0
- package/dist/lib/compare/index.d.ts +2 -0
- package/dist/lib/compare/index.d.ts.map +1 -0
- package/dist/lib/compare/index.js +1 -0
- package/dist/lib/compare/index.mjs +152 -0
- package/dist/lib/cookie/codec.cjs +72 -0
- package/dist/lib/cookie/codec.d.ts +22 -0
- package/dist/lib/cookie/codec.d.ts.map +1 -0
- package/dist/lib/cookie/codec.js +67 -0
- package/dist/lib/cookie/codec.mjs +51 -0
- package/dist/lib/cookie/index.cjs +75 -0
- package/dist/lib/cookie/index.d.ts +2 -0
- package/dist/lib/cookie/index.d.ts.map +1 -0
- package/dist/lib/cookie/index.js +1 -0
- package/dist/lib/cookie/index.mjs +53 -0
- package/dist/lib/crypto/hash.cjs +83 -0
- package/dist/lib/crypto/hash.d.ts +6 -0
- package/dist/lib/crypto/hash.d.ts.map +1 -0
- package/dist/lib/crypto/hash.js +53 -0
- package/dist/lib/crypto/hash.mjs +62 -0
- package/dist/lib/crypto/index.cjs +85 -0
- package/dist/lib/crypto/index.d.ts +2 -0
- package/dist/lib/crypto/index.d.ts.map +1 -0
- package/dist/lib/crypto/index.js +1 -0
- package/dist/lib/crypto/index.mjs +62 -0
- package/dist/lib/dom/events.cjs +40 -0
- package/dist/lib/dom/events.d.ts +159 -0
- package/dist/lib/dom/events.d.ts.map +1 -0
- package/dist/lib/dom/events.js +50 -0
- package/dist/lib/dom/events.mjs +19 -0
- package/dist/lib/dom/index.cjs +78 -0
- package/dist/lib/dom/index.d.ts +3 -0
- package/dist/lib/dom/index.d.ts.map +1 -0
- package/dist/lib/dom/index.js +2 -0
- package/dist/lib/dom/index.mjs +56 -0
- package/dist/lib/dom/utils.cjs +57 -0
- package/dist/lib/dom/utils.d.ts +6 -0
- package/dist/lib/dom/utils.d.ts.map +1 -0
- package/dist/lib/dom/utils.js +37 -0
- package/dist/lib/dom/utils.mjs +36 -0
- package/dist/lib/functions/functions.cjs +366 -0
- package/dist/lib/functions/functions.d.ts +329 -0
- package/dist/lib/functions/functions.d.ts.map +1 -0
- package/dist/lib/functions/functions.js +585 -0
- package/dist/lib/functions/functions.mjs +345 -0
- package/dist/lib/functions/index.cjs +369 -0
- package/dist/lib/functions/index.d.ts +3 -0
- package/dist/lib/functions/index.d.ts.map +1 -0
- package/dist/lib/functions/index.js +1 -0
- package/dist/lib/functions/index.mjs +347 -0
- package/dist/lib/functions/types.cjs +18 -0
- package/dist/lib/functions/types.d.ts +2 -0
- package/dist/lib/functions/types.d.ts.map +1 -0
- package/dist/lib/functions/types.js +1 -0
- package/dist/lib/functions/types.mjs +0 -0
- package/dist/lib/helpers.cjs +78 -0
- package/dist/lib/helpers.d.ts +13 -0
- package/dist/lib/helpers.d.ts.map +1 -0
- package/dist/lib/helpers.js +66 -0
- package/dist/lib/helpers.mjs +59 -0
- package/dist/lib/index.cjs +2857 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +8 -0
- package/dist/lib/index.mjs +2836 -0
- package/dist/lib/maths/constants.cjs +70 -0
- package/dist/lib/maths/constants.d.ts +84 -0
- package/dist/lib/maths/constants.d.ts.map +1 -0
- package/dist/lib/maths/constants.js +79 -0
- package/dist/lib/maths/constants.mjs +50 -0
- package/dist/lib/maths/fn/advanced.cjs +231 -0
- package/dist/lib/maths/fn/advanced.d.ts +149 -0
- package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
- package/dist/lib/maths/fn/advanced.js +264 -0
- package/dist/lib/maths/fn/advanced.mjs +208 -0
- package/dist/lib/maths/fn/basic.cjs +212 -0
- package/dist/lib/maths/fn/basic.d.ts +182 -0
- package/dist/lib/maths/fn/basic.d.ts.map +1 -0
- package/dist/lib/maths/fn/basic.js +343 -0
- package/dist/lib/maths/fn/basic.mjs +191 -0
- package/dist/lib/maths/fn/complex.cjs +268 -0
- package/dist/lib/maths/fn/complex.d.ts +153 -0
- package/dist/lib/maths/fn/complex.d.ts.map +1 -0
- package/dist/lib/maths/fn/complex.js +383 -0
- package/dist/lib/maths/fn/complex.mjs +247 -0
- package/dist/lib/maths/fn/index.cjs +877 -0
- package/dist/lib/maths/fn/index.d.ts +10 -0
- package/dist/lib/maths/fn/index.d.ts.map +1 -0
- package/dist/lib/maths/fn/index.js +9 -0
- package/dist/lib/maths/fn/index.mjs +855 -0
- package/dist/lib/maths/fn/trigo.cjs +179 -0
- package/dist/lib/maths/fn/trigo.d.ts +147 -0
- package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
- package/dist/lib/maths/fn/trigo.js +227 -0
- package/dist/lib/maths/fn/trigo.mjs +156 -0
- package/dist/lib/maths/fn/vector.cjs +728 -0
- package/dist/lib/maths/fn/vector.d.ts +512 -0
- package/dist/lib/maths/fn/vector.d.ts.map +1 -0
- package/dist/lib/maths/fn/vector.js +1136 -0
- package/dist/lib/maths/fn/vector.mjs +707 -0
- package/dist/lib/maths/formatter.cjs +61 -0
- package/dist/lib/maths/formatter.d.ts +35 -0
- package/dist/lib/maths/formatter.d.ts.map +1 -0
- package/dist/lib/maths/formatter.js +56 -0
- package/dist/lib/maths/formatter.mjs +40 -0
- package/dist/lib/maths/guards.cjs +164 -0
- package/dist/lib/maths/guards.d.ts +166 -0
- package/dist/lib/maths/guards.d.ts.map +1 -0
- package/dist/lib/maths/guards.js +315 -0
- package/dist/lib/maths/guards.mjs +144 -0
- package/dist/lib/maths/index.cjs +1152 -0
- package/dist/lib/maths/index.d.ts +24 -0
- package/dist/lib/maths/index.d.ts.map +1 -0
- package/dist/lib/maths/index.js +29 -0
- package/dist/lib/maths/index.mjs +1130 -0
- package/dist/lib/maths/parser.cjs +75 -0
- package/dist/lib/maths/parser.d.ts +20 -0
- package/dist/lib/maths/parser.d.ts.map +1 -0
- package/dist/lib/maths/parser.js +78 -0
- package/dist/lib/maths/parser.mjs +54 -0
- package/dist/lib/maths/random.cjs +49 -0
- package/dist/lib/maths/random.d.ts +27 -0
- package/dist/lib/maths/random.d.ts.map +1 -0
- package/dist/lib/maths/random.js +49 -0
- package/dist/lib/maths/random.mjs +28 -0
- package/dist/lib/maths/types/advanced.cjs +18 -0
- package/dist/lib/maths/types/advanced.d.ts +357 -0
- package/dist/lib/maths/types/advanced.d.ts.map +1 -0
- package/dist/lib/maths/types/advanced.js +5 -0
- package/dist/lib/maths/types/advanced.mjs +0 -0
- package/dist/lib/maths/types/basic.cjs +18 -0
- package/dist/lib/maths/types/basic.d.ts +95 -0
- package/dist/lib/maths/types/basic.d.ts.map +1 -0
- package/dist/lib/maths/types/basic.js +5 -0
- package/dist/lib/maths/types/basic.mjs +0 -0
- package/dist/lib/maths/types/index.cjs +19 -0
- package/dist/lib/maths/types/index.d.ts +4 -0
- package/dist/lib/maths/types/index.d.ts.map +1 -0
- package/dist/lib/maths/types/index.js +3 -0
- package/dist/lib/maths/types/index.mjs +1 -0
- package/dist/lib/maths/types/negative.cjs +18 -0
- package/dist/lib/maths/types/negative.d.ts +51 -0
- package/dist/lib/maths/types/negative.d.ts.map +1 -0
- package/dist/lib/maths/types/negative.js +5 -0
- package/dist/lib/maths/types/negative.mjs +0 -0
- package/dist/lib/maths/types/operations.cjs +18 -0
- package/dist/lib/maths/types/operations.d.ts +188 -0
- package/dist/lib/maths/types/operations.d.ts.map +1 -0
- package/dist/lib/maths/types/operations.js +6 -0
- package/dist/lib/maths/types/operations.mjs +0 -0
- package/dist/lib/object/clone.cjs +88 -0
- package/dist/lib/object/clone.d.ts +46 -0
- package/dist/lib/object/clone.d.ts.map +1 -0
- package/dist/lib/object/clone.js +104 -0
- package/dist/lib/object/clone.mjs +65 -0
- package/dist/lib/object/diff.cjs +573 -0
- package/dist/lib/object/diff.d.ts +203 -0
- package/dist/lib/object/diff.d.ts.map +1 -0
- package/dist/lib/object/diff.js +805 -0
- package/dist/lib/object/diff.mjs +550 -0
- package/dist/lib/object/getter-setter.cjs +2351 -0
- package/dist/lib/object/getter-setter.d.ts +361 -0
- package/dist/lib/object/getter-setter.d.ts.map +1 -0
- package/dist/lib/object/getter-setter.js +1771 -0
- package/dist/lib/object/getter-setter.mjs +2330 -0
- package/dist/lib/object/index.cjs +3956 -0
- package/dist/lib/object/index.d.ts +13 -0
- package/dist/lib/object/index.d.ts.map +1 -0
- package/dist/lib/object/index.js +12 -0
- package/dist/lib/object/index.mjs +3936 -0
- package/dist/lib/object/merge.cjs +1029 -0
- package/dist/lib/object/merge.d.ts +93 -0
- package/dist/lib/object/merge.d.ts.map +1 -0
- package/dist/lib/object/merge.js +474 -0
- package/dist/lib/object/merge.mjs +1006 -0
- package/dist/lib/object/object.cjs +280 -0
- package/dist/lib/object/object.d.ts +128 -0
- package/dist/lib/object/object.d.ts.map +1 -0
- package/dist/lib/object/object.js +432 -0
- package/dist/lib/object/object.mjs +257 -0
- package/dist/lib/object/omit.cjs +2022 -0
- package/dist/lib/object/omit.d.ts +351 -0
- package/dist/lib/object/omit.d.ts.map +1 -0
- package/dist/lib/object/omit.js +656 -0
- package/dist/lib/object/omit.mjs +1999 -0
- package/dist/lib/object/reconcile.cjs +126 -0
- package/dist/lib/object/reconcile.d.ts +7 -0
- package/dist/lib/object/reconcile.d.ts.map +1 -0
- package/dist/lib/object/reconcile.js +122 -0
- package/dist/lib/object/reconcile.mjs +105 -0
- package/dist/lib/object/selector.cjs +303 -0
- package/dist/lib/object/selector.d.ts +50 -0
- package/dist/lib/object/selector.d.ts.map +1 -0
- package/dist/lib/object/selector.js +371 -0
- package/dist/lib/object/selector.mjs +282 -0
- package/dist/lib/object/sort.cjs +209 -0
- package/dist/lib/object/sort.d.ts +149 -0
- package/dist/lib/object/sort.d.ts.map +1 -0
- package/dist/lib/object/sort.js +298 -0
- package/dist/lib/object/sort.mjs +186 -0
- package/dist/lib/object/transform.cjs +2211 -0
- package/dist/lib/object/transform.d.ts +620 -0
- package/dist/lib/object/transform.d.ts.map +1 -0
- package/dist/lib/object/transform.js +1058 -0
- package/dist/lib/object/transform.mjs +2190 -0
- package/dist/lib/object/types.cjs +18 -0
- package/dist/lib/object/types.d.ts +250 -0
- package/dist/lib/object/types.d.ts.map +1 -0
- package/dist/lib/object/types.js +1 -0
- package/dist/lib/object/types.mjs +0 -0
- package/dist/lib/object/utils.cjs +326 -0
- package/dist/lib/object/utils.d.ts +165 -0
- package/dist/lib/object/utils.d.ts.map +1 -0
- package/dist/lib/object/utils.js +444 -0
- package/dist/lib/object/utils.mjs +305 -0
- package/dist/lib/primitive/boolean/boolean.cjs +407 -0
- package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
- package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/boolean.js +615 -0
- package/dist/lib/primitive/boolean/boolean.mjs +386 -0
- package/dist/lib/primitive/boolean/index.cjs +382 -0
- package/dist/lib/primitive/boolean/index.d.ts +3 -0
- package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/index.js +2 -0
- package/dist/lib/primitive/boolean/index.mjs +359 -0
- package/dist/lib/primitive/boolean/types.cjs +18 -0
- package/dist/lib/primitive/boolean/types.d.ts +14 -0
- package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/types.js +1 -0
- package/dist/lib/primitive/boolean/types.mjs +0 -0
- package/dist/lib/primitive/date/date.cjs +1126 -0
- package/dist/lib/primitive/date/date.d.ts +641 -0
- package/dist/lib/primitive/date/date.d.ts.map +1 -0
- package/dist/lib/primitive/date/date.js +1998 -0
- package/dist/lib/primitive/date/date.mjs +1105 -0
- package/dist/lib/primitive/date/index.cjs +1128 -0
- package/dist/lib/primitive/date/index.d.ts +3 -0
- package/dist/lib/primitive/date/index.d.ts.map +1 -0
- package/dist/lib/primitive/date/index.js +2 -0
- package/dist/lib/primitive/date/index.mjs +1105 -0
- package/dist/lib/primitive/date/types.cjs +18 -0
- package/dist/lib/primitive/date/types.d.ts +205 -0
- package/dist/lib/primitive/date/types.d.ts.map +1 -0
- package/dist/lib/primitive/date/types.js +7 -0
- package/dist/lib/primitive/date/types.mjs +0 -0
- package/dist/lib/primitive/index.cjs +2338 -0
- package/dist/lib/primitive/index.d.ts +5 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/index.js +4 -0
- package/dist/lib/primitive/index.mjs +2316 -0
- package/dist/lib/primitive/string/index.cjs +875 -0
- package/dist/lib/primitive/string/index.d.ts +3 -0
- package/dist/lib/primitive/string/index.d.ts.map +1 -0
- package/dist/lib/primitive/string/index.js +2 -0
- package/dist/lib/primitive/string/index.mjs +852 -0
- package/dist/lib/primitive/string/parser-2.cjs +543 -0
- package/dist/lib/primitive/string/parser-2.d.ts +17 -0
- package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser-2.js +656 -0
- package/dist/lib/primitive/string/parser-2.mjs +522 -0
- package/dist/lib/primitive/string/parser.cjs +236 -0
- package/dist/lib/primitive/string/parser.d.ts +9 -0
- package/dist/lib/primitive/string/parser.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser.js +775 -0
- package/dist/lib/primitive/string/parser.mjs +215 -0
- package/dist/lib/primitive/string/string.cjs +926 -0
- package/dist/lib/primitive/string/string.d.ts +535 -0
- package/dist/lib/primitive/string/string.d.ts.map +1 -0
- package/dist/lib/primitive/string/string.js +1301 -0
- package/dist/lib/primitive/string/string.mjs +903 -0
- package/dist/lib/primitive/string/types.cjs +18 -0
- package/dist/lib/primitive/string/types.d.ts +318 -0
- package/dist/lib/primitive/string/types.d.ts.map +1 -0
- package/dist/lib/primitive/string/types.js +5 -0
- package/dist/lib/primitive/string/types.mjs +0 -0
- package/dist/lib/primitive/types.cjs +18 -0
- package/dist/lib/primitive/types.d.ts +27 -0
- package/dist/lib/primitive/types.d.ts.map +1 -0
- package/dist/lib/primitive/types.js +1 -0
- package/dist/lib/primitive/types.mjs +0 -0
- package/dist/lib/url/index.cjs +327 -0
- package/dist/lib/url/index.d.ts +3 -0
- package/dist/lib/url/index.d.ts.map +1 -0
- package/dist/lib/url/index.js +2 -0
- package/dist/lib/url/index.mjs +304 -0
- package/dist/lib/url/parser.cjs +325 -0
- package/dist/lib/url/parser.d.ts +216 -0
- package/dist/lib/url/parser.d.ts.map +1 -0
- package/dist/lib/url/parser.js +488 -0
- package/dist/lib/url/parser.mjs +304 -0
- package/dist/lib/url/types.cjs +18 -0
- package/dist/lib/url/types.d.ts +18 -0
- package/dist/lib/url/types.d.ts.map +1 -0
- package/dist/lib/url/types.js +1 -0
- package/dist/lib/url/types.mjs +0 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +127 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/maths/fn/trigo.ts
|
|
21
|
+
var trigo_exports = {};
|
|
22
|
+
__export(trigo_exports, {
|
|
23
|
+
acos: () => acos,
|
|
24
|
+
acosh: () => acosh,
|
|
25
|
+
asin: () => asin,
|
|
26
|
+
asinh: () => asinh,
|
|
27
|
+
atan: () => atan,
|
|
28
|
+
atan2: () => atan2,
|
|
29
|
+
atanh: () => atanh,
|
|
30
|
+
cos: () => cos,
|
|
31
|
+
cosh: () => cosh,
|
|
32
|
+
cot: () => cot,
|
|
33
|
+
csc: () => csc,
|
|
34
|
+
degToGrad: () => degToGrad,
|
|
35
|
+
degToRad: () => degToRad,
|
|
36
|
+
gradToDeg: () => gradToDeg,
|
|
37
|
+
normalizeDegrees: () => normalizeDegrees,
|
|
38
|
+
normalizeRadians: () => normalizeRadians,
|
|
39
|
+
radToDeg: () => radToDeg,
|
|
40
|
+
sec: () => sec,
|
|
41
|
+
sin: () => sin,
|
|
42
|
+
sinh: () => sinh,
|
|
43
|
+
tan: () => tan,
|
|
44
|
+
tanh: () => tanh
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(trigo_exports);
|
|
47
|
+
|
|
48
|
+
// src/lib/maths/constants.ts
|
|
49
|
+
var PI = 3.141592653589793;
|
|
50
|
+
var E = 2.718281828459045;
|
|
51
|
+
var PHI = 1.618033988749894;
|
|
52
|
+
var SQRT2 = 1.4142135623730951;
|
|
53
|
+
var SQRT1_2 = 0.7071067811865476;
|
|
54
|
+
var LN2 = 0.6931471805599453;
|
|
55
|
+
var LN10 = 2.302585092994046;
|
|
56
|
+
var LOG2E = 1.4426950408889634;
|
|
57
|
+
var LOG10E = 0.4342944819032518;
|
|
58
|
+
var DEGREES_IN_CIRCLE = 360;
|
|
59
|
+
var RADIANS_IN_CIRCLE = 2 * PI;
|
|
60
|
+
var GRADIANS_IN_CIRCLE = 400;
|
|
61
|
+
var DEGREES_PER_RADIAN = 180 / PI;
|
|
62
|
+
var RADIANS_PER_DEGREE = PI / 180;
|
|
63
|
+
var Constants = {
|
|
64
|
+
PI,
|
|
65
|
+
E,
|
|
66
|
+
PHI,
|
|
67
|
+
SQRT2,
|
|
68
|
+
SQRT1_2,
|
|
69
|
+
LN2,
|
|
70
|
+
LN10,
|
|
71
|
+
LOG2E,
|
|
72
|
+
LOG10E,
|
|
73
|
+
DEGREES_IN_CIRCLE,
|
|
74
|
+
RADIANS_IN_CIRCLE,
|
|
75
|
+
GRADIANS_IN_CIRCLE,
|
|
76
|
+
DEGREES_PER_RADIAN,
|
|
77
|
+
RADIANS_PER_DEGREE
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/lib/maths/fn/trigo.ts
|
|
81
|
+
function degToRad(degrees) {
|
|
82
|
+
return degrees * Constants.RADIANS_PER_DEGREE;
|
|
83
|
+
}
|
|
84
|
+
function radToDeg(radians) {
|
|
85
|
+
return radians * Constants.DEGREES_PER_RADIAN;
|
|
86
|
+
}
|
|
87
|
+
function degToGrad(degrees) {
|
|
88
|
+
return degrees * (Constants.GRADIANS_IN_CIRCLE / Constants.DEGREES_IN_CIRCLE);
|
|
89
|
+
}
|
|
90
|
+
function gradToDeg(gradians) {
|
|
91
|
+
return gradians * (Constants.DEGREES_IN_CIRCLE / Constants.GRADIANS_IN_CIRCLE);
|
|
92
|
+
}
|
|
93
|
+
function normalizeRadians(radians) {
|
|
94
|
+
const twoPi = Constants.RADIANS_IN_CIRCLE;
|
|
95
|
+
let normalized = radians % twoPi;
|
|
96
|
+
if (normalized < 0) normalized += twoPi;
|
|
97
|
+
return normalized;
|
|
98
|
+
}
|
|
99
|
+
function normalizeDegrees(degrees) {
|
|
100
|
+
let normalized = degrees % Constants.DEGREES_IN_CIRCLE;
|
|
101
|
+
if (normalized < 0) normalized += Constants.DEGREES_IN_CIRCLE;
|
|
102
|
+
return normalized;
|
|
103
|
+
}
|
|
104
|
+
function sin(radians) {
|
|
105
|
+
return Math.sin(radians);
|
|
106
|
+
}
|
|
107
|
+
function cos(radians) {
|
|
108
|
+
return Math.cos(radians);
|
|
109
|
+
}
|
|
110
|
+
function tan(radians) {
|
|
111
|
+
const cosine = Math.cos(radians);
|
|
112
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
113
|
+
throw new Error("Tangent undefined for this angle (cosine is zero)");
|
|
114
|
+
}
|
|
115
|
+
return Math.tan(radians);
|
|
116
|
+
}
|
|
117
|
+
function asin(value) {
|
|
118
|
+
if (value < -1 || value > 1) {
|
|
119
|
+
throw new Error("Arcsine is only defined for values between -1 and 1");
|
|
120
|
+
}
|
|
121
|
+
return Math.asin(value);
|
|
122
|
+
}
|
|
123
|
+
function acos(value) {
|
|
124
|
+
if (value < -1 || value > 1) {
|
|
125
|
+
throw new Error("Arccosine is only defined for values between -1 and 1");
|
|
126
|
+
}
|
|
127
|
+
return Math.acos(value);
|
|
128
|
+
}
|
|
129
|
+
function atan(value) {
|
|
130
|
+
return Math.atan(value);
|
|
131
|
+
}
|
|
132
|
+
function atan2(y, x) {
|
|
133
|
+
return Math.atan2(y, x);
|
|
134
|
+
}
|
|
135
|
+
function sinh(x) {
|
|
136
|
+
return Math.sinh(x);
|
|
137
|
+
}
|
|
138
|
+
function cosh(x) {
|
|
139
|
+
return Math.cosh(x);
|
|
140
|
+
}
|
|
141
|
+
function tanh(x) {
|
|
142
|
+
return Math.tanh(x);
|
|
143
|
+
}
|
|
144
|
+
function asinh(x) {
|
|
145
|
+
return Math.asinh(x);
|
|
146
|
+
}
|
|
147
|
+
function acosh(x) {
|
|
148
|
+
if (x < 1) {
|
|
149
|
+
throw new Error("Inverse hyperbolic cosine is only defined for x >= 1");
|
|
150
|
+
}
|
|
151
|
+
return Math.acosh(x);
|
|
152
|
+
}
|
|
153
|
+
function atanh(x) {
|
|
154
|
+
if (Math.abs(x) >= 1) {
|
|
155
|
+
throw new Error("Inverse hyperbolic tangent is only defined for |x| < 1");
|
|
156
|
+
}
|
|
157
|
+
return Math.atanh(x);
|
|
158
|
+
}
|
|
159
|
+
function sec(radians) {
|
|
160
|
+
const cosine = Math.cos(radians);
|
|
161
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
162
|
+
throw new Error("Secant undefined for this angle (cosine is zero)");
|
|
163
|
+
}
|
|
164
|
+
return 1 / cosine;
|
|
165
|
+
}
|
|
166
|
+
function csc(radians) {
|
|
167
|
+
const sine = Math.sin(radians);
|
|
168
|
+
if (Math.abs(sine) < 1e-10) {
|
|
169
|
+
throw new Error("Cosecant undefined for this angle (sine is zero)");
|
|
170
|
+
}
|
|
171
|
+
return 1 / sine;
|
|
172
|
+
}
|
|
173
|
+
function cot(radians) {
|
|
174
|
+
const tangent = Math.tan(radians);
|
|
175
|
+
if (Math.abs(tangent) < 1e-10) {
|
|
176
|
+
throw new Error("Cotangent undefined for this angle (tangent is zero)");
|
|
177
|
+
}
|
|
178
|
+
return 1 / tangent;
|
|
179
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trigonometric functions and angle conversions.
|
|
3
|
+
* @module TrigonometryFunctions
|
|
4
|
+
*/
|
|
5
|
+
import type { Degrees, Radians } from '../types/basic.js';
|
|
6
|
+
/**
|
|
7
|
+
* Converts degrees to radians.
|
|
8
|
+
* @param degrees - Angle in degrees
|
|
9
|
+
* @returns Angle in radians
|
|
10
|
+
*/
|
|
11
|
+
export declare function degToRad(degrees: number): Radians;
|
|
12
|
+
/**
|
|
13
|
+
* Converts radians to degrees.
|
|
14
|
+
* @param radians - Angle in radians
|
|
15
|
+
* @returns Angle in degrees
|
|
16
|
+
*/
|
|
17
|
+
export declare function radToDeg(radians: number): Degrees;
|
|
18
|
+
/**
|
|
19
|
+
* Converts degrees to gradians.
|
|
20
|
+
* @param degrees - Angle in degrees
|
|
21
|
+
* @returns Angle in gradians
|
|
22
|
+
*/
|
|
23
|
+
export declare function degToGrad(degrees: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Converts gradians to degrees.
|
|
26
|
+
* @param gradians - Angle in gradians
|
|
27
|
+
* @returns Angle in degrees
|
|
28
|
+
*/
|
|
29
|
+
export declare function gradToDeg(gradians: number): Degrees;
|
|
30
|
+
/**
|
|
31
|
+
* Normalizes an angle to the range [0, 2π) radians.
|
|
32
|
+
* @param radians - Angle in radians
|
|
33
|
+
* @returns Normalized angle in radians
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeRadians(radians: number): Radians;
|
|
36
|
+
/**
|
|
37
|
+
* Normalizes an angle to the range [0, 360) degrees.
|
|
38
|
+
* @param degrees - Angle in degrees
|
|
39
|
+
* @returns Normalized angle in degrees
|
|
40
|
+
*/
|
|
41
|
+
export declare function normalizeDegrees(degrees: number): Degrees;
|
|
42
|
+
/**
|
|
43
|
+
* Calculates the sine of an angle in radians.
|
|
44
|
+
* @param radians - Angle in radians
|
|
45
|
+
* @returns The sine value
|
|
46
|
+
*/
|
|
47
|
+
export declare function sin(radians: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Calculates the cosine of an angle in radians.
|
|
50
|
+
* @param radians - Angle in radians
|
|
51
|
+
* @returns The cosine value
|
|
52
|
+
*/
|
|
53
|
+
export declare function cos(radians: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* Calculates the tangent of an angle in radians.
|
|
56
|
+
* @param radians - Angle in radians
|
|
57
|
+
* @returns The tangent value
|
|
58
|
+
* @throws {Error} If cosine is zero (angle is π/2 + nπ)
|
|
59
|
+
*/
|
|
60
|
+
export declare function tan(radians: number): number;
|
|
61
|
+
/**
|
|
62
|
+
* Calculates the arcsine (inverse sine) in radians.
|
|
63
|
+
* @param value - Sine value between -1 and 1
|
|
64
|
+
* @returns Angle in radians
|
|
65
|
+
* @throws {Error} If value is outside [-1, 1]
|
|
66
|
+
*/
|
|
67
|
+
export declare function asin(value: number): Radians;
|
|
68
|
+
/**
|
|
69
|
+
* Calculates the arccosine (inverse cosine) in radians.
|
|
70
|
+
* @param value - Cosine value between -1 and 1
|
|
71
|
+
* @returns Angle in radians
|
|
72
|
+
* @throws {Error} If value is outside [-1, 1]
|
|
73
|
+
*/
|
|
74
|
+
export declare function acos(value: number): Radians;
|
|
75
|
+
/**
|
|
76
|
+
* Calculates the arctangent (inverse tangent) in radians.
|
|
77
|
+
* @param value - Tangent value
|
|
78
|
+
* @returns Angle in radians between -π/2 and π/2
|
|
79
|
+
*/
|
|
80
|
+
export declare function atan(value: number): Radians;
|
|
81
|
+
/**
|
|
82
|
+
* Calculates the arctangent of y/x in radians, handling all quadrants.
|
|
83
|
+
* @param y - Numerator
|
|
84
|
+
* @param x - Denominator
|
|
85
|
+
* @returns Angle in radians between -π and π
|
|
86
|
+
*/
|
|
87
|
+
export declare function atan2(y: number, x: number): Radians;
|
|
88
|
+
/**
|
|
89
|
+
* Calculates the hyperbolic sine.
|
|
90
|
+
* @param x - Input value
|
|
91
|
+
* @returns Hyperbolic sine
|
|
92
|
+
*/
|
|
93
|
+
export declare function sinh(x: number): number;
|
|
94
|
+
/**
|
|
95
|
+
* Calculates the hyperbolic cosine.
|
|
96
|
+
* @param x - Input value
|
|
97
|
+
* @returns Hyperbolic cosine
|
|
98
|
+
*/
|
|
99
|
+
export declare function cosh(x: number): number;
|
|
100
|
+
/**
|
|
101
|
+
* Calculates the hyperbolic tangent.
|
|
102
|
+
* @param x - Input value
|
|
103
|
+
* @returns Hyperbolic tangent
|
|
104
|
+
*/
|
|
105
|
+
export declare function tanh(x: number): number;
|
|
106
|
+
/**
|
|
107
|
+
* Calculates the inverse hyperbolic sine.
|
|
108
|
+
* @param x - Input value
|
|
109
|
+
* @returns Inverse hyperbolic sine
|
|
110
|
+
*/
|
|
111
|
+
export declare function asinh(x: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Calculates the inverse hyperbolic cosine.
|
|
114
|
+
* @param x - Input value >= 1
|
|
115
|
+
* @returns Inverse hyperbolic cosine
|
|
116
|
+
* @throws {Error} If x < 1
|
|
117
|
+
*/
|
|
118
|
+
export declare function acosh(x: number): number;
|
|
119
|
+
/**
|
|
120
|
+
* Calculates the inverse hyperbolic tangent.
|
|
121
|
+
* @param x - Input value between -1 and 1 (exclusive)
|
|
122
|
+
* @returns Inverse hyperbolic tangent
|
|
123
|
+
* @throws {Error} If |x| >= 1
|
|
124
|
+
*/
|
|
125
|
+
export declare function atanh(x: number): number;
|
|
126
|
+
/**
|
|
127
|
+
* Calculates the secant of an angle.
|
|
128
|
+
* @param radians - Angle in radians
|
|
129
|
+
* @returns The secant value
|
|
130
|
+
* @throws {Error} If cosine is zero
|
|
131
|
+
*/
|
|
132
|
+
export declare function sec(radians: number): number;
|
|
133
|
+
/**
|
|
134
|
+
* Calculates the cosecant of an angle.
|
|
135
|
+
* @param radians - Angle in radians
|
|
136
|
+
* @returns The cosecant value
|
|
137
|
+
* @throws {Error} If sine is zero
|
|
138
|
+
*/
|
|
139
|
+
export declare function csc(radians: number): number;
|
|
140
|
+
/**
|
|
141
|
+
* Calculates the cotangent of an angle.
|
|
142
|
+
* @param radians - Angle in radians
|
|
143
|
+
* @returns The cotangent value
|
|
144
|
+
* @throws {Error} If tangent is zero
|
|
145
|
+
*/
|
|
146
|
+
export declare function cot(radians: number): number;
|
|
147
|
+
//# sourceMappingURL=trigo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigo.d.ts","sourceRoot":"","sources":["../../../../src/lib/maths/fn/trigo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKzD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAIzD;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3C;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAK3C;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAK3C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvC;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3C;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3C;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3C"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trigonometric functions and angle conversions.
|
|
3
|
+
* @module TrigonometryFunctions
|
|
4
|
+
*/
|
|
5
|
+
import { Constants } from '../constants.js';
|
|
6
|
+
/**
|
|
7
|
+
* Converts degrees to radians.
|
|
8
|
+
* @param degrees - Angle in degrees
|
|
9
|
+
* @returns Angle in radians
|
|
10
|
+
*/
|
|
11
|
+
export function degToRad(degrees) {
|
|
12
|
+
// return degrees * (Math.PI / 180);
|
|
13
|
+
return (degrees * Constants.RADIANS_PER_DEGREE);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Converts radians to degrees.
|
|
17
|
+
* @param radians - Angle in radians
|
|
18
|
+
* @returns Angle in degrees
|
|
19
|
+
*/
|
|
20
|
+
export function radToDeg(radians) {
|
|
21
|
+
// return radians * (180 / Math.PI);
|
|
22
|
+
return (radians * Constants.DEGREES_PER_RADIAN);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts degrees to gradians.
|
|
26
|
+
* @param degrees - Angle in degrees
|
|
27
|
+
* @returns Angle in gradians
|
|
28
|
+
*/
|
|
29
|
+
export function degToGrad(degrees) {
|
|
30
|
+
return degrees * (Constants.GRADIANS_IN_CIRCLE / Constants.DEGREES_IN_CIRCLE);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts gradians to degrees.
|
|
34
|
+
* @param gradians - Angle in gradians
|
|
35
|
+
* @returns Angle in degrees
|
|
36
|
+
*/
|
|
37
|
+
export function gradToDeg(gradians) {
|
|
38
|
+
return (gradians * (Constants.DEGREES_IN_CIRCLE / Constants.GRADIANS_IN_CIRCLE));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Normalizes an angle to the range [0, 2π) radians.
|
|
42
|
+
* @param radians - Angle in radians
|
|
43
|
+
* @returns Normalized angle in radians
|
|
44
|
+
*/
|
|
45
|
+
export function normalizeRadians(radians) {
|
|
46
|
+
const twoPi = Constants.RADIANS_IN_CIRCLE;
|
|
47
|
+
let normalized = radians % twoPi;
|
|
48
|
+
if (normalized < 0)
|
|
49
|
+
normalized += twoPi;
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Normalizes an angle to the range [0, 360) degrees.
|
|
54
|
+
* @param degrees - Angle in degrees
|
|
55
|
+
* @returns Normalized angle in degrees
|
|
56
|
+
*/
|
|
57
|
+
export function normalizeDegrees(degrees) {
|
|
58
|
+
let normalized = degrees % Constants.DEGREES_IN_CIRCLE;
|
|
59
|
+
if (normalized < 0)
|
|
60
|
+
normalized += Constants.DEGREES_IN_CIRCLE;
|
|
61
|
+
return normalized;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Calculates the sine of an angle in radians.
|
|
65
|
+
* @param radians - Angle in radians
|
|
66
|
+
* @returns The sine value
|
|
67
|
+
*/
|
|
68
|
+
export function sin(radians) {
|
|
69
|
+
return Math.sin(radians);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Calculates the cosine of an angle in radians.
|
|
73
|
+
* @param radians - Angle in radians
|
|
74
|
+
* @returns The cosine value
|
|
75
|
+
*/
|
|
76
|
+
export function cos(radians) {
|
|
77
|
+
return Math.cos(radians);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Calculates the tangent of an angle in radians.
|
|
81
|
+
* @param radians - Angle in radians
|
|
82
|
+
* @returns The tangent value
|
|
83
|
+
* @throws {Error} If cosine is zero (angle is π/2 + nπ)
|
|
84
|
+
*/
|
|
85
|
+
export function tan(radians) {
|
|
86
|
+
const cosine = Math.cos(radians);
|
|
87
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
88
|
+
throw new Error('Tangent undefined for this angle (cosine is zero)');
|
|
89
|
+
}
|
|
90
|
+
return Math.tan(radians);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Calculates the arcsine (inverse sine) in radians.
|
|
94
|
+
* @param value - Sine value between -1 and 1
|
|
95
|
+
* @returns Angle in radians
|
|
96
|
+
* @throws {Error} If value is outside [-1, 1]
|
|
97
|
+
*/
|
|
98
|
+
export function asin(value) {
|
|
99
|
+
if (value < -1 || value > 1) {
|
|
100
|
+
throw new Error('Arcsine is only defined for values between -1 and 1');
|
|
101
|
+
}
|
|
102
|
+
return Math.asin(value);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Calculates the arccosine (inverse cosine) in radians.
|
|
106
|
+
* @param value - Cosine value between -1 and 1
|
|
107
|
+
* @returns Angle in radians
|
|
108
|
+
* @throws {Error} If value is outside [-1, 1]
|
|
109
|
+
*/
|
|
110
|
+
export function acos(value) {
|
|
111
|
+
if (value < -1 || value > 1) {
|
|
112
|
+
throw new Error('Arccosine is only defined for values between -1 and 1');
|
|
113
|
+
}
|
|
114
|
+
return Math.acos(value);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Calculates the arctangent (inverse tangent) in radians.
|
|
118
|
+
* @param value - Tangent value
|
|
119
|
+
* @returns Angle in radians between -π/2 and π/2
|
|
120
|
+
*/
|
|
121
|
+
export function atan(value) {
|
|
122
|
+
return Math.atan(value);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Calculates the arctangent of y/x in radians, handling all quadrants.
|
|
126
|
+
* @param y - Numerator
|
|
127
|
+
* @param x - Denominator
|
|
128
|
+
* @returns Angle in radians between -π and π
|
|
129
|
+
*/
|
|
130
|
+
export function atan2(y, x) {
|
|
131
|
+
return Math.atan2(y, x);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Calculates the hyperbolic sine.
|
|
135
|
+
* @param x - Input value
|
|
136
|
+
* @returns Hyperbolic sine
|
|
137
|
+
*/
|
|
138
|
+
export function sinh(x) {
|
|
139
|
+
return Math.sinh(x);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Calculates the hyperbolic cosine.
|
|
143
|
+
* @param x - Input value
|
|
144
|
+
* @returns Hyperbolic cosine
|
|
145
|
+
*/
|
|
146
|
+
export function cosh(x) {
|
|
147
|
+
return Math.cosh(x);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Calculates the hyperbolic tangent.
|
|
151
|
+
* @param x - Input value
|
|
152
|
+
* @returns Hyperbolic tangent
|
|
153
|
+
*/
|
|
154
|
+
export function tanh(x) {
|
|
155
|
+
return Math.tanh(x);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Calculates the inverse hyperbolic sine.
|
|
159
|
+
* @param x - Input value
|
|
160
|
+
* @returns Inverse hyperbolic sine
|
|
161
|
+
*/
|
|
162
|
+
export function asinh(x) {
|
|
163
|
+
return Math.asinh(x);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Calculates the inverse hyperbolic cosine.
|
|
167
|
+
* @param x - Input value >= 1
|
|
168
|
+
* @returns Inverse hyperbolic cosine
|
|
169
|
+
* @throws {Error} If x < 1
|
|
170
|
+
*/
|
|
171
|
+
export function acosh(x) {
|
|
172
|
+
if (x < 1) {
|
|
173
|
+
throw new Error('Inverse hyperbolic cosine is only defined for x >= 1');
|
|
174
|
+
}
|
|
175
|
+
return Math.acosh(x);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Calculates the inverse hyperbolic tangent.
|
|
179
|
+
* @param x - Input value between -1 and 1 (exclusive)
|
|
180
|
+
* @returns Inverse hyperbolic tangent
|
|
181
|
+
* @throws {Error} If |x| >= 1
|
|
182
|
+
*/
|
|
183
|
+
export function atanh(x) {
|
|
184
|
+
if (Math.abs(x) >= 1) {
|
|
185
|
+
throw new Error('Inverse hyperbolic tangent is only defined for |x| < 1');
|
|
186
|
+
}
|
|
187
|
+
return Math.atanh(x);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Calculates the secant of an angle.
|
|
191
|
+
* @param radians - Angle in radians
|
|
192
|
+
* @returns The secant value
|
|
193
|
+
* @throws {Error} If cosine is zero
|
|
194
|
+
*/
|
|
195
|
+
export function sec(radians) {
|
|
196
|
+
const cosine = Math.cos(radians);
|
|
197
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
198
|
+
throw new Error('Secant undefined for this angle (cosine is zero)');
|
|
199
|
+
}
|
|
200
|
+
return 1 / cosine;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Calculates the cosecant of an angle.
|
|
204
|
+
* @param radians - Angle in radians
|
|
205
|
+
* @returns The cosecant value
|
|
206
|
+
* @throws {Error} If sine is zero
|
|
207
|
+
*/
|
|
208
|
+
export function csc(radians) {
|
|
209
|
+
const sine = Math.sin(radians);
|
|
210
|
+
if (Math.abs(sine) < 1e-10) {
|
|
211
|
+
throw new Error('Cosecant undefined for this angle (sine is zero)');
|
|
212
|
+
}
|
|
213
|
+
return 1 / sine;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Calculates the cotangent of an angle.
|
|
217
|
+
* @param radians - Angle in radians
|
|
218
|
+
* @returns The cotangent value
|
|
219
|
+
* @throws {Error} If tangent is zero
|
|
220
|
+
*/
|
|
221
|
+
export function cot(radians) {
|
|
222
|
+
const tangent = Math.tan(radians);
|
|
223
|
+
if (Math.abs(tangent) < 1e-10) {
|
|
224
|
+
throw new Error('Cotangent undefined for this angle (tangent is zero)');
|
|
225
|
+
}
|
|
226
|
+
return 1 / tangent;
|
|
227
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// src/lib/maths/constants.ts
|
|
2
|
+
var PI = 3.141592653589793;
|
|
3
|
+
var E = 2.718281828459045;
|
|
4
|
+
var PHI = 1.618033988749894;
|
|
5
|
+
var SQRT2 = 1.4142135623730951;
|
|
6
|
+
var SQRT1_2 = 0.7071067811865476;
|
|
7
|
+
var LN2 = 0.6931471805599453;
|
|
8
|
+
var LN10 = 2.302585092994046;
|
|
9
|
+
var LOG2E = 1.4426950408889634;
|
|
10
|
+
var LOG10E = 0.4342944819032518;
|
|
11
|
+
var DEGREES_IN_CIRCLE = 360;
|
|
12
|
+
var RADIANS_IN_CIRCLE = 2 * PI;
|
|
13
|
+
var GRADIANS_IN_CIRCLE = 400;
|
|
14
|
+
var DEGREES_PER_RADIAN = 180 / PI;
|
|
15
|
+
var RADIANS_PER_DEGREE = PI / 180;
|
|
16
|
+
var Constants = {
|
|
17
|
+
PI,
|
|
18
|
+
E,
|
|
19
|
+
PHI,
|
|
20
|
+
SQRT2,
|
|
21
|
+
SQRT1_2,
|
|
22
|
+
LN2,
|
|
23
|
+
LN10,
|
|
24
|
+
LOG2E,
|
|
25
|
+
LOG10E,
|
|
26
|
+
DEGREES_IN_CIRCLE,
|
|
27
|
+
RADIANS_IN_CIRCLE,
|
|
28
|
+
GRADIANS_IN_CIRCLE,
|
|
29
|
+
DEGREES_PER_RADIAN,
|
|
30
|
+
RADIANS_PER_DEGREE
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/lib/maths/fn/trigo.ts
|
|
34
|
+
function degToRad(degrees) {
|
|
35
|
+
return degrees * Constants.RADIANS_PER_DEGREE;
|
|
36
|
+
}
|
|
37
|
+
function radToDeg(radians) {
|
|
38
|
+
return radians * Constants.DEGREES_PER_RADIAN;
|
|
39
|
+
}
|
|
40
|
+
function degToGrad(degrees) {
|
|
41
|
+
return degrees * (Constants.GRADIANS_IN_CIRCLE / Constants.DEGREES_IN_CIRCLE);
|
|
42
|
+
}
|
|
43
|
+
function gradToDeg(gradians) {
|
|
44
|
+
return gradians * (Constants.DEGREES_IN_CIRCLE / Constants.GRADIANS_IN_CIRCLE);
|
|
45
|
+
}
|
|
46
|
+
function normalizeRadians(radians) {
|
|
47
|
+
const twoPi = Constants.RADIANS_IN_CIRCLE;
|
|
48
|
+
let normalized = radians % twoPi;
|
|
49
|
+
if (normalized < 0) normalized += twoPi;
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
function normalizeDegrees(degrees) {
|
|
53
|
+
let normalized = degrees % Constants.DEGREES_IN_CIRCLE;
|
|
54
|
+
if (normalized < 0) normalized += Constants.DEGREES_IN_CIRCLE;
|
|
55
|
+
return normalized;
|
|
56
|
+
}
|
|
57
|
+
function sin(radians) {
|
|
58
|
+
return Math.sin(radians);
|
|
59
|
+
}
|
|
60
|
+
function cos(radians) {
|
|
61
|
+
return Math.cos(radians);
|
|
62
|
+
}
|
|
63
|
+
function tan(radians) {
|
|
64
|
+
const cosine = Math.cos(radians);
|
|
65
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
66
|
+
throw new Error("Tangent undefined for this angle (cosine is zero)");
|
|
67
|
+
}
|
|
68
|
+
return Math.tan(radians);
|
|
69
|
+
}
|
|
70
|
+
function asin(value) {
|
|
71
|
+
if (value < -1 || value > 1) {
|
|
72
|
+
throw new Error("Arcsine is only defined for values between -1 and 1");
|
|
73
|
+
}
|
|
74
|
+
return Math.asin(value);
|
|
75
|
+
}
|
|
76
|
+
function acos(value) {
|
|
77
|
+
if (value < -1 || value > 1) {
|
|
78
|
+
throw new Error("Arccosine is only defined for values between -1 and 1");
|
|
79
|
+
}
|
|
80
|
+
return Math.acos(value);
|
|
81
|
+
}
|
|
82
|
+
function atan(value) {
|
|
83
|
+
return Math.atan(value);
|
|
84
|
+
}
|
|
85
|
+
function atan2(y, x) {
|
|
86
|
+
return Math.atan2(y, x);
|
|
87
|
+
}
|
|
88
|
+
function sinh(x) {
|
|
89
|
+
return Math.sinh(x);
|
|
90
|
+
}
|
|
91
|
+
function cosh(x) {
|
|
92
|
+
return Math.cosh(x);
|
|
93
|
+
}
|
|
94
|
+
function tanh(x) {
|
|
95
|
+
return Math.tanh(x);
|
|
96
|
+
}
|
|
97
|
+
function asinh(x) {
|
|
98
|
+
return Math.asinh(x);
|
|
99
|
+
}
|
|
100
|
+
function acosh(x) {
|
|
101
|
+
if (x < 1) {
|
|
102
|
+
throw new Error("Inverse hyperbolic cosine is only defined for x >= 1");
|
|
103
|
+
}
|
|
104
|
+
return Math.acosh(x);
|
|
105
|
+
}
|
|
106
|
+
function atanh(x) {
|
|
107
|
+
if (Math.abs(x) >= 1) {
|
|
108
|
+
throw new Error("Inverse hyperbolic tangent is only defined for |x| < 1");
|
|
109
|
+
}
|
|
110
|
+
return Math.atanh(x);
|
|
111
|
+
}
|
|
112
|
+
function sec(radians) {
|
|
113
|
+
const cosine = Math.cos(radians);
|
|
114
|
+
if (Math.abs(cosine) < 1e-10) {
|
|
115
|
+
throw new Error("Secant undefined for this angle (cosine is zero)");
|
|
116
|
+
}
|
|
117
|
+
return 1 / cosine;
|
|
118
|
+
}
|
|
119
|
+
function csc(radians) {
|
|
120
|
+
const sine = Math.sin(radians);
|
|
121
|
+
if (Math.abs(sine) < 1e-10) {
|
|
122
|
+
throw new Error("Cosecant undefined for this angle (sine is zero)");
|
|
123
|
+
}
|
|
124
|
+
return 1 / sine;
|
|
125
|
+
}
|
|
126
|
+
function cot(radians) {
|
|
127
|
+
const tangent = Math.tan(radians);
|
|
128
|
+
if (Math.abs(tangent) < 1e-10) {
|
|
129
|
+
throw new Error("Cotangent undefined for this angle (tangent is zero)");
|
|
130
|
+
}
|
|
131
|
+
return 1 / tangent;
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
acos,
|
|
135
|
+
acosh,
|
|
136
|
+
asin,
|
|
137
|
+
asinh,
|
|
138
|
+
atan,
|
|
139
|
+
atan2,
|
|
140
|
+
atanh,
|
|
141
|
+
cos,
|
|
142
|
+
cosh,
|
|
143
|
+
cot,
|
|
144
|
+
csc,
|
|
145
|
+
degToGrad,
|
|
146
|
+
degToRad,
|
|
147
|
+
gradToDeg,
|
|
148
|
+
normalizeDegrees,
|
|
149
|
+
normalizeRadians,
|
|
150
|
+
radToDeg,
|
|
151
|
+
sec,
|
|
152
|
+
sin,
|
|
153
|
+
sinh,
|
|
154
|
+
tan,
|
|
155
|
+
tanh
|
|
156
|
+
};
|