@bitbybit-dev/base 0.20.13 → 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
|
@@ -9,7 +9,8 @@ export class Vector {
|
|
|
9
9
|
this.geometryHelper = geometryHelper;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Removes all duplicate vectors from the input array
|
|
12
|
+
* Removes all duplicate vectors from the input array (keeps only unique vectors).
|
|
13
|
+
* Example: [[1,2,3], [4,5,6], [1,2,3], [7,8,9]] → [[1,2,3], [4,5,6], [7,8,9]]
|
|
13
14
|
* @param inputs Contains vectors and a tolerance value
|
|
14
15
|
* @returns Array of vectors without duplicates
|
|
15
16
|
* @group remove
|
|
@@ -20,7 +21,8 @@ export class Vector {
|
|
|
20
21
|
return this.geometryHelper.removeAllDuplicateVectors(inputs.vectors, inputs.tolerance);
|
|
21
22
|
}
|
|
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
|
|
@@ -31,7 +33,8 @@ export class Vector {
|
|
|
31
33
|
return this.geometryHelper.removeConsecutiveVectorDuplicates(inputs.vectors, inputs.checkFirstAndLast, inputs.tolerance);
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
|
-
* Checks if two vectors are the same within a given tolerance
|
|
36
|
+
* Checks if two vectors are the same within a given tolerance (accounts for floating point precision).
|
|
37
|
+
* Example: [1,2,3] vs [1.0001,2.0001,3.0001] with tolerance 0.001 → true
|
|
35
38
|
* @param inputs Contains two vectors and a tolerance value
|
|
36
39
|
* @returns Boolean indicating if vectors are the same
|
|
37
40
|
* @group validate
|
|
@@ -42,7 +45,8 @@ export class Vector {
|
|
|
42
45
|
return this.geometryHelper.vectorsTheSame(inputs.vec1, inputs.vec2, inputs.tolerance);
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
|
-
* Measures the angle between two vectors in degrees
|
|
48
|
+
* Measures the angle between two vectors in degrees (always returns positive angle 0-180°).
|
|
49
|
+
* Example: [1,0,0] and [0,1,0] → 90° (perpendicular vectors)
|
|
46
50
|
* @param inputs Contains two vectors represented as number arrays
|
|
47
51
|
* @group angles
|
|
48
52
|
* @shortname angle
|
|
@@ -55,7 +59,8 @@ export class Vector {
|
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
|
-
* Measures the normalized
|
|
62
|
+
* Measures the normalized 2D angle between two vectors in degrees (considers direction, can be negative).
|
|
63
|
+
* Example: [1,0] to [0,1] → 90°, [0,1] to [1,0] → -90°
|
|
59
64
|
* @param inputs Contains two vectors represented as number arrays
|
|
60
65
|
* @returns Number in degrees
|
|
61
66
|
* @group angles
|
|
@@ -69,7 +74,8 @@ export class Vector {
|
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
|
-
* Measures a positive angle between two vectors given the reference vector in degrees
|
|
77
|
+
* Measures a positive angle between two vectors given the reference vector in degrees (always 0-360°).
|
|
78
|
+
* Example: converts negative signed angles to positive by adding 360° when needed
|
|
73
79
|
* @param inputs Contains information of two vectors and a reference vector
|
|
74
80
|
* @returns Number in degrees
|
|
75
81
|
* @group angles
|
|
@@ -81,7 +87,8 @@ export class Vector {
|
|
|
81
87
|
return angle < 0 ? 360 + angle : angle;
|
|
82
88
|
}
|
|
83
89
|
/**
|
|
84
|
-
* Adds all vector xyz values together and
|
|
90
|
+
* Adds all vector xyz values together element-wise and creates a new vector.
|
|
91
|
+
* Example: [[1,2,3], [4,5,6], [7,8,9]] → [12,15,18] (sums each column)
|
|
85
92
|
* @param inputs Vectors to be added
|
|
86
93
|
* @returns New vector that has xyz values as sums of all the vectors
|
|
87
94
|
* @group sum
|
|
@@ -100,7 +107,8 @@ export class Vector {
|
|
|
100
107
|
return res;
|
|
101
108
|
}
|
|
102
109
|
/**
|
|
103
|
-
* Adds two vectors together
|
|
110
|
+
* Adds two vectors together element-wise.
|
|
111
|
+
* Example: [1,2,3] + [4,5,6] → [5,7,9]
|
|
104
112
|
* @param inputs Two vectors to be added
|
|
105
113
|
* @returns Number array representing vector
|
|
106
114
|
* @group sum
|
|
@@ -115,7 +123,8 @@ export class Vector {
|
|
|
115
123
|
return res;
|
|
116
124
|
}
|
|
117
125
|
/**
|
|
118
|
-
* Checks if the boolean array contains only true values, if there's a single false
|
|
126
|
+
* Checks if the boolean array contains only true values, returns false if there's a single false.
|
|
127
|
+
* Example: [true, true, true] → true, [true, false, true] → false
|
|
119
128
|
* @param inputs Vectors to be checked
|
|
120
129
|
* @returns Boolean indicating if vector contains only true values
|
|
121
130
|
* @group sum
|
|
@@ -126,10 +135,11 @@ export class Vector {
|
|
|
126
135
|
return inputs.vector.every(v => v);
|
|
127
136
|
}
|
|
128
137
|
/**
|
|
129
|
-
*
|
|
138
|
+
* Computes the cross product of two 3D vectors (perpendicular vector to both inputs).
|
|
139
|
+
* Example: [1,0,0] × [0,1,0] → [0,0,1] (right-hand rule)
|
|
130
140
|
* @param inputs Two vectors to be crossed
|
|
131
141
|
* @group base
|
|
132
|
-
* @shortname
|
|
142
|
+
* @shortname cross
|
|
133
143
|
* @returns Crossed vector
|
|
134
144
|
* @drawable false
|
|
135
145
|
*/
|
|
@@ -141,7 +151,8 @@ export class Vector {
|
|
|
141
151
|
return res;
|
|
142
152
|
}
|
|
143
153
|
/**
|
|
144
|
-
*
|
|
154
|
+
* Calculates squared distance between two vectors (faster than distance, avoids sqrt).
|
|
155
|
+
* Example: [0,0,0] to [3,4,0] → 25 (distance 5 squared)
|
|
145
156
|
* @param inputs Two vectors
|
|
146
157
|
* @returns Number representing squared distance between two vectors
|
|
147
158
|
* @group distance
|
|
@@ -156,7 +167,8 @@ export class Vector {
|
|
|
156
167
|
return res;
|
|
157
168
|
}
|
|
158
169
|
/**
|
|
159
|
-
*
|
|
170
|
+
* Calculates the Euclidean distance between two vectors.
|
|
171
|
+
* Example: [0,0,0] to [3,4,0] → 5, [1,1] to [4,5] → 5
|
|
160
172
|
* @param inputs Two vectors
|
|
161
173
|
* @returns Number representing distance between two vectors
|
|
162
174
|
* @group distance
|
|
@@ -167,7 +179,8 @@ export class Vector {
|
|
|
167
179
|
return Math.sqrt(this.distSquared(inputs));
|
|
168
180
|
}
|
|
169
181
|
/**
|
|
170
|
-
*
|
|
182
|
+
* Divides each element of the vector by a scalar value.
|
|
183
|
+
* Example: [10,20,30] ÷ 2 → [5,10,15]
|
|
171
184
|
* @param inputs Contains vector and a scalar
|
|
172
185
|
* @returns Vector that is a result of division by a scalar
|
|
173
186
|
* @group base
|
|
@@ -182,7 +195,8 @@ export class Vector {
|
|
|
182
195
|
return res;
|
|
183
196
|
}
|
|
184
197
|
/**
|
|
185
|
-
* Computes the domain between minimum and maximum values of the vector
|
|
198
|
+
* Computes the domain (range) between minimum and maximum values of the vector.
|
|
199
|
+
* Example: [1,3,5,9] → 8 (difference between last and first: 9-1)
|
|
186
200
|
* @param inputs Vector information
|
|
187
201
|
* @returns Number representing distance between two vectors
|
|
188
202
|
* @group base
|
|
@@ -193,7 +207,8 @@ export class Vector {
|
|
|
193
207
|
return inputs.vector[inputs.vector.length - 1] - inputs.vector[0];
|
|
194
208
|
}
|
|
195
209
|
/**
|
|
196
|
-
*
|
|
210
|
+
* Calculates the dot product between two vectors (measures similarity/projection).
|
|
211
|
+
* Example: [1,2,3] • [4,5,6] → 32 (1×4 + 2×5 + 3×6), perpendicular vectors → 0
|
|
197
212
|
* @param inputs Two vectors
|
|
198
213
|
* @returns Number representing dot product of the vector
|
|
199
214
|
* @group base
|
|
@@ -208,7 +223,8 @@ export class Vector {
|
|
|
208
223
|
return res;
|
|
209
224
|
}
|
|
210
225
|
/**
|
|
211
|
-
* Checks if vector is finite
|
|
226
|
+
* Checks if each element in the vector is finite and returns a boolean array.
|
|
227
|
+
* Example: [1, 2, Infinity, 3] → [true, true, false, true]
|
|
212
228
|
* @param inputs Vector with possibly infinite values
|
|
213
229
|
* @returns Vector array that contains boolean values for each number in the input
|
|
214
230
|
* vector that identifies if value is finite (true) or infinite (false)
|
|
@@ -220,7 +236,8 @@ export class Vector {
|
|
|
220
236
|
return inputs.vector.map(v => isFinite(v));
|
|
221
237
|
}
|
|
222
238
|
/**
|
|
223
|
-
* Checks if the vector
|
|
239
|
+
* Checks if the vector has zero length (all elements are zero).
|
|
240
|
+
* Example: [0,0,0] → true, [0,0,0.001] → false
|
|
224
241
|
* @param inputs Vector to be checked
|
|
225
242
|
* @returns Boolean that identifies if vector is zero length
|
|
226
243
|
* @group validate
|
|
@@ -231,7 +248,8 @@ export class Vector {
|
|
|
231
248
|
return this.norm({ vector: inputs.vector }) === 0;
|
|
232
249
|
}
|
|
233
250
|
/**
|
|
234
|
-
* Finds
|
|
251
|
+
* Finds an interpolated vector between two vectors using a fraction (linear interpolation).
|
|
252
|
+
* Example: [0,0,0] to [10,10,10] at 0.5 → [5,5,5], fraction=0 → first, fraction=1 → second
|
|
235
253
|
* @param inputs Information for finding vector between two vectors using a fraction
|
|
236
254
|
* @returns Vector that is in between two vectors
|
|
237
255
|
* @group distance
|
|
@@ -245,7 +263,8 @@ export class Vector {
|
|
|
245
263
|
});
|
|
246
264
|
}
|
|
247
265
|
/**
|
|
248
|
-
* Finds the maximum value in the vector
|
|
266
|
+
* Finds the maximum (largest) value in the vector.
|
|
267
|
+
* Example: [3, 7, 2, 9, 1] → 9
|
|
249
268
|
* @param inputs Vector to be checked
|
|
250
269
|
* @returns Largest number in the vector
|
|
251
270
|
* @group extract
|
|
@@ -256,7 +275,8 @@ export class Vector {
|
|
|
256
275
|
return Math.max(...inputs.vector);
|
|
257
276
|
}
|
|
258
277
|
/**
|
|
259
|
-
* Finds the minimum value in the vector
|
|
278
|
+
* Finds the minimum (smallest) value in the vector.
|
|
279
|
+
* Example: [3, 7, 2, 9, 1] → 1
|
|
260
280
|
* @param inputs Vector to be checked
|
|
261
281
|
* @returns Lowest number in the vector
|
|
262
282
|
* @group extract
|
|
@@ -267,7 +287,8 @@ export class Vector {
|
|
|
267
287
|
return Math.min(...inputs.vector);
|
|
268
288
|
}
|
|
269
289
|
/**
|
|
270
|
-
*
|
|
290
|
+
* Multiplies each element of the vector by a scalar value.
|
|
291
|
+
* Example: [2,3,4] × 5 → [10,15,20]
|
|
271
292
|
* @param inputs Vector with a scalar
|
|
272
293
|
* @returns Vector that results from multiplication
|
|
273
294
|
* @group base
|
|
@@ -282,7 +303,8 @@ export class Vector {
|
|
|
282
303
|
return res;
|
|
283
304
|
}
|
|
284
305
|
/**
|
|
285
|
-
* Negates the vector
|
|
306
|
+
* Negates the vector (flips the sign of each element).
|
|
307
|
+
* Example: [5,-3,2] → [-5,3,-2]
|
|
286
308
|
* @param inputs Vector to negate
|
|
287
309
|
* @returns Negative vector
|
|
288
310
|
* @group base
|
|
@@ -297,7 +319,8 @@ export class Vector {
|
|
|
297
319
|
return res;
|
|
298
320
|
}
|
|
299
321
|
/**
|
|
300
|
-
*
|
|
322
|
+
* Computes the squared norm (squared magnitude/length) of the vector.
|
|
323
|
+
* Example: [3,4,0] → 25 (length 5 squared)
|
|
301
324
|
* @param inputs Vector for squared norm
|
|
302
325
|
* @returns Number that is squared norm
|
|
303
326
|
* @group base
|
|
@@ -308,7 +331,8 @@ export class Vector {
|
|
|
308
331
|
return this.dot({ first: inputs.vector, second: inputs.vector });
|
|
309
332
|
}
|
|
310
333
|
/**
|
|
311
|
-
*
|
|
334
|
+
* Calculates the norm (magnitude/length) of the vector.
|
|
335
|
+
* Example: [3,4,0] → 5, [1,0,0] → 1
|
|
312
336
|
* @param inputs Vector to compute the norm
|
|
313
337
|
* @returns Number that is norm of the vector
|
|
314
338
|
* @group base
|
|
@@ -320,7 +344,8 @@ export class Vector {
|
|
|
320
344
|
return norm2 !== 0.0 ? Math.sqrt(norm2) : norm2;
|
|
321
345
|
}
|
|
322
346
|
/**
|
|
323
|
-
*
|
|
347
|
+
* Normalizes the vector into a unit vector that has a length of 1 (maintains direction, scales magnitude to 1).
|
|
348
|
+
* Example: [3,4,0] → [0.6,0.8,0], [10,0,0] → [1,0,0]
|
|
324
349
|
* @param inputs Vector to normalize
|
|
325
350
|
* @returns Unit vector that has length of 1
|
|
326
351
|
* @group base
|
|
@@ -335,7 +360,8 @@ export class Vector {
|
|
|
335
360
|
return this.div({ scalar: this.norm(inputs), vector: inputs.vector });
|
|
336
361
|
}
|
|
337
362
|
/**
|
|
338
|
-
* Finds a point
|
|
363
|
+
* Finds a point on a ray at a given distance from the origin along the direction vector.
|
|
364
|
+
* Example: Point [0,0,0] + direction [1,0,0] at distance 5 → [5,0,0]
|
|
339
365
|
* @param inputs Provide a point, vector and a distance for finding a point
|
|
340
366
|
* @returns Vector representing point on the ray
|
|
341
367
|
* @group base
|
|
@@ -346,7 +372,8 @@ export class Vector {
|
|
|
346
372
|
return this.add({ first: inputs.point, second: this.mul({ vector: inputs.vector, scalar: inputs.distance }) });
|
|
347
373
|
}
|
|
348
374
|
/**
|
|
349
|
-
*
|
|
375
|
+
* Creates a 3D vector from x, y, z coordinates.
|
|
376
|
+
* Example: x=1, y=2, z=3 → [1,2,3]
|
|
350
377
|
* @param inputs Vector coordinates
|
|
351
378
|
* @returns Create a vector of xyz values
|
|
352
379
|
* @group create
|
|
@@ -357,7 +384,8 @@ export class Vector {
|
|
|
357
384
|
return [inputs.x, inputs.y, inputs.z];
|
|
358
385
|
}
|
|
359
386
|
/**
|
|
360
|
-
*
|
|
387
|
+
* Creates a 2D vector from x, y coordinates.
|
|
388
|
+
* Example: x=3, y=4 → [3,4]
|
|
361
389
|
* @param inputs Vector coordinates
|
|
362
390
|
* @returns Create a vector of xy values
|
|
363
391
|
* @group create
|
|
@@ -368,7 +396,8 @@ export class Vector {
|
|
|
368
396
|
return [inputs.x, inputs.y];
|
|
369
397
|
}
|
|
370
398
|
/**
|
|
371
|
-
* Creates a vector of integers
|
|
399
|
+
* Creates a vector of integers from 0 to max (exclusive).
|
|
400
|
+
* Example: max=5 → [0,1,2,3,4], max=3 → [0,1,2]
|
|
372
401
|
* @param inputs Max value for the range
|
|
373
402
|
* @returns Vector containing items from 0 to max
|
|
374
403
|
* @group create
|
|
@@ -383,7 +412,8 @@ export class Vector {
|
|
|
383
412
|
return res;
|
|
384
413
|
}
|
|
385
414
|
/**
|
|
386
|
-
* Computes signed angle between two vectors
|
|
415
|
+
* Computes signed angle between two vectors using a reference vector (determines rotation direction).
|
|
416
|
+
* Example: Returns positive or negative angle depending on rotation direction relative to reference
|
|
387
417
|
* @param inputs Contains information of two vectors and a reference vector
|
|
388
418
|
* @returns Signed angle in degrees
|
|
389
419
|
* @group angles
|
|
@@ -404,7 +434,8 @@ export class Vector {
|
|
|
404
434
|
return this.math.radToDeg({ number: res });
|
|
405
435
|
}
|
|
406
436
|
/**
|
|
407
|
-
* Creates a vector
|
|
437
|
+
* Creates a vector containing numbers from min to max at a given step increment.
|
|
438
|
+
* Example: min=0, max=10, step=2 → [0,2,4,6,8,10]
|
|
408
439
|
* @param inputs Span information containing min, max and step values
|
|
409
440
|
* @returns Vector containing number between min, max and increasing at a given step
|
|
410
441
|
* @group create
|
|
@@ -419,7 +450,8 @@ export class Vector {
|
|
|
419
450
|
return res;
|
|
420
451
|
}
|
|
421
452
|
/**
|
|
422
|
-
* Creates a vector
|
|
453
|
+
* Creates a vector with numbers from min to max using an easing function for non-linear distribution.
|
|
454
|
+
* Example: min=0, max=100, nrItems=5, ease='easeInQuad' → creates accelerating intervals
|
|
423
455
|
* @param inputs Span information containing min, max and ease function
|
|
424
456
|
* @returns Vector containing numbers between min, max and increasing in non-linear steps defined by nr of items in the vector and type
|
|
425
457
|
* @group create
|
|
@@ -438,7 +470,8 @@ export class Vector {
|
|
|
438
470
|
return res;
|
|
439
471
|
}
|
|
440
472
|
/**
|
|
441
|
-
* Creates a vector
|
|
473
|
+
* Creates a vector with evenly spaced numbers from min to max with a specified number of items.
|
|
474
|
+
* Example: min=0, max=10, nrItems=5 → [0, 2.5, 5, 7.5, 10]
|
|
442
475
|
* @param inputs Span information containing min, max and step values
|
|
443
476
|
* @returns Vector containing number between min, max by giving nr of items
|
|
444
477
|
* @group create
|
|
@@ -455,7 +488,8 @@ export class Vector {
|
|
|
455
488
|
return res;
|
|
456
489
|
}
|
|
457
490
|
/**
|
|
458
|
-
*
|
|
491
|
+
* Subtracts the second vector from the first element-wise.
|
|
492
|
+
* Example: [10,20,30] - [1,2,3] → [9,18,27]
|
|
459
493
|
* @param inputs Two vectors
|
|
460
494
|
* @returns Vector that result by subtraction two vectors
|
|
461
495
|
* @group base
|
|
@@ -470,7 +504,8 @@ export class Vector {
|
|
|
470
504
|
return res;
|
|
471
505
|
}
|
|
472
506
|
/**
|
|
473
|
-
* Sums
|
|
507
|
+
* Sums all values in the vector and returns a single number.
|
|
508
|
+
* Example: [1,2,3,4] → 10, [5,10,15] → 30
|
|
474
509
|
* @param inputs Vector to sum
|
|
475
510
|
* @returns Number that results by adding up all values in the vector
|
|
476
511
|
* @group base
|
|
@@ -481,7 +516,8 @@ export class Vector {
|
|
|
481
516
|
return inputs.vector.reduce((a, b) => a + b, 0);
|
|
482
517
|
}
|
|
483
518
|
/**
|
|
484
|
-
* Computes the squared length of
|
|
519
|
+
* Computes the squared length (squared magnitude) of a 3D vector.
|
|
520
|
+
* Example: [3,4,0] → 25 (length 5 squared)
|
|
485
521
|
* @param inputs Vector to compute the length
|
|
486
522
|
* @returns Number that is squared length of the vector
|
|
487
523
|
* @group base
|
|
@@ -493,7 +529,8 @@ export class Vector {
|
|
|
493
529
|
return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
|
|
494
530
|
}
|
|
495
531
|
/**
|
|
496
|
-
* Computes the length of
|
|
532
|
+
* Computes the length (magnitude) of a 3D vector.
|
|
533
|
+
* Example: [3,4,0] → 5, [1,0,0] → 1
|
|
497
534
|
* @param inputs Vector to compute the length
|
|
498
535
|
* @returns Number that is length of the vector
|
|
499
536
|
* @group base
|
|
@@ -503,4 +540,16 @@ export class Vector {
|
|
|
503
540
|
length(inputs) {
|
|
504
541
|
return Math.sqrt(this.lengthSq(inputs));
|
|
505
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Converts an array of stringified numbers to actual numbers.
|
|
545
|
+
* Example: ['1', '2.5', '3'] → [1, 2.5, 3], ['10', '-5', '0.1'] → [10, -5, 0.1]
|
|
546
|
+
* @param inputs Array of stringified numbers
|
|
547
|
+
* @returns Array of numbers
|
|
548
|
+
* @group create
|
|
549
|
+
* @shortname parse numbers
|
|
550
|
+
* @drawable false
|
|
551
|
+
*/
|
|
552
|
+
parseNumbers(inputs) {
|
|
553
|
+
return inputs.vector.map(v => parseFloat(v));
|
|
554
|
+
}
|
|
506
555
|
}
|