@bitbybit-dev/base 0.20.13 → 0.21.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.
Files changed (38) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/lists-inputs.d.ts +39 -0
  3. package/lib/api/inputs/lists-inputs.js +43 -0
  4. package/lib/api/inputs/math-inputs.d.ts +154 -0
  5. package/lib/api/inputs/math-inputs.js +217 -0
  6. package/lib/api/inputs/text-inputs.d.ts +139 -0
  7. package/lib/api/inputs/text-inputs.js +215 -0
  8. package/lib/api/inputs/vector-inputs.d.ts +8 -0
  9. package/lib/api/inputs/vector-inputs.js +8 -0
  10. package/lib/api/services/color.d.ts +27 -12
  11. package/lib/api/services/color.js +27 -12
  12. package/lib/api/services/dates.d.ts +62 -30
  13. package/lib/api/services/dates.js +62 -30
  14. package/lib/api/services/geometry-helper.d.ts +50 -0
  15. package/lib/api/services/geometry-helper.js +50 -2
  16. package/lib/api/services/helpers/dxf/dxf.d.ts +19 -9
  17. package/lib/api/services/helpers/dxf/dxf.js +19 -9
  18. package/lib/api/services/line.d.ts +34 -16
  19. package/lib/api/services/line.js +34 -16
  20. package/lib/api/services/lists.d.ts +175 -32
  21. package/lib/api/services/lists.js +275 -32
  22. package/lib/api/services/logic.d.ts +24 -13
  23. package/lib/api/services/logic.js +24 -13
  24. package/lib/api/services/math.d.ts +180 -35
  25. package/lib/api/services/math.js +215 -35
  26. package/lib/api/services/mesh.d.ts +17 -6
  27. package/lib/api/services/mesh.js +17 -6
  28. package/lib/api/services/point.d.ts +63 -32
  29. package/lib/api/services/point.js +63 -32
  30. package/lib/api/services/polyline.d.ts +27 -11
  31. package/lib/api/services/polyline.js +27 -11
  32. package/lib/api/services/text.d.ts +286 -7
  33. package/lib/api/services/text.js +350 -7
  34. package/lib/api/services/transforms.d.ts +30 -16
  35. package/lib/api/services/transforms.js +30 -16
  36. package/lib/api/services/vector.d.ts +85 -38
  37. package/lib/api/services/vector.js +87 -38
  38. package/package.json +1 -1
