@equinor/videx-math 1.1.1 → 1.1.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/README.md +2 -0
- package/dist/const.d.ts +15 -15
- package/dist/index.d.ts +178 -178
- package/package.json +11 -11
package/README.md
CHANGED
package/dist/const.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constant for converting radians to degrees.
|
|
3
|
-
* @private
|
|
4
|
-
*/
|
|
5
|
-
export declare const RAD2DEG: number;
|
|
6
|
-
/**
|
|
7
|
-
* Constant for converting degrees to radians.
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
export declare const DEG2RAD: number;
|
|
11
|
-
/**
|
|
12
|
-
* Constant for 2π.
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
export declare const TAU: number;
|
|
1
|
+
/**
|
|
2
|
+
* Constant for converting radians to degrees.
|
|
3
|
+
* @private
|
|
4
|
+
*/
|
|
5
|
+
export declare const RAD2DEG: number;
|
|
6
|
+
/**
|
|
7
|
+
* Constant for converting degrees to radians.
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEG2RAD: number;
|
|
11
|
+
/**
|
|
12
|
+
* Constant for 2π.
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export declare const TAU: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clamps the value to min or max if value is less than min or greater than max.
|
|
3
|
-
* @param value Value to clamp
|
|
4
|
-
* @param min Minimum value (Default: 0)
|
|
5
|
-
* @param max Maximum value (Default: 1)
|
|
6
|
-
* @return Clamped value
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* clamp(8, 3, 7); // Returns: 7
|
|
10
|
-
*/
|
|
11
|
-
export declare function clamp(value: number, min?: number, max?: number): number;
|
|
12
|
-
/**
|
|
13
|
-
* Generate a step function by comparing two values.
|
|
14
|
-
* @param edge Edge of the step function
|
|
15
|
-
* @param x Value used to generate the step function
|
|
16
|
-
* @return Returns either 0 or 1
|
|
17
|
-
*/
|
|
18
|
-
export declare function step(edge: number, x: number): number;
|
|
19
|
-
/**
|
|
20
|
-
* Perform Hermite interpolation between two values.
|
|
21
|
-
* @param edge0 Lower edge of the Hermite function
|
|
22
|
-
* @param edge1 Upper edge of the Hermite function
|
|
23
|
-
* @param x Source value for interpolation
|
|
24
|
-
* @return Hermite interpolated value
|
|
25
|
-
*/
|
|
26
|
-
export declare function smoothstep(edge0: number, edge1: number, x: number): number;
|
|
27
|
-
/**
|
|
28
|
-
* Linear interpolation between two numbers.
|
|
29
|
-
* @param a Number to interpolate from
|
|
30
|
-
* @param b Number to interpolate to
|
|
31
|
-
* @param t Interpolation parameter, 0 = a and 1 = b
|
|
32
|
-
* @return The interpolated value
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* lerp(2, 4, 0.5); // Returns 3
|
|
36
|
-
*/
|
|
37
|
-
export declare function lerp(a: number, b: number, t: number): number;
|
|
38
|
-
/**
|
|
39
|
-
* Get the interpolant [t] that produces given value within the range [a, b].
|
|
40
|
-
* @param a Start value
|
|
41
|
-
* @param b End value
|
|
42
|
-
* @param value Value between start and end
|
|
43
|
-
* @return Percentage of value between start and end
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* inverseLerp(2, 4, 3); // Returns 0.5
|
|
47
|
-
*/
|
|
48
|
-
export declare function inverseLerp(a: number, b: number, value: number): number;
|
|
49
|
-
/**
|
|
50
|
-
* Rounds number to a specific amount of digits.
|
|
51
|
-
* @param value Value to round
|
|
52
|
-
* @param digits Number of digits (Default: 1)
|
|
53
|
-
* @return Rounded value
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* round(Math.PI, 3); // Returns 3.142
|
|
57
|
-
*/
|
|
58
|
-
export declare function round(value: number, digits?: number): number;
|
|
59
|
-
/**
|
|
60
|
-
* Convert degrees to radians.
|
|
61
|
-
* @param deg Angle in degrees
|
|
62
|
-
* @returns Angle in radians
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* radians(90); // Returns π / 2
|
|
66
|
-
*/
|
|
67
|
-
export declare function radians(deg: number): number;
|
|
68
|
-
/**
|
|
69
|
-
* Convert radians to degrees.
|
|
70
|
-
* @param rad Angle in radians
|
|
71
|
-
* @returns Angle in degrees
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* degrees(Math.PI); // Returns 180
|
|
75
|
-
*/
|
|
76
|
-
export declare function degrees(rad: number): number;
|
|
77
|
-
/**
|
|
78
|
-
* Normalise an angle to be between -π and +π.
|
|
79
|
-
* @param rad Angle in radians
|
|
80
|
-
* @return Normalised angle
|
|
81
|
-
*/
|
|
82
|
-
export declare function nrad(rad: number): number;
|
|
83
|
-
/**
|
|
84
|
-
* Generates a list of interpolated values between start and end,
|
|
85
|
-
* where the number of elements returned is equal to the amount
|
|
86
|
-
* of steps.
|
|
87
|
-
* @param start Start of interpolated range
|
|
88
|
-
* @param end End of interpolated range
|
|
89
|
-
* @param steps Steps of interpolation
|
|
90
|
-
* @returns Interpolated series
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* seq(2, 4, 5); // Returns [2, 2.5, 3, 3.5, 4]
|
|
94
|
-
*/
|
|
95
|
-
export declare function seq(start: number, end: number, steps: number): number[];
|
|
96
|
-
/**
|
|
97
|
-
* Generates a list of interpolated values between 0 and 1,
|
|
98
|
-
* where the number of elements returned is equal to the amount
|
|
99
|
-
* of steps.
|
|
100
|
-
* @param steps Steps of interpolation
|
|
101
|
-
* @returns Interpolated series
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* seqI(3); // Returns [0, 0.5, 1]
|
|
105
|
-
*/
|
|
106
|
-
export declare function seqI(steps: number): number[];
|
|
107
|
-
/**
|
|
108
|
-
* Retrieves the minimum value of an array.
|
|
109
|
-
* @param values Array with values
|
|
110
|
-
* @returns Minimum value
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* min([2, 1, 3]); // Returns 1
|
|
114
|
-
*/
|
|
115
|
-
export declare function min(values: number[]): number;
|
|
116
|
-
/**
|
|
117
|
-
* Retrieves the minimum value among a collection of values.
|
|
118
|
-
* @param values Collection of values
|
|
119
|
-
* @returns Minimum value
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* min(2, 1, 3); // Returns 1
|
|
123
|
-
*/
|
|
124
|
-
export declare function min(...values: number[]): number;
|
|
125
|
-
/**
|
|
126
|
-
* Retrieves the maximum value of an array.
|
|
127
|
-
* @param values Array with values
|
|
128
|
-
* @returns Maximum value
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* min([2, 1, 3]); // Returns 3
|
|
132
|
-
*/
|
|
133
|
-
export declare function max(values: number[]): number;
|
|
134
|
-
/**
|
|
135
|
-
* Retrieves the maximum value among a collection of values.
|
|
136
|
-
* @param values Collection of values
|
|
137
|
-
* @returns Maximum value
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* min(2, 1, 3); // Returns 3
|
|
141
|
-
*/
|
|
142
|
-
export declare function max(...values: number[]): number;
|
|
143
|
-
/**
|
|
144
|
-
* Retrieves the extent of an array.
|
|
145
|
-
* @param values Array with values
|
|
146
|
-
* @returns Extent on format [min, max]
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* min([2, 1, 3]); // Returns [1, 3]
|
|
150
|
-
*/
|
|
151
|
-
export declare function extent(values: number[]): [number, number];
|
|
152
|
-
/**
|
|
153
|
-
* Retrieves the extent of a collection of values.
|
|
154
|
-
* @param values Collection of values
|
|
155
|
-
* @returns Extent on format [min, max]
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* min(2, 1, 3); // Returns [1, 3]
|
|
159
|
-
*/
|
|
160
|
-
export declare function extent(...values: number[]): [number, number];
|
|
161
|
-
/**
|
|
162
|
-
* Find the mean of a numeric array.
|
|
163
|
-
* @param values Array with values
|
|
164
|
-
* @returns Mean of values
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* mean([2, 1, 3]); // Returns 2
|
|
168
|
-
*/
|
|
169
|
-
export declare function mean(values: number[]): number;
|
|
170
|
-
/**
|
|
171
|
-
* Find the mean of a collection of values.
|
|
172
|
-
* @param values Collection of values
|
|
173
|
-
* @returns Mean of values
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* mean(2, 1, 3); // Returns 2
|
|
177
|
-
*/
|
|
178
|
-
export declare function mean(...values: number[]): number;
|
|
1
|
+
/**
|
|
2
|
+
* Clamps the value to min or max if value is less than min or greater than max.
|
|
3
|
+
* @param value Value to clamp
|
|
4
|
+
* @param min Minimum value (Default: 0)
|
|
5
|
+
* @param max Maximum value (Default: 1)
|
|
6
|
+
* @return Clamped value
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* clamp(8, 3, 7); // Returns: 7
|
|
10
|
+
*/
|
|
11
|
+
export declare function clamp(value: number, min?: number, max?: number): number;
|
|
12
|
+
/**
|
|
13
|
+
* Generate a step function by comparing two values.
|
|
14
|
+
* @param edge Edge of the step function
|
|
15
|
+
* @param x Value used to generate the step function
|
|
16
|
+
* @return Returns either 0 or 1
|
|
17
|
+
*/
|
|
18
|
+
export declare function step(edge: number, x: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Perform Hermite interpolation between two values.
|
|
21
|
+
* @param edge0 Lower edge of the Hermite function
|
|
22
|
+
* @param edge1 Upper edge of the Hermite function
|
|
23
|
+
* @param x Source value for interpolation
|
|
24
|
+
* @return Hermite interpolated value
|
|
25
|
+
*/
|
|
26
|
+
export declare function smoothstep(edge0: number, edge1: number, x: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Linear interpolation between two numbers.
|
|
29
|
+
* @param a Number to interpolate from
|
|
30
|
+
* @param b Number to interpolate to
|
|
31
|
+
* @param t Interpolation parameter, 0 = a and 1 = b
|
|
32
|
+
* @return The interpolated value
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* lerp(2, 4, 0.5); // Returns 3
|
|
36
|
+
*/
|
|
37
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* Get the interpolant [t] that produces given value within the range [a, b].
|
|
40
|
+
* @param a Start value
|
|
41
|
+
* @param b End value
|
|
42
|
+
* @param value Value between start and end
|
|
43
|
+
* @return Percentage of value between start and end
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* inverseLerp(2, 4, 3); // Returns 0.5
|
|
47
|
+
*/
|
|
48
|
+
export declare function inverseLerp(a: number, b: number, value: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* Rounds number to a specific amount of digits.
|
|
51
|
+
* @param value Value to round
|
|
52
|
+
* @param digits Number of digits (Default: 1)
|
|
53
|
+
* @return Rounded value
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* round(Math.PI, 3); // Returns 3.142
|
|
57
|
+
*/
|
|
58
|
+
export declare function round(value: number, digits?: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Convert degrees to radians.
|
|
61
|
+
* @param deg Angle in degrees
|
|
62
|
+
* @returns Angle in radians
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* radians(90); // Returns π / 2
|
|
66
|
+
*/
|
|
67
|
+
export declare function radians(deg: number): number;
|
|
68
|
+
/**
|
|
69
|
+
* Convert radians to degrees.
|
|
70
|
+
* @param rad Angle in radians
|
|
71
|
+
* @returns Angle in degrees
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* degrees(Math.PI); // Returns 180
|
|
75
|
+
*/
|
|
76
|
+
export declare function degrees(rad: number): number;
|
|
77
|
+
/**
|
|
78
|
+
* Normalise an angle to be between -π and +π.
|
|
79
|
+
* @param rad Angle in radians
|
|
80
|
+
* @return Normalised angle
|
|
81
|
+
*/
|
|
82
|
+
export declare function nrad(rad: number): number;
|
|
83
|
+
/**
|
|
84
|
+
* Generates a list of interpolated values between start and end,
|
|
85
|
+
* where the number of elements returned is equal to the amount
|
|
86
|
+
* of steps.
|
|
87
|
+
* @param start Start of interpolated range
|
|
88
|
+
* @param end End of interpolated range
|
|
89
|
+
* @param steps Steps of interpolation
|
|
90
|
+
* @returns Interpolated series
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* seq(2, 4, 5); // Returns [2, 2.5, 3, 3.5, 4]
|
|
94
|
+
*/
|
|
95
|
+
export declare function seq(start: number, end: number, steps: number): number[];
|
|
96
|
+
/**
|
|
97
|
+
* Generates a list of interpolated values between 0 and 1,
|
|
98
|
+
* where the number of elements returned is equal to the amount
|
|
99
|
+
* of steps.
|
|
100
|
+
* @param steps Steps of interpolation
|
|
101
|
+
* @returns Interpolated series
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* seqI(3); // Returns [0, 0.5, 1]
|
|
105
|
+
*/
|
|
106
|
+
export declare function seqI(steps: number): number[];
|
|
107
|
+
/**
|
|
108
|
+
* Retrieves the minimum value of an array.
|
|
109
|
+
* @param values Array with values
|
|
110
|
+
* @returns Minimum value
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* min([2, 1, 3]); // Returns 1
|
|
114
|
+
*/
|
|
115
|
+
export declare function min(values: number[]): number;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves the minimum value among a collection of values.
|
|
118
|
+
* @param values Collection of values
|
|
119
|
+
* @returns Minimum value
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* min(2, 1, 3); // Returns 1
|
|
123
|
+
*/
|
|
124
|
+
export declare function min(...values: number[]): number;
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves the maximum value of an array.
|
|
127
|
+
* @param values Array with values
|
|
128
|
+
* @returns Maximum value
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* min([2, 1, 3]); // Returns 3
|
|
132
|
+
*/
|
|
133
|
+
export declare function max(values: number[]): number;
|
|
134
|
+
/**
|
|
135
|
+
* Retrieves the maximum value among a collection of values.
|
|
136
|
+
* @param values Collection of values
|
|
137
|
+
* @returns Maximum value
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* min(2, 1, 3); // Returns 3
|
|
141
|
+
*/
|
|
142
|
+
export declare function max(...values: number[]): number;
|
|
143
|
+
/**
|
|
144
|
+
* Retrieves the extent of an array.
|
|
145
|
+
* @param values Array with values
|
|
146
|
+
* @returns Extent on format [min, max]
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* min([2, 1, 3]); // Returns [1, 3]
|
|
150
|
+
*/
|
|
151
|
+
export declare function extent(values: number[]): [number, number];
|
|
152
|
+
/**
|
|
153
|
+
* Retrieves the extent of a collection of values.
|
|
154
|
+
* @param values Collection of values
|
|
155
|
+
* @returns Extent on format [min, max]
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* min(2, 1, 3); // Returns [1, 3]
|
|
159
|
+
*/
|
|
160
|
+
export declare function extent(...values: number[]): [number, number];
|
|
161
|
+
/**
|
|
162
|
+
* Find the mean of a numeric array.
|
|
163
|
+
* @param values Array with values
|
|
164
|
+
* @returns Mean of values
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* mean([2, 1, 3]); // Returns 2
|
|
168
|
+
*/
|
|
169
|
+
export declare function mean(values: number[]): number;
|
|
170
|
+
/**
|
|
171
|
+
* Find the mean of a collection of values.
|
|
172
|
+
* @param values Collection of values
|
|
173
|
+
* @returns Mean of values
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* mean(2, 1, 3); // Returns 2
|
|
177
|
+
*/
|
|
178
|
+
export declare function mean(...values: number[]): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/videx-math",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A library with math used by Videx.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"pub": "npm publish --access=public",
|
|
17
17
|
"test": "jest",
|
|
18
18
|
"test:watch": "jest --watchAll",
|
|
19
|
-
"lint": "eslint
|
|
19
|
+
"lint": "eslint src --color",
|
|
20
20
|
"predocs": "rimraf docs",
|
|
21
21
|
"docs": "typedoc --out docs src",
|
|
22
22
|
"postdocs": "node postdocs.copyfiles.mjs"
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/equinor/videx-math#readme",
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@
|
|
38
|
+
"@eslint/js": "^9.32.0",
|
|
39
39
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
40
40
|
"@rollup/plugin-terser": "^0.4.4",
|
|
41
41
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
42
|
-
"
|
|
43
|
-
"eslint": "^
|
|
44
|
-
"eslint-plugin-import": "^2.
|
|
45
|
-
"
|
|
46
|
-
"@typescript-eslint/parser": "^8.4.0",
|
|
47
|
-
"jest": "^29.5.0",
|
|
42
|
+
"@types/jest": "^29.5.12",
|
|
43
|
+
"eslint": "^9.32.0",
|
|
44
|
+
"eslint-plugin-import": "^2.31.0",
|
|
45
|
+
"jest": "^29.7.0",
|
|
48
46
|
"rimraf": "^6.0.1",
|
|
47
|
+
"rollup": "^3.29.5",
|
|
49
48
|
"ts-jest": "^29.1.0",
|
|
50
49
|
"tslib": "^2.7.0",
|
|
51
|
-
"typedoc": "^0.
|
|
52
|
-
"typescript": "^4.
|
|
50
|
+
"typedoc": "^0.26.6",
|
|
51
|
+
"typescript": "^4.9.5",
|
|
52
|
+
"typescript-eslint": "^8.26.1"
|
|
53
53
|
},
|
|
54
54
|
"jest": {
|
|
55
55
|
"transform": {
|