@bitbybit-dev/base 0.20.12 → 0.20.14
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/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/lists-inputs.d.ts +39 -0
- package/lib/api/inputs/lists-inputs.js +43 -0
- package/lib/api/inputs/math-inputs.d.ts +154 -0
- package/lib/api/inputs/math-inputs.js +217 -0
- package/lib/api/inputs/text-inputs.d.ts +139 -0
- package/lib/api/inputs/text-inputs.js +215 -0
- package/lib/api/inputs/vector-inputs.d.ts +8 -0
- package/lib/api/inputs/vector-inputs.js +8 -0
- package/lib/api/services/color.d.ts +27 -12
- package/lib/api/services/color.js +27 -12
- package/lib/api/services/dates.d.ts +62 -30
- package/lib/api/services/dates.js +62 -30
- package/lib/api/services/geometry-helper.d.ts +50 -0
- package/lib/api/services/geometry-helper.js +50 -2
- package/lib/api/services/helpers/dxf/dxf.d.ts +19 -9
- package/lib/api/services/helpers/dxf/dxf.js +19 -9
- package/lib/api/services/line.d.ts +34 -16
- package/lib/api/services/line.js +34 -16
- package/lib/api/services/lists.d.ts +175 -32
- package/lib/api/services/lists.js +275 -32
- package/lib/api/services/logic.d.ts +24 -13
- package/lib/api/services/logic.js +24 -13
- package/lib/api/services/math.d.ts +180 -35
- package/lib/api/services/math.js +215 -35
- package/lib/api/services/mesh.d.ts +17 -6
- package/lib/api/services/mesh.js +17 -6
- package/lib/api/services/point.d.ts +63 -32
- package/lib/api/services/point.js +63 -32
- package/lib/api/services/polyline.d.ts +27 -11
- package/lib/api/services/polyline.js +27 -11
- package/lib/api/services/text.d.ts +286 -7
- package/lib/api/services/text.js +350 -7
- package/lib/api/services/transforms.d.ts +30 -16
- package/lib/api/services/transforms.js +30 -16
- package/lib/api/services/vector.d.ts +85 -38
- package/lib/api/services/vector.js +87 -38
- package/package.json +1 -1
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export class Logic {
|
|
5
5
|
/**
|
|
6
|
-
* Creates a boolean value -
|
|
6
|
+
* Creates and returns a boolean value (pass-through for boolean input).
|
|
7
|
+
* Example: true → true, false → false
|
|
7
8
|
* @param inputs a true or false boolean
|
|
8
9
|
* @returns boolean
|
|
9
10
|
* @group create
|
|
@@ -14,7 +15,8 @@ export class Logic {
|
|
|
14
15
|
return inputs.boolean;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Generates a random boolean list where each value has a threshold chance of being true.
|
|
19
|
+
* Example: length=5, threshold=0.7 → might produce [true, true, false, true, true]
|
|
18
20
|
* @param inputs a length and a threshold for randomization of true values
|
|
19
21
|
* @returns booleans
|
|
20
22
|
* @group create
|
|
@@ -29,10 +31,10 @@ export class Logic {
|
|
|
29
31
|
return booleans;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Converts numbers to booleans using two thresholds with gradient randomization between them.
|
|
35
|
+
* Values below trueThreshold → always true, above falseThreshold → always false.
|
|
36
|
+
* Between thresholds → probability gradient (closer to false threshold = higher chance of false).
|
|
37
|
+
* Example: [0.1, 0.4, 0.6, 0.9] with thresholds [0.3, 0.7] → [true, gradient, gradient, false]
|
|
36
38
|
* @param inputs a length and a threshold for randomization of true values
|
|
37
39
|
* @returns booleans
|
|
38
40
|
* @group create
|
|
@@ -65,7 +67,9 @@ export class Logic {
|
|
|
65
67
|
return booleans;
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
|
-
*
|
|
70
|
+
* Converts numbers to booleans based on a threshold (below threshold → true, above → false).
|
|
71
|
+
* Can be inverted to flip the logic.
|
|
72
|
+
* Example: [0.3, 0.7, 0.5] with threshold=0.6 → [true, false, true]
|
|
69
73
|
* @param inputs a length and a threshold for randomization of true values
|
|
70
74
|
* @returns booleans
|
|
71
75
|
* @group create
|
|
@@ -88,7 +92,9 @@ export class Logic {
|
|
|
88
92
|
return booleans;
|
|
89
93
|
}
|
|
90
94
|
/**
|
|
91
|
-
*
|
|
95
|
+
* Converts numbers to booleans using multiple range thresholds (gaps define true ranges).
|
|
96
|
+
* Values within any gap range → true, outside all gaps → false. Can be inverted.
|
|
97
|
+
* Example: [0.2, 0.5, 0.8] with gaps [[0.3, 0.6], [0.7, 0.9]] → [false, true, true]
|
|
92
98
|
* @param inputs a length and a threshold for randomization of true values
|
|
93
99
|
* @returns booleans
|
|
94
100
|
* @group create
|
|
@@ -117,7 +123,8 @@ export class Logic {
|
|
|
117
123
|
return booleans;
|
|
118
124
|
}
|
|
119
125
|
/**
|
|
120
|
-
*
|
|
126
|
+
* Applies NOT operator to flip a boolean value.
|
|
127
|
+
* Example: true → false, false → true
|
|
121
128
|
* @param inputs a true or false boolean
|
|
122
129
|
* @returns boolean
|
|
123
130
|
* @group edit
|
|
@@ -128,7 +135,8 @@ export class Logic {
|
|
|
128
135
|
return !inputs.boolean;
|
|
129
136
|
}
|
|
130
137
|
/**
|
|
131
|
-
*
|
|
138
|
+
* Applies NOT operator to flip all boolean values in a list.
|
|
139
|
+
* Example: [true, false, true] → [false, true, false]
|
|
132
140
|
* @param inputs a list of true or false booleans
|
|
133
141
|
* @returns booleans
|
|
134
142
|
* @group edit
|
|
@@ -139,7 +147,8 @@ export class Logic {
|
|
|
139
147
|
return inputs.booleans.map(b => !b);
|
|
140
148
|
}
|
|
141
149
|
/**
|
|
142
|
-
*
|
|
150
|
+
* Compares two values using various operators (==, !=, ===, !==, <, <=, >, >=).
|
|
151
|
+
* Example: 5 > 3 → true, 'hello' === 'world' → false
|
|
143
152
|
* @param inputs two values to be compared
|
|
144
153
|
* @returns Result of the comparison
|
|
145
154
|
* @group operations
|
|
@@ -169,7 +178,8 @@ export class Logic {
|
|
|
169
178
|
}
|
|
170
179
|
}
|
|
171
180
|
/**
|
|
172
|
-
*
|
|
181
|
+
* Conditionally passes a value through if boolean is true, otherwise returns undefined.
|
|
182
|
+
* Example: value=42, boolean=true → 42, value=42, boolean=false → undefined
|
|
173
183
|
* @param inputs a value and a boolean value
|
|
174
184
|
* @returns value or undefined
|
|
175
185
|
* @group operations
|
|
@@ -180,7 +190,8 @@ export class Logic {
|
|
|
180
190
|
return inputs.boolean ? inputs.value : undefined;
|
|
181
191
|
}
|
|
182
192
|
/**
|
|
183
|
-
* Returns first defined value
|
|
193
|
+
* Returns the first defined (non-undefined) value from two options (fallback pattern).
|
|
194
|
+
* Example: value1=42, value2=10 → 42, value1=undefined, value2=10 → 10
|
|
184
195
|
* @param inputs two values
|
|
185
196
|
* @returns value or undefined
|
|
186
197
|
* @group operations
|
|
@@ -4,7 +4,8 @@ import * as Inputs from "../inputs";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class MathBitByBit {
|
|
6
6
|
/**
|
|
7
|
-
* Creates a number
|
|
7
|
+
* Creates and returns a number value (pass-through for number input).
|
|
8
|
+
* Example: Input 42 → 42, Input 3.14 → 3.14
|
|
8
9
|
* @param inputs a number to be created
|
|
9
10
|
* @returns number
|
|
10
11
|
* @group create
|
|
@@ -13,7 +14,8 @@ export declare class MathBitByBit {
|
|
|
13
14
|
*/
|
|
14
15
|
number(inputs: Inputs.Math.NumberDto): number;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Performs basic arithmetic operations on two numbers (add, subtract, multiply, divide, power, modulus).
|
|
18
|
+
* Example: 5 + 3 → 8, 10 % 3 → 1, 2 ^ 3 → 8
|
|
17
19
|
* @param inputs two numbers and operator
|
|
18
20
|
* @returns Result of math operation action
|
|
19
21
|
* @group operations
|
|
@@ -22,7 +24,8 @@ export declare class MathBitByBit {
|
|
|
22
24
|
*/
|
|
23
25
|
twoNrOperation(inputs: Inputs.Math.ActionOnTwoNumbersDto): number;
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
27
|
+
* Calculates the remainder after division (modulus operation).
|
|
28
|
+
* Example: 10 % 3 → 1, 17 % 5 → 2
|
|
26
29
|
* @param inputs two numbers and operator
|
|
27
30
|
* @returns Result of modulus operation
|
|
28
31
|
* @group operations
|
|
@@ -31,7 +34,8 @@ export declare class MathBitByBit {
|
|
|
31
34
|
*/
|
|
32
35
|
modulus(inputs: Inputs.Math.ModulusDto): number;
|
|
33
36
|
/**
|
|
34
|
-
*
|
|
37
|
+
* Rounds a number to specified decimal places.
|
|
38
|
+
* Example: 1.32156 with 3 decimals returns 1.322
|
|
35
39
|
* @param inputs a number and decimal places
|
|
36
40
|
* @returns Result of rounding
|
|
37
41
|
* @group operations
|
|
@@ -40,7 +44,18 @@ export declare class MathBitByBit {
|
|
|
40
44
|
*/
|
|
41
45
|
roundToDecimals(inputs: Inputs.Math.RoundToDecimalsDto): number;
|
|
42
46
|
/**
|
|
43
|
-
*
|
|
47
|
+
* Rounds a number to specified decimal places and removes trailing zeros.
|
|
48
|
+
* Example: 1.32156 with 3 decimals returns 1.322, but 1.320000001 returns 1.32, and 1.000 returns 1
|
|
49
|
+
* @param inputs a number and decimal places
|
|
50
|
+
* @returns Result of rounding as a number without trailing zeros
|
|
51
|
+
* @group operations
|
|
52
|
+
* @shortname round trim zeros
|
|
53
|
+
* @drawable false
|
|
54
|
+
*/
|
|
55
|
+
roundAndRemoveTrailingZeros(inputs: Inputs.Math.RoundToDecimalsDto): number;
|
|
56
|
+
/**
|
|
57
|
+
* Performs mathematical operations on a single number (absolute, negate, sqrt, trig functions, logarithms, etc.).
|
|
58
|
+
* Example: sqrt(5) → 2.236, abs(-3) → 3, sin(π/2) → 1
|
|
44
59
|
* @param inputs one number and operator action
|
|
45
60
|
* @returns Result of math operation
|
|
46
61
|
* @group operations
|
|
@@ -49,7 +64,8 @@ export declare class MathBitByBit {
|
|
|
49
64
|
*/
|
|
50
65
|
oneNrOperation(inputs: Inputs.Math.ActionOnOneNumberDto): number;
|
|
51
66
|
/**
|
|
52
|
-
*
|
|
67
|
+
* Maps a number from one range to another range proportionally.
|
|
68
|
+
* Example: 5 from [0,10] to [0,100] → 50, 0.5 from [0,1] to [-10,10] → 0
|
|
53
69
|
* @param inputs one number and operator action
|
|
54
70
|
* @returns Result of mapping
|
|
55
71
|
* @group operations
|
|
@@ -58,7 +74,8 @@ export declare class MathBitByBit {
|
|
|
58
74
|
*/
|
|
59
75
|
remap(inputs: Inputs.Math.RemapNumberDto): number;
|
|
60
76
|
/**
|
|
61
|
-
*
|
|
77
|
+
* Generates a random decimal number between 0 (inclusive) and 1 (exclusive).
|
|
78
|
+
* Example: Outputs like 0.342, 0.891, or any value in [0, 1)
|
|
62
79
|
* @returns A random number between 0 and 1
|
|
63
80
|
* @group generate
|
|
64
81
|
* @shortname random 0 - 1
|
|
@@ -66,7 +83,8 @@ export declare class MathBitByBit {
|
|
|
66
83
|
*/
|
|
67
84
|
random(): number;
|
|
68
85
|
/**
|
|
69
|
-
*
|
|
86
|
+
* Generates a random number within a specified range (low to high).
|
|
87
|
+
* Example: Range [0, 10] → outputs like 3.7, 8.2, or any value between 0 and 10
|
|
70
88
|
* @param inputs low and high numbers
|
|
71
89
|
* @returns A random number
|
|
72
90
|
* @group generate
|
|
@@ -75,7 +93,8 @@ export declare class MathBitByBit {
|
|
|
75
93
|
*/
|
|
76
94
|
randomNumber(inputs: Inputs.Math.RandomNumberDto): number;
|
|
77
95
|
/**
|
|
78
|
-
*
|
|
96
|
+
* Generates multiple random numbers within a specified range.
|
|
97
|
+
* Example: Range [0, 10] with 3 items → [2.5, 7.1, 4.8]
|
|
79
98
|
* @param inputs low and high numbers
|
|
80
99
|
* @returns A list of random numbers
|
|
81
100
|
* @group generate
|
|
@@ -84,7 +103,8 @@ export declare class MathBitByBit {
|
|
|
84
103
|
*/
|
|
85
104
|
randomNumbers(inputs: Inputs.Math.RandomNumbersDto): number[];
|
|
86
105
|
/**
|
|
87
|
-
*
|
|
106
|
+
* Returns the mathematical constant π (pi) ≈ 3.14159.
|
|
107
|
+
* Example: Outputs 3.141592653589793
|
|
88
108
|
* @returns A number PI
|
|
89
109
|
* @group generate
|
|
90
110
|
* @shortname π
|
|
@@ -92,7 +112,8 @@ export declare class MathBitByBit {
|
|
|
92
112
|
*/
|
|
93
113
|
pi(): number;
|
|
94
114
|
/**
|
|
95
|
-
*
|
|
115
|
+
* Formats a number as a string with a fixed number of decimal places (always shows trailing zeros).
|
|
116
|
+
* Example: 3.14159 with 2 decimals → '3.14', 5 with 3 decimals → '5.000'
|
|
96
117
|
* @param inputs a number to be rounded to decimal places
|
|
97
118
|
* @returns number
|
|
98
119
|
* @group operations
|
|
@@ -101,7 +122,8 @@ export declare class MathBitByBit {
|
|
|
101
122
|
*/
|
|
102
123
|
toFixed(inputs: Inputs.Math.ToFixedDto): string;
|
|
103
124
|
/**
|
|
104
|
-
* Adds two numbers
|
|
125
|
+
* Adds two numbers together.
|
|
126
|
+
* Example: 5 + 3 → 8, -2 + 7 → 5
|
|
105
127
|
* @param inputs two numbers
|
|
106
128
|
* @returns number
|
|
107
129
|
* @group basics
|
|
@@ -110,7 +132,8 @@ export declare class MathBitByBit {
|
|
|
110
132
|
*/
|
|
111
133
|
add(inputs: Inputs.Math.TwoNumbersDto): number;
|
|
112
134
|
/**
|
|
113
|
-
* Subtracts
|
|
135
|
+
* Subtracts the second number from the first.
|
|
136
|
+
* Example: 10 - 3 → 7, 5 - 8 → -3
|
|
114
137
|
* @param inputs two numbers
|
|
115
138
|
* @returns number
|
|
116
139
|
* @group basics
|
|
@@ -119,7 +142,8 @@ export declare class MathBitByBit {
|
|
|
119
142
|
*/
|
|
120
143
|
subtract(inputs: Inputs.Math.TwoNumbersDto): number;
|
|
121
144
|
/**
|
|
122
|
-
* Multiplies two numbers
|
|
145
|
+
* Multiplies two numbers together.
|
|
146
|
+
* Example: 5 × 3 → 15, -2 × 4 → -8
|
|
123
147
|
* @param inputs two numbers
|
|
124
148
|
* @returns number
|
|
125
149
|
* @group basics
|
|
@@ -128,7 +152,8 @@ export declare class MathBitByBit {
|
|
|
128
152
|
*/
|
|
129
153
|
multiply(inputs: Inputs.Math.TwoNumbersDto): number;
|
|
130
154
|
/**
|
|
131
|
-
* Divides
|
|
155
|
+
* Divides the first number by the second.
|
|
156
|
+
* Example: 10 ÷ 2 → 5, 7 ÷ 2 → 3.5
|
|
132
157
|
* @param inputs two numbers
|
|
133
158
|
* @returns number
|
|
134
159
|
* @group basics
|
|
@@ -137,7 +162,8 @@ export declare class MathBitByBit {
|
|
|
137
162
|
*/
|
|
138
163
|
divide(inputs: Inputs.Math.TwoNumbersDto): number;
|
|
139
164
|
/**
|
|
140
|
-
*
|
|
165
|
+
* Raises the first number to the power of the second (exponentiation).
|
|
166
|
+
* Example: 2³ → 8, 5² → 25, 10⁻¹ → 0.1
|
|
141
167
|
* @param inputs two numbers
|
|
142
168
|
* @returns number
|
|
143
169
|
* @group basics
|
|
@@ -146,7 +172,8 @@ export declare class MathBitByBit {
|
|
|
146
172
|
*/
|
|
147
173
|
power(inputs: Inputs.Math.TwoNumbersDto): number;
|
|
148
174
|
/**
|
|
149
|
-
*
|
|
175
|
+
* Calculates the square root of a number.
|
|
176
|
+
* Example: √9 → 3, √2 → 1.414, √16 → 4
|
|
150
177
|
* @param inputs a number
|
|
151
178
|
* @returns number
|
|
152
179
|
* @group basics
|
|
@@ -155,7 +182,8 @@ export declare class MathBitByBit {
|
|
|
155
182
|
*/
|
|
156
183
|
sqrt(inputs: Inputs.Math.NumberDto): number;
|
|
157
184
|
/**
|
|
158
|
-
*
|
|
185
|
+
* Returns the absolute value (removes negative sign, always positive or zero).
|
|
186
|
+
* Example: |-5| → 5, |3| → 3, |0| → 0
|
|
159
187
|
* @param inputs a number
|
|
160
188
|
* @returns number
|
|
161
189
|
* @group basics
|
|
@@ -164,7 +192,8 @@ export declare class MathBitByBit {
|
|
|
164
192
|
*/
|
|
165
193
|
abs(inputs: Inputs.Math.NumberDto): number;
|
|
166
194
|
/**
|
|
167
|
-
* Rounds a number
|
|
195
|
+
* Rounds a number to the nearest integer.
|
|
196
|
+
* Example: 3.7 → 4, 2.3 → 2, 5.5 → 6
|
|
168
197
|
* @param inputs a number
|
|
169
198
|
* @returns number
|
|
170
199
|
* @group basics
|
|
@@ -173,7 +202,8 @@ export declare class MathBitByBit {
|
|
|
173
202
|
*/
|
|
174
203
|
round(inputs: Inputs.Math.NumberDto): number;
|
|
175
204
|
/**
|
|
176
|
-
*
|
|
205
|
+
* Rounds a number down to the nearest integer (toward negative infinity).
|
|
206
|
+
* Example: 3.7 → 3, -2.3 → -3, 5 → 5
|
|
177
207
|
* @param inputs a number
|
|
178
208
|
* @returns number
|
|
179
209
|
* @group basics
|
|
@@ -182,7 +212,8 @@ export declare class MathBitByBit {
|
|
|
182
212
|
*/
|
|
183
213
|
floor(inputs: Inputs.Math.NumberDto): number;
|
|
184
214
|
/**
|
|
185
|
-
*
|
|
215
|
+
* Rounds a number up to the nearest integer (toward positive infinity).
|
|
216
|
+
* Example: 3.2 → 4, -2.8 → -2, 5 → 5
|
|
186
217
|
* @param inputs a number
|
|
187
218
|
* @returns number
|
|
188
219
|
* @group basics
|
|
@@ -191,7 +222,8 @@ export declare class MathBitByBit {
|
|
|
191
222
|
*/
|
|
192
223
|
ceil(inputs: Inputs.Math.NumberDto): number;
|
|
193
224
|
/**
|
|
194
|
-
* Negates a number
|
|
225
|
+
* Negates a number (flips its sign: positive becomes negative, negative becomes positive).
|
|
226
|
+
* Example: 5 → -5, -3 → 3, 0 → 0
|
|
195
227
|
* @param inputs a number
|
|
196
228
|
* @returns number
|
|
197
229
|
* @group basics
|
|
@@ -200,7 +232,8 @@ export declare class MathBitByBit {
|
|
|
200
232
|
*/
|
|
201
233
|
negate(inputs: Inputs.Math.NumberDto): number;
|
|
202
234
|
/**
|
|
203
|
-
*
|
|
235
|
+
* Calculates the natural logarithm (base e) of a number.
|
|
236
|
+
* Example: ln(2.718) → ~1, ln(7.389) → ~2, ln(1) → 0
|
|
204
237
|
* @param inputs a number
|
|
205
238
|
* @returns number
|
|
206
239
|
* @group basics
|
|
@@ -209,7 +242,8 @@ export declare class MathBitByBit {
|
|
|
209
242
|
*/
|
|
210
243
|
ln(inputs: Inputs.Math.NumberDto): number;
|
|
211
244
|
/**
|
|
212
|
-
*
|
|
245
|
+
* Calculates the base 10 logarithm of a number.
|
|
246
|
+
* Example: log₁₀(100) → 2, log₁₀(1000) → 3, log₁₀(10) → 1
|
|
213
247
|
* @param inputs a number
|
|
214
248
|
* @returns number
|
|
215
249
|
* @group basics
|
|
@@ -218,7 +252,8 @@ export declare class MathBitByBit {
|
|
|
218
252
|
*/
|
|
219
253
|
log10(inputs: Inputs.Math.NumberDto): number;
|
|
220
254
|
/**
|
|
221
|
-
* Raises 10 to the power of
|
|
255
|
+
* Raises 10 to the power of the input number.
|
|
256
|
+
* Example: 10² → 100, 10³ → 1000, 10⁻¹ → 0.1
|
|
222
257
|
* @param inputs a number
|
|
223
258
|
* @returns number
|
|
224
259
|
* @group basics
|
|
@@ -227,7 +262,8 @@ export declare class MathBitByBit {
|
|
|
227
262
|
*/
|
|
228
263
|
tenPow(inputs: Inputs.Math.NumberDto): number;
|
|
229
264
|
/**
|
|
230
|
-
*
|
|
265
|
+
* Calculates the sine of an angle in radians.
|
|
266
|
+
* Example: sin(0) → 0, sin(π/2) → 1, sin(π) → ~0
|
|
231
267
|
* @param inputs a number
|
|
232
268
|
* @returns number
|
|
233
269
|
* @group basics
|
|
@@ -236,7 +272,8 @@ export declare class MathBitByBit {
|
|
|
236
272
|
*/
|
|
237
273
|
sin(inputs: Inputs.Math.NumberDto): number;
|
|
238
274
|
/**
|
|
239
|
-
*
|
|
275
|
+
* Calculates the cosine of an angle in radians.
|
|
276
|
+
* Example: cos(0) → 1, cos(π/2) → ~0, cos(π) → -1
|
|
240
277
|
* @param inputs a number
|
|
241
278
|
* @returns number
|
|
242
279
|
* @group basics
|
|
@@ -245,7 +282,8 @@ export declare class MathBitByBit {
|
|
|
245
282
|
*/
|
|
246
283
|
cos(inputs: Inputs.Math.NumberDto): number;
|
|
247
284
|
/**
|
|
248
|
-
*
|
|
285
|
+
* Calculates the tangent of an angle in radians.
|
|
286
|
+
* Example: tan(0) → 0, tan(π/4) → ~1, tan(π/2) → infinity
|
|
249
287
|
* @param inputs a number
|
|
250
288
|
* @returns number
|
|
251
289
|
* @group basics
|
|
@@ -254,7 +292,8 @@ export declare class MathBitByBit {
|
|
|
254
292
|
*/
|
|
255
293
|
tan(inputs: Inputs.Math.NumberDto): number;
|
|
256
294
|
/**
|
|
257
|
-
*
|
|
295
|
+
* Calculates the arcsine (inverse sine) in radians, returns angle whose sine is the input.
|
|
296
|
+
* Example: asin(0) → 0, asin(1) → π/2 (~1.57), asin(0.5) → π/6 (~0.524)
|
|
258
297
|
* @param inputs a number
|
|
259
298
|
* @returns number
|
|
260
299
|
* @group basics
|
|
@@ -263,7 +302,8 @@ export declare class MathBitByBit {
|
|
|
263
302
|
*/
|
|
264
303
|
asin(inputs: Inputs.Math.NumberDto): number;
|
|
265
304
|
/**
|
|
266
|
-
*
|
|
305
|
+
* Calculates the arccosine (inverse cosine) in radians, returns angle whose cosine is the input.
|
|
306
|
+
* Example: acos(1) → 0, acos(0) → π/2 (~1.57), acos(-1) → π (~3.14)
|
|
267
307
|
* @param inputs a number
|
|
268
308
|
* @returns number
|
|
269
309
|
* @group basics
|
|
@@ -272,7 +312,8 @@ export declare class MathBitByBit {
|
|
|
272
312
|
*/
|
|
273
313
|
acos(inputs: Inputs.Math.NumberDto): number;
|
|
274
314
|
/**
|
|
275
|
-
*
|
|
315
|
+
* Calculates the arctangent (inverse tangent) in radians, returns angle whose tangent is the input.
|
|
316
|
+
* Example: atan(0) → 0, atan(1) → π/4 (~0.785), atan(-1) → -π/4
|
|
276
317
|
* @param inputs a number
|
|
277
318
|
* @returns number
|
|
278
319
|
* @group basics
|
|
@@ -281,7 +322,8 @@ export declare class MathBitByBit {
|
|
|
281
322
|
*/
|
|
282
323
|
atan(inputs: Inputs.Math.NumberDto): number;
|
|
283
324
|
/**
|
|
284
|
-
*
|
|
325
|
+
* Calculates e raised to the power of the input (exponential function).
|
|
326
|
+
* Example: e⁰ → 1, e¹ → ~2.718, e² → ~7.389
|
|
285
327
|
* @param inputs a number
|
|
286
328
|
* @returns number
|
|
287
329
|
* @group basics
|
|
@@ -290,7 +332,8 @@ export declare class MathBitByBit {
|
|
|
290
332
|
*/
|
|
291
333
|
exp(inputs: Inputs.Math.NumberDto): number;
|
|
292
334
|
/**
|
|
293
|
-
* Converts degrees to radians
|
|
335
|
+
* Converts an angle from degrees to radians.
|
|
336
|
+
* Example: 180° → π (~3.14159), 90° → π/2 (~1.5708), 360° → 2π
|
|
294
337
|
* @param inputs a number in degrees
|
|
295
338
|
* @returns number
|
|
296
339
|
* @group basics
|
|
@@ -299,7 +342,8 @@ export declare class MathBitByBit {
|
|
|
299
342
|
*/
|
|
300
343
|
degToRad(inputs: Inputs.Math.NumberDto): number;
|
|
301
344
|
/**
|
|
302
|
-
* Converts radians to degrees
|
|
345
|
+
* Converts an angle from radians to degrees.
|
|
346
|
+
* Example: π → 180°, π/2 → 90°, 2π → 360°
|
|
303
347
|
* @param inputs a number in radians
|
|
304
348
|
* @returns number
|
|
305
349
|
* @group basics
|
|
@@ -308,7 +352,9 @@ export declare class MathBitByBit {
|
|
|
308
352
|
*/
|
|
309
353
|
radToDeg(inputs: Inputs.Math.NumberDto): number;
|
|
310
354
|
/**
|
|
311
|
-
*
|
|
355
|
+
* Applies an easing function to interpolate smoothly between min and max values.
|
|
356
|
+
* Example: x=0.5 from [0,100] with easeInQuad → applies quadratic acceleration curve
|
|
357
|
+
* Useful for smooth animations with various acceleration/deceleration curves.
|
|
312
358
|
* @param inputs a number, min and max values, and ease type
|
|
313
359
|
* @returns number
|
|
314
360
|
* @group operations
|
|
@@ -316,6 +362,105 @@ export declare class MathBitByBit {
|
|
|
316
362
|
* @drawable false
|
|
317
363
|
*/
|
|
318
364
|
ease(inputs: Inputs.Math.EaseDto): number;
|
|
365
|
+
/**
|
|
366
|
+
* Constrains a value between a minimum and maximum value.
|
|
367
|
+
* Example: clamp(5, 0, 3) returns 3, clamp(-1, 0, 3) returns 0, clamp(1.5, 0, 3) returns 1.5
|
|
368
|
+
* @param inputs a number, min and max values
|
|
369
|
+
* @returns number clamped between min and max
|
|
370
|
+
* @group operations
|
|
371
|
+
* @shortname clamp
|
|
372
|
+
* @drawable false
|
|
373
|
+
*/
|
|
374
|
+
clamp(inputs: Inputs.Math.ClampDto): number;
|
|
375
|
+
/**
|
|
376
|
+
* Linear interpolation between two values using parameter t (0 to 1).
|
|
377
|
+
* Example: From 0 to 100 at t=0.5 → 50, From 10 to 20 at t=0.25 → 12.5
|
|
378
|
+
* When t=0 returns start, when t=1 returns end. Useful for smooth transitions.
|
|
379
|
+
* @param inputs start value, end value, and interpolation parameter t
|
|
380
|
+
* @returns interpolated value
|
|
381
|
+
* @group operations
|
|
382
|
+
* @shortname lerp
|
|
383
|
+
* @drawable false
|
|
384
|
+
*/
|
|
385
|
+
lerp(inputs: Inputs.Math.LerpDto): number;
|
|
386
|
+
/**
|
|
387
|
+
* Calculates the interpolation parameter t for a value between start and end (reverse of lerp).
|
|
388
|
+
* Example: Value 5 in range [0,10] → t=0.5, Value 2.5 in range [0,10] → t=0.25
|
|
389
|
+
* Returns what t value would produce the given value in a lerp. Useful for finding relative position.
|
|
390
|
+
* @param inputs start value, end value, and the value to find t for
|
|
391
|
+
* @returns interpolation parameter (typically 0-1)
|
|
392
|
+
* @group operations
|
|
393
|
+
* @shortname inverse lerp
|
|
394
|
+
* @drawable false
|
|
395
|
+
*/
|
|
396
|
+
inverseLerp(inputs: Inputs.Math.InverseLerpDto): number;
|
|
397
|
+
/**
|
|
398
|
+
* Hermite interpolation with smooth acceleration and deceleration (smoother than linear lerp).
|
|
399
|
+
* Example: x=0 → 0, x=0.5 → 0.5, x=1 → 1 (but with smooth S-curve in between)
|
|
400
|
+
* Input is automatically clamped to [0,1]. Output eases in and out smoothly. Great for animations.
|
|
401
|
+
* @param inputs a number between 0 and 1
|
|
402
|
+
* @returns smoothly interpolated value
|
|
403
|
+
* @group operations
|
|
404
|
+
* @shortname smoothstep
|
|
405
|
+
* @drawable false
|
|
406
|
+
*/
|
|
407
|
+
smoothstep(inputs: Inputs.Math.NumberDto): number;
|
|
408
|
+
/**
|
|
409
|
+
* Returns the sign of a number: -1 for negative, 0 for zero, 1 for positive.
|
|
410
|
+
* Example: -5 → -1, 0 → 0, 3.14 → 1
|
|
411
|
+
* Useful for determining direction or polarity.
|
|
412
|
+
* @param inputs a number
|
|
413
|
+
* @returns -1, 0, or 1
|
|
414
|
+
* @group operations
|
|
415
|
+
* @shortname sign
|
|
416
|
+
* @drawable false
|
|
417
|
+
*/
|
|
418
|
+
sign(inputs: Inputs.Math.NumberDto): number;
|
|
419
|
+
/**
|
|
420
|
+
* Returns the fractional part of a number (removes integer part, keeps decimals).
|
|
421
|
+
* Example: 3.14 → 0.14, 5.9 → 0.9, -2.3 → 0.7
|
|
422
|
+
* Useful for wrapping values and creating repeating patterns.
|
|
423
|
+
* @param inputs a number
|
|
424
|
+
* @returns fractional part (always positive)
|
|
425
|
+
* @group operations
|
|
426
|
+
* @shortname fract
|
|
427
|
+
* @drawable false
|
|
428
|
+
*/
|
|
429
|
+
fract(inputs: Inputs.Math.NumberDto): number;
|
|
430
|
+
/**
|
|
431
|
+
* Wraps a number within a specified range (creates repeating cycle).
|
|
432
|
+
* Example: 1.5 in range [0,1) → 0.5, -0.3 in range [0,1) → 0.7, 370° in range [0,360) → 10°
|
|
433
|
+
* Useful for angles, UVs, or any repeating domain. Like modulo but handles negatives properly.
|
|
434
|
+
* @param inputs a number, min and max values
|
|
435
|
+
* @returns wrapped value within range
|
|
436
|
+
* @group operations
|
|
437
|
+
* @shortname wrap
|
|
438
|
+
* @drawable false
|
|
439
|
+
*/
|
|
440
|
+
wrap(inputs: Inputs.Math.WrapDto): number;
|
|
441
|
+
/**
|
|
442
|
+
* Creates a ping-pong (back-and-forth) effect that bounces a value between 0 and length.
|
|
443
|
+
* The value goes from 0→length, then back length→0, repeating this cycle.
|
|
444
|
+
* Example: With length=1: t=0→0, t=0.5→0.5, t=1→1 (peak), t=1.5→0.5, t=2→0, t=2.5→0.5 (repeats)
|
|
445
|
+
* Useful for creating bouncing animations like a ball or oscillating motion.
|
|
446
|
+
* @param inputs time value t and length
|
|
447
|
+
* @returns value bouncing between 0 and length
|
|
448
|
+
* @group operations
|
|
449
|
+
* @shortname ping pong
|
|
450
|
+
* @drawable false
|
|
451
|
+
*/
|
|
452
|
+
pingPong(inputs: Inputs.Math.PingPongDto): number;
|
|
453
|
+
/**
|
|
454
|
+
* Moves a value toward a target by a maximum delta amount (never overshooting).
|
|
455
|
+
* Example: From 0 toward 10 by max 3 → 3, From 8 toward 10 by max 3 → 10 (reached)
|
|
456
|
+
* Useful for smooth movement with maximum speed limits.
|
|
457
|
+
* @param inputs current value, target value, and maximum delta
|
|
458
|
+
* @returns new value moved toward target
|
|
459
|
+
* @group operations
|
|
460
|
+
* @shortname move towards
|
|
461
|
+
* @drawable false
|
|
462
|
+
*/
|
|
463
|
+
moveTowards(inputs: Inputs.Math.MoveTowardsDto): number;
|
|
319
464
|
private easeInSine;
|
|
320
465
|
private easeOutSine;
|
|
321
466
|
private easeInOutSine;
|