@@ -11,7 +11,8 @@ export declare class Vector {
11
11
  private readonly geometryHelper;
12
12
  constructor(math: MathBitByBit, geometryHelper: GeometryHelper);
13
13
  /**
14
- * Removes all duplicate vectors from the input array
14
+ * Removes all duplicate vectors from the input array (keeps only unique vectors).
15
+ * Example: [[1,2,3], [4,5,6], [1,2,3], [7,8,9]] → [[1,2,3], [4,5,6], [7,8,9]]
15
16
  * @param inputs Contains vectors and a tolerance value
16
17
  * @returns Array of vectors without duplicates
17
18
  * @group remove
@@ -20,7 +21,8 @@ export declare class Vector {
20
21
  */
21
22
  removeAllDuplicateVectors(inputs: Inputs.Vector.RemoveAllDuplicateVectorsDto): number[][];
22
23
  /**
23
- * Removes consecutive duplicate vectors from the input array
24
+ * Removes consecutive duplicate vectors from the input array (only removes duplicates that appear next to each other).
25
+ * Example: [[1,2], [1,2], [3,4], [1,2]] → [[1,2], [3,4], [1,2]] (only removed consecutive duplicate)
24
26
  * @param inputs Contains vectors and a tolerance value
25
27
  * @returns Array of vectors without duplicates
26
28
  * @group remove
@@ -29,7 +31,8 @@ export declare class Vector {
29
31
  */
30
32
  removeConsecutiveDuplicateVectors(inputs: Inputs.Vector.RemoveConsecutiveDuplicateVectorsDto): number[][];
31
33
  /**
32
- * Checks if two vectors are the same within a given tolerance
34
+ * Checks if two vectors are the same within a given tolerance (accounts for floating point precision).
35
+ * Example: [1,2,3] vs [1.0001,2.0001,3.0001] with tolerance 0.001 → true
33
36
  * @param inputs Contains two vectors and a tolerance value
34
37
  * @returns Boolean indicating if vectors are the same
35
38
  * @group validate
@@ -38,7 +41,8 @@ export declare class Vector {
38
41
  */
39
42
  vectorsTheSame(inputs: Inputs.Vector.VectorsTheSameDto): boolean;
40
43
  /**
41
- * Measures the angle between two vectors in degrees
44
+ * Measures the angle between two vectors in degrees (always returns positive angle 0-180°).
45
+ * Example: [1,0,0] and [0,1,0] → 90° (perpendicular vectors)
42
46
  * @param inputs Contains two vectors represented as number arrays
43
47
  * @group angles
44
48
  * @shortname angle
@@ -47,7 +51,8 @@ export declare class Vector {
47
51
  */
48
52
  angleBetween(inputs: Inputs.Vector.TwoVectorsDto): number;
49
53
  /**
50
- * Measures the normalized 2d angle between two vectors in degrees
54
+ * Measures the normalized 2D angle between two vectors in degrees (considers direction, can be negative).
55
+ * Example: [1,0] to [0,1] → 90°, [0,1] to [1,0] → -90°
51
56
  * @param inputs Contains two vectors represented as number arrays
52
57
  * @returns Number in degrees
53
58
  * @group angles
@@ -56,7 +61,8 @@ export declare class Vector {
56
61
  */
57
62
  angleBetweenNormalized2d(inputs: Inputs.Vector.TwoVectorsDto): number;
58
63
  /**
59
- * Measures a positive angle between two vectors given the reference vector in degrees
64
+ * Measures a positive angle between two vectors given the reference vector in degrees (always 0-360°).
65
+ * Example: converts negative signed angles to positive by adding 360° when needed
60
66
  * @param inputs Contains information of two vectors and a reference vector
61
67
  * @returns Number in degrees
62
68
  * @group angles
@@ -65,7 +71,8 @@ export declare class Vector {
65
71
  */
66
72
  positiveAngleBetween(inputs: Inputs.Vector.TwoVectorsReferenceDto): number;
67
73
  /**
68
- * Adds all vector xyz values together and create a new vector
74
+ * Adds all vector xyz values together element-wise and creates a new vector.
75
+ * Example: [[1,2,3], [4,5,6], [7,8,9]] → [12,15,18] (sums each column)
69
76
  * @param inputs Vectors to be added
70
77
  * @returns New vector that has xyz values as sums of all the vectors
71
78
  * @group sum
@@ -74,7 +81,8 @@ export declare class Vector {
74
81
  */
75
82
  addAll(inputs: Inputs.Vector.VectorsDto): number[];
76
83
  /**
77
- * Adds two vectors together
84
+ * Adds two vectors together element-wise.
85
+ * Example: [1,2,3] + [4,5,6] → [5,7,9]
78
86
  * @param inputs Two vectors to be added
79
87
  * @returns Number array representing vector
80
88
  * @group sum
@@ -83,7 +91,8 @@ export declare class Vector {
83
91
  */
84
92
  add(inputs: Inputs.Vector.TwoVectorsDto): number[];
85
93
  /**
86
- * Checks if the boolean array contains only true values, if there's a single false it will return false.
94
+ * Checks if the boolean array contains only true values, returns false if there's a single false.
95
+ * Example: [true, true, true] → true, [true, false, true] → false
87
96
  * @param inputs Vectors to be checked
88
97
  * @returns Boolean indicating if vector contains only true values
89
98
  * @group sum
@@ -92,16 +101,18 @@ export declare class Vector {
92
101
  */
93
102
  all(inputs: Inputs.Vector.VectorBoolDto): boolean;
94
103
  /**
95
- * Cross two vectors
104
+ * Computes the cross product of two 3D vectors (perpendicular vector to both inputs).
105
+ * Example: [1,0,0] × [0,1,0] → [0,0,1] (right-hand rule)
96
106
  * @param inputs Two vectors to be crossed
97
107
  * @group base
98
- * @shortname all
108
+ * @shortname cross
99
109
  * @returns Crossed vector
100
110
  * @drawable false
101
111
  */
102
112
  cross(inputs: Inputs.Vector.TwoVectorsDto): number[];
103
113
  /**
104
- * Squared distance between two vectors
114
+ * Calculates squared distance between two vectors (faster than distance, avoids sqrt).
115
+ * Example: [0,0,0] to [3,4,0] → 25 (distance 5 squared)
105
116
  * @param inputs Two vectors
106
117
  * @returns Number representing squared distance between two vectors
107
118
  * @group distance
@@ -110,7 +121,8 @@ export declare class Vector {
110
121
  */
111
122
  distSquared(inputs: Inputs.Vector.TwoVectorsDto): number;
112
123
  /**
113
- * Distance between two vectors
124
+ * Calculates the Euclidean distance between two vectors.
125
+ * Example: [0,0,0] to [3,4,0] → 5, [1,1] to [4,5] → 5
114
126
  * @param inputs Two vectors
115
127
  * @returns Number representing distance between two vectors
116
128
  * @group distance
@@ -119,7 +131,8 @@ export declare class Vector {
119
131
  */
120
132
  dist(inputs: Inputs.Vector.TwoVectorsDto): number;
121
133
  /**
122
- * Divide the vector by a scalar value
134
+ * Divides each element of the vector by a scalar value.
135
+ * Example: [10,20,30] ÷ 2 → [5,10,15]
123
136
  * @param inputs Contains vector and a scalar
124
137
  * @returns Vector that is a result of division by a scalar
125
138
  * @group base
@@ -128,7 +141,8 @@ export declare class Vector {
128
141
  */
129
142
  div(inputs: Inputs.Vector.VectorScalarDto): number[];
130
143
  /**
131
- * Computes the domain between minimum and maximum values of the vector
144
+ * Computes the domain (range) between minimum and maximum values of the vector.
145
+ * Example: [1,3,5,9] → 8 (difference between last and first: 9-1)
132
146
  * @param inputs Vector information
133
147
  * @returns Number representing distance between two vectors
134
148
  * @group base
@@ -137,7 +151,8 @@ export declare class Vector {
137
151
  */
138
152
  domain(inputs: Inputs.Vector.VectorDto): number;
139
153
  /**
140
- * Dot product between two vectors
154
+ * Calculates the dot product between two vectors (measures similarity/projection).
155
+ * Example: [1,2,3] • [4,5,6] → 32 (1×4 + 2×5 + 3×6), perpendicular vectors → 0
141
156
  * @param inputs Two vectors
142
157
  * @returns Number representing dot product of the vector
143
158
  * @group base
@@ -146,7 +161,8 @@ export declare class Vector {
146
161
  */
147
162
  dot(inputs: Inputs.Vector.TwoVectorsDto): number;
148
163
  /**
149
- * Checks if vector is finite for each number and returns a boolean array
164
+ * Checks if each element in the vector is finite and returns a boolean array.
165
+ * Example: [1, 2, Infinity, 3] → [true, true, false, true]
150
166
  * @param inputs Vector with possibly infinite values
151
167
  * @returns Vector array that contains boolean values for each number in the input
152
168
  * vector that identifies if value is finite (true) or infinite (false)
@@ -156,7 +172,8 @@ export declare class Vector {
156
172
  */
157
173
  finite(inputs: Inputs.Vector.VectorDto): boolean[];
158
174
  /**
159
- * Checks if the vector is zero length
175
+ * Checks if the vector has zero length (all elements are zero).
176
+ * Example: [0,0,0] → true, [0,0,0.001] → false
160
177
  * @param inputs Vector to be checked
161
178
  * @returns Boolean that identifies if vector is zero length
162
179
  * @group validate
@@ -165,7 +182,8 @@ export declare class Vector {
165
182
  */
166
183
  isZero(inputs: Inputs.Vector.VectorDto): boolean;
167
184
  /**
168
- * Finds in between vector between two vectors by providing a fracture
185
+ * Finds an interpolated vector between two vectors using a fraction (linear interpolation).
186
+ * Example: [0,0,0] to [10,10,10] at 0.5 → [5,5,5], fraction=0 → first, fraction=1 → second
169
187
  * @param inputs Information for finding vector between two vectors using a fraction
170
188
  * @returns Vector that is in between two vectors
171
189
  * @group distance
@@ -174,7 +192,8 @@ export declare class Vector {
174
192
  */
175
193
  lerp(inputs: Inputs.Vector.FractionTwoVectorsDto): number[];
176
194
  /**
177
- * Finds the maximum value in the vector
195
+ * Finds the maximum (largest) value in the vector.
196
+ * Example: [3, 7, 2, 9, 1] → 9
178
197
  * @param inputs Vector to be checked
179
198
  * @returns Largest number in the vector
180
199
  * @group extract
@@ -183,7 +202,8 @@ export declare class Vector {
183
202
  */
184
203
  max(inputs: Inputs.Vector.VectorDto): number;
185
204
  /**
186
- * Finds the minimum value in the vector
205
+ * Finds the minimum (smallest) value in the vector.
206
+ * Example: [3, 7, 2, 9, 1] → 1
187
207
  * @param inputs Vector to be checked
188
208
  * @returns Lowest number in the vector
189
209
  * @group extract
@@ -192,7 +212,8 @@ export declare class Vector {
192
212
  */
193
213
  min(inputs: Inputs.Vector.VectorDto): number;
194
214
  /**
195
- * Multiple vector with the scalar
215
+ * Multiplies each element of the vector by a scalar value.
216
+ * Example: [2,3,4] × 5 → [10,15,20]
196
217
  * @param inputs Vector with a scalar
197
218
  * @returns Vector that results from multiplication
198
219
  * @group base
@@ -201,7 +222,8 @@ export declare class Vector {
201
222
  */
202
223
  mul(inputs: Inputs.Vector.VectorScalarDto): number[];
203
224
  /**
204
- * Negates the vector
225
+ * Negates the vector (flips the sign of each element).
226
+ * Example: [5,-3,2] → [-5,3,-2]
205
227
  * @param inputs Vector to negate
206
228
  * @returns Negative vector
207
229
  * @group base
@@ -210,7 +232,8 @@ export declare class Vector {
210
232
  */
211
233
  neg(inputs: Inputs.Vector.VectorDto): number[];
212
234
  /**
213
- * Compute squared norm
235
+ * Computes the squared norm (squared magnitude/length) of the vector.
236
+ * Example: [3,4,0] → 25 (length 5 squared)
214
237
  * @param inputs Vector for squared norm
215
238
  * @returns Number that is squared norm
216
239
  * @group base
@@ -219,7 +242,8 @@ export declare class Vector {
219
242
  */
220
243
  normSquared(inputs: Inputs.Vector.VectorDto): number;
221
244
  /**
222
- * Norm of the vector
245
+ * Calculates the norm (magnitude/length) of the vector.
246
+ * Example: [3,4,0] → 5, [1,0,0] → 1
223
247
  * @param inputs Vector to compute the norm
224
248
  * @returns Number that is norm of the vector
225
249
  * @group base
@@ -228,7 +252,8 @@ export declare class Vector {
228
252
  */
229
253
  norm(inputs: Inputs.Vector.VectorDto): number;
230
254
  /**
231
- * Normalize the vector into a unit vector, that has a length of 1
255
+ * Normalizes the vector into a unit vector that has a length of 1 (maintains direction, scales magnitude to 1).
256
+ * Example: [3,4,0] → [0.6,0.8,0], [10,0,0] → [1,0,0]
232
257
  * @param inputs Vector to normalize
233
258
  * @returns Unit vector that has length of 1
234
259
  * @group base
@@ -237,7 +262,8 @@ export declare class Vector {
237
262
  */
238
263
  normalized(inputs: Inputs.Vector.VectorDto): number[];
239
264
  /**
240
- * Finds a point coordinates on the given distance ray that spans between the point along the direction vector
265
+ * Finds a point on a ray at a given distance from the origin along the direction vector.
266
+ * Example: Point [0,0,0] + direction [1,0,0] at distance 5 → [5,0,0]
241
267
  * @param inputs Provide a point, vector and a distance for finding a point
242
268
  * @returns Vector representing point on the ray
243
269
  * @group base
@@ -246,7 +272,8 @@ export declare class Vector {
246
272
  */
247
273
  onRay(inputs: Inputs.Vector.RayPointDto): number[];
248
274
  /**
249
- * Create a xyz vector
275
+ * Creates a 3D vector from x, y, z coordinates.
276
+ * Example: x=1, y=2, z=3 → [1,2,3]
250
277
  * @param inputs Vector coordinates
251
278
  * @returns Create a vector of xyz values
252
279
  * @group create
@@ -255,7 +282,8 @@ export declare class Vector {
255
282
  */
256
283
  vectorXYZ(inputs: Inputs.Vector.VectorXYZDto): Inputs.Base.Vector3;
257
284
  /**
258
- * Create 2d xy vector
285
+ * Creates a 2D vector from x, y coordinates.
286
+ * Example: x=3, y=4 → [3,4]
259
287
  * @param inputs Vector coordinates
260
288
  * @returns Create a vector of xy values
261
289
  * @group create
@@ -264,7 +292,8 @@ export declare class Vector {
264
292
  */
265
293
  vectorXY(inputs: Inputs.Vector.VectorXYDto): Inputs.Base.Vector2;
266
294
  /**
267
- * Creates a vector of integers between 0 and maximum ceiling integer
295
+ * Creates a vector of integers from 0 to max (exclusive).
296
+ * Example: max=5 → [0,1,2,3,4], max=3 → [0,1,2]
268
297
  * @param inputs Max value for the range
269
298
  * @returns Vector containing items from 0 to max
270
299
  * @group create
@@ -273,7 +302,8 @@ export declare class Vector {
273
302
  */
274
303
  range(inputs: Inputs.Vector.RangeMaxDto): number[];
275
304
  /**
276
- * Computes signed angle between two vectors and a reference. This will always return a smaller angle between two possible angles.
305
+ * Computes signed angle between two vectors using a reference vector (determines rotation direction).
306
+ * Example: Returns positive or negative angle depending on rotation direction relative to reference
277
307
  * @param inputs Contains information of two vectors and a reference vector
278
308
  * @returns Signed angle in degrees
279
309
  * @group angles
@@ -282,7 +312,8 @@ export declare class Vector {
282
312
  */
283
313
  signedAngleBetween(inputs: Inputs.Vector.TwoVectorsReferenceDto): number;
284
314
  /**
285
- * Creates a vector that contains numbers spanning between minimum and maximum values at a given step
315
+ * Creates a vector containing numbers from min to max at a given step increment.
316
+ * Example: min=0, max=10, step=2 → [0,2,4,6,8,10]
286
317
  * @param inputs Span information containing min, max and step values
287
318
  * @returns Vector containing number between min, max and increasing at a given step
288
319
  * @group create
@@ -291,7 +322,8 @@ export declare class Vector {
291
322
  */
292
323
  span(inputs: Inputs.Vector.SpanDto): number[];
293
324
  /**
294
- * Creates a vector that contains numbers spanning between minimum and maximum values at a given ease function
325
+ * Creates a vector with numbers from min to max using an easing function for non-linear distribution.
326
+ * Example: min=0, max=100, nrItems=5, ease='easeInQuad' → creates accelerating intervals
295
327
  * @param inputs Span information containing min, max and ease function
296
328
  * @returns Vector containing numbers between min, max and increasing in non-linear steps defined by nr of items in the vector and type
297
329
  * @group create
@@ -300,7 +332,8 @@ export declare class Vector {
300
332
  */
301
333
  spanEaseItems(inputs: Inputs.Vector.SpanEaseItemsDto): number[];
302
334
  /**
303
- * Creates a vector that contains numbers spanning between minimum and maximum values by giving nr of items
335
+ * Creates a vector with evenly spaced numbers from min to max with a specified number of items.
336
+ * Example: min=0, max=10, nrItems=5 → [0, 2.5, 5, 7.5, 10]
304
337
  * @param inputs Span information containing min, max and step values
305
338
  * @returns Vector containing number between min, max by giving nr of items
306
339
  * @group create
@@ -309,7 +342,8 @@ export declare class Vector {
309
342
  */
310
343
  spanLinearItems(inputs: Inputs.Vector.SpanLinearItemsDto): number[];
311
344
  /**
312
- * Subtract two vectors
345
+ * Subtracts the second vector from the first element-wise.
346
+ * Example: [10,20,30] - [1,2,3] → [9,18,27]
313
347
  * @param inputs Two vectors
314
348
  * @returns Vector that result by subtraction two vectors
315
349
  * @group base
@@ -318,7 +352,8 @@ export declare class Vector {
318
352
  */
319
353
  sub(inputs: Inputs.Vector.TwoVectorsDto): number[];
320
354
  /**
321
- * Sums the values of the vector
355
+ * Sums all values in the vector and returns a single number.
356
+ * Example: [1,2,3,4] → 10, [5,10,15] → 30
322
357
  * @param inputs Vector to sum
323
358
  * @returns Number that results by adding up all values in the vector
324
359
  * @group base
@@ -327,7 +362,8 @@ export declare class Vector {
327
362
  */
328
363
  sum(inputs: Inputs.Vector.VectorDto): number;
329
364
  /**
330
- * Computes the squared length of the vector
365
+ * Computes the squared length (squared magnitude) of a 3D vector.
366
+ * Example: [3,4,0] → 25 (length 5 squared)
331
367
  * @param inputs Vector to compute the length
332
368
  * @returns Number that is squared length of the vector
333
369
  * @group base
@@ -336,7 +372,8 @@ export declare class Vector {
336
372
  */
337
373
  lengthSq(inputs: Inputs.Vector.Vector3Dto): number;
338
374
  /**
339
- * Computes the length of the vector
375
+ * Computes the length (magnitude) of a 3D vector.
376
+ * Example: [3,4,0] → 5, [1,0,0] → 1
340
377
  * @param inputs Vector to compute the length
341
378
  * @returns Number that is length of the vector
342
379
  * @group base
@@ -344,4 +381,14 @@ export declare class Vector {
344
381
  * @drawable false
345
382
  */
346
383
  length(inputs: Inputs.Vector.Vector3Dto): number;
384
+ /**
385
+ * Converts an array of stringified numbers to actual numbers.
386
+ * Example: ['1', '2.5', '3'] → [1, 2.5, 3], ['10', '-5', '0.1'] → [10, -5, 0.1]
387
+ * @param inputs Array of stringified numbers
388
+ * @returns Array of numbers
389
+ * @group create
390
+ * @shortname parse numbers
391
+ * @drawable false
392
+ */
393
+ parseNumbers(inputs: Inputs.Vector.VectorStringDto): number[];
347
394
  }