@bitbybit-dev/base 1.2.0-rc.2 → 1.3.0-rc.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 (55) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +13 -12
  3. package/lib/api/inputs/color-inputs.d.ts +97 -48
  4. package/lib/api/inputs/color-inputs.js +95 -46
  5. package/lib/api/inputs/dates-inputs.d.ts +67 -26
  6. package/lib/api/inputs/dates-inputs.js +57 -16
  7. package/lib/api/inputs/io-inputs.d.ts +13 -15
  8. package/lib/api/inputs/io-inputs.js +7 -8
  9. package/lib/api/inputs/line-inputs.d.ts +88 -33
  10. package/lib/api/inputs/line-inputs.js +61 -11
  11. package/lib/api/inputs/lists-inputs.d.ts +207 -96
  12. package/lib/api/inputs/lists-inputs.js +153 -45
  13. package/lib/api/inputs/logic-inputs.d.ts +52 -22
  14. package/lib/api/inputs/logic-inputs.js +41 -12
  15. package/lib/api/inputs/math-inputs.d.ts +113 -52
  16. package/lib/api/inputs/math-inputs.js +112 -51
  17. package/lib/api/inputs/mesh-inputs.d.ts +30 -11
  18. package/lib/api/inputs/mesh-inputs.js +21 -3
  19. package/lib/api/inputs/point-inputs.d.ts +240 -107
  20. package/lib/api/inputs/point-inputs.js +199 -73
  21. package/lib/api/inputs/polyline-inputs.d.ts +68 -28
  22. package/lib/api/inputs/polyline-inputs.js +48 -13
  23. package/lib/api/inputs/text-inputs.d.ts +117 -46
  24. package/lib/api/inputs/text-inputs.js +111 -41
  25. package/lib/api/inputs/transforms-inputs.d.ts +65 -23
  26. package/lib/api/inputs/transforms-inputs.js +64 -22
  27. package/lib/api/inputs/vector-inputs.d.ts +154 -76
  28. package/lib/api/inputs/vector-inputs.js +132 -57
  29. package/lib/api/models/point/hex-grid-data.d.ts +1 -1
  30. package/lib/api/models/point/hex-grid-data.js +1 -1
  31. package/lib/api/services/color.d.ts +149 -70
  32. package/lib/api/services/color.js +149 -70
  33. package/lib/api/services/dates.d.ts +313 -150
  34. package/lib/api/services/dates.js +313 -150
  35. package/lib/api/services/line.d.ts +138 -68
  36. package/lib/api/services/line.js +138 -68
  37. package/lib/api/services/lists.d.ts +357 -177
  38. package/lib/api/services/lists.js +357 -177
  39. package/lib/api/services/logic.d.ts +98 -45
  40. package/lib/api/services/logic.js +98 -45
  41. package/lib/api/services/math.d.ts +363 -211
  42. package/lib/api/services/math.js +363 -211
  43. package/lib/api/services/mesh.d.ts +73 -31
  44. package/lib/api/services/mesh.js +73 -31
  45. package/lib/api/services/point.d.ts +367 -147
  46. package/lib/api/services/point.js +367 -147
  47. package/lib/api/services/polyline.d.ts +146 -71
  48. package/lib/api/services/polyline.js +146 -71
  49. package/lib/api/services/text.d.ts +320 -165
  50. package/lib/api/services/text.js +320 -165
  51. package/lib/api/services/transforms.d.ts +145 -58
  52. package/lib/api/services/transforms.js +145 -58
  53. package/lib/api/services/vector.d.ts +381 -156
  54. package/lib/api/services/vector.js +381 -156
  55. package/package.json +1 -1
@@ -2,393 +2,618 @@ import * as Inputs from "../inputs";
2
2
  import { GeometryHelper } from "./geometry-helper";
3
3
  import { MathBitByBit } from "./math";
4
4
  /**
5
- * Contains various methods for vector mathematics. Vector in bitbybit is simply an array, usually
6
- * containing numbers. In 3D [x, y, z] form describes space, where y is the up vector. Because of this form
7
- * Vector can be interchanged with Point, which also is an array in [x, y, z] form.
5
+ * Vector maths on plain number arrays. A vector is an array of numbers; in 3D it is `[x, y, z]`
6
+ * with Y pointing up, the same shape as a point, so the two can be passed to each other's methods.
7
+ * Every method returns a new array or a number and never changes its inputs. Angles are in degrees.
8
8
  */
9
9
  export declare class Vector {
10
10
  private readonly math;
11
11
  private readonly geometryHelper;
12
12
  constructor(math: MathBitByBit, geometryHelper: GeometryHelper);
13
13
  /**
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]]
16
- * @param inputs Contains vectors and a tolerance value
17
- * @returns Array of vectors without duplicates
14
+ * Removes every repeated vector from a list, keeping the first occurrence of each.
15
+ *
16
+ * Two vectors count as the same when every entry differs by less than `tolerance`.
17
+ * Example: [[1,2,3], [4,5,6], [1,2,3], [7,8,9]] -> [[1,2,3], [4,5,6], [7,8,9]]
18
+ * @param inputs - Vectors to filter and the tolerance
19
+ * @returns The vectors without repeats, in their original order
18
20
  * @group remove
19
21
  * @shortname remove all duplicates
20
22
  * @drawable false
23
+ * @example
24
+ * ```typescript
25
+ * const unique = bitbybit.vector.removeAllDuplicateVectors({
26
+ * vectors: [[1, 2, 3], [4, 5, 6], [1, 2, 3]],
27
+ * tolerance: 1e-7,
28
+ * });
29
+ * ```
21
30
  */
22
31
  removeAllDuplicateVectors(inputs: Inputs.Vector.RemoveAllDuplicateVectorsDto): number[][];
23
32
  /**
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)
26
- * @param inputs Contains vectors and a tolerance value
27
- * @returns Array of vectors without duplicates
33
+ * Removes a vector when it repeats the one right before it; the same vector further away is
34
+ * kept.
35
+ *
36
+ * With `checkFirstAndLast` on, a last vector that repeats the first is dropped too, which
37
+ * closes a loop of points cleanly. Entries within `tolerance` of each other count as equal.
38
+ * Example: [[1,2], [1,2], [3,4], [1,2]] -> [[1,2], [3,4], [1,2]]
39
+ * @param inputs - Vectors to filter, whether to compare the first and last, and the tolerance
40
+ * @returns The vectors without consecutive repeats
28
41
  * @group remove
29
42
  * @shortname remove consecutive duplicates
30
43
  * @drawable false
44
+ * @example
45
+ * ```typescript
46
+ * const cleaned = bitbybit.vector.removeConsecutiveDuplicateVectors({
47
+ * vectors: [[0, 0], [0, 0], [1, 1], [0, 0]],
48
+ * checkFirstAndLast: true,
49
+ * tolerance: 1e-7,
50
+ * });
51
+ * ```
31
52
  */
32
53
  removeConsecutiveDuplicateVectors(inputs: Inputs.Vector.RemoveConsecutiveDuplicateVectorsDto): number[][];
33
54
  /**
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
36
- * @param inputs Contains two vectors and a tolerance value
37
- * @returns Boolean indicating if vectors are the same
55
+ * Tells whether two vectors are the same within a tolerance, entry by entry.
56
+ *
57
+ * Vectors of different length are never the same.
58
+ * Example: [1,2,3] and [1.0001,2.0001,3.0001] with tolerance 0.001 -> true
59
+ * @param inputs - The two vectors and the tolerance
60
+ * @returns True when every entry differs by less than the tolerance
38
61
  * @group validate
39
62
  * @shortname vectors the same
40
63
  * @drawable false
64
+ * @example
65
+ * ```typescript
66
+ * const same = bitbybit.vector.vectorsTheSame({ vec1: [1, 2, 3], vec2: [1, 2, 3.0000001], tolerance: 1e-6 });
67
+ * ```
41
68
  */
42
69
  vectorsTheSame(inputs: Inputs.Vector.VectorsTheSameDto): boolean;
43
70
  /**
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)
46
- * @param inputs Contains two vectors represented as number arrays
71
+ * Measures the angle between two vectors in degrees, always between 0 and 180.
72
+ *
73
+ * The direction of turning is not considered; use `signedAngleBetween` for that.
74
+ * Example: [1,0,0] and [0,1,0] -> 90
75
+ * @param inputs - The two vectors
76
+ * @returns Angle in degrees
47
77
  * @group angles
48
78
  * @shortname angle
49
- * @returns Number in degrees
50
79
  * @drawable false
80
+ * @example
81
+ * ```typescript
82
+ * const angle = bitbybit.vector.angleBetween({ first: [1, 0, 0], second: [0, 1, 0] });
83
+ * ```
51
84
  */
52
85
  angleBetween(inputs: Inputs.Vector.TwoVectorsDto): number;
53
86
  /**
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°
56
- * @param inputs Contains two vectors represented as number arrays
57
- * @returns Number in degrees
87
+ * Measures the signed angle from the first 2D vector to the second, in degrees from -180 to
88
+ * 180.
89
+ *
90
+ * Only the first two entries of each vector are used; a positive angle turns counter-clockwise.
91
+ * Example: [1,0] to [0,1] -> 90, [0,1] to [1,0] -> -90
92
+ * @param inputs - The two 2D vectors
93
+ * @returns Signed angle in degrees
58
94
  * @group angles
59
95
  * @shortname angle normalized 2d
60
96
  * @drawable false
97
+ * @example
98
+ * ```typescript
99
+ * const angle = bitbybit.vector.angleBetweenNormalized2d({ first: [1, 0], second: [0, 1] });
100
+ * ```
61
101
  */
62
102
  angleBetweenNormalized2d(inputs: Inputs.Vector.TwoVectorsDto): number;
63
103
  /**
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
66
- * @param inputs Contains information of two vectors and a reference vector
67
- * @returns Number in degrees
104
+ * Measures the angle from the first vector to the second, turning around a reference direction,
105
+ * in degrees from 0 to 360.
106
+ *
107
+ * The turn is counter-clockwise when the reference vector points toward you.
108
+ * Example: [1,0,0] to [0,0,-1] around [0,1,0] -> 90
109
+ * @param inputs - The two vectors and the reference direction to turn around
110
+ * @returns Angle in degrees from 0 to 360
68
111
  * @group angles
69
112
  * @shortname positive angle
70
113
  * @drawable false
114
+ * @example
115
+ * ```typescript
116
+ * const angle = bitbybit.vector.positiveAngleBetween({ first: [1, 0, 0], second: [0, 0, -1], reference: [0, 1, 0] });
117
+ * ```
71
118
  */
72
119
  positiveAngleBetween(inputs: Inputs.Vector.TwoVectorsReferenceDto): number;
73
120
  /**
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)
76
- * @param inputs Vectors to be added
77
- * @returns New vector that has xyz values as sums of all the vectors
121
+ * Adds a list of vectors together entry by entry into one vector.
122
+ *
123
+ * The result has as many entries as the first vector.
124
+ * Example: [[1,2,3], [4,5,6], [7,8,9]] -> [12,15,18]
125
+ * @param inputs - Vectors to add
126
+ * @returns The vector of sums
78
127
  * @group sum
79
128
  * @shortname add all
80
129
  * @drawable false
130
+ * @example
131
+ * ```typescript
132
+ * const total = bitbybit.vector.addAll({ vectors: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] });
133
+ * ```
81
134
  */
82
135
  addAll(inputs: Inputs.Vector.VectorsDto): number[];
83
136
  /**
84
- * Adds two vectors together element-wise.
85
- * Example: [1,2,3] + [4,5,6] → [5,7,9]
86
- * @param inputs Two vectors to be added
87
- * @returns Number array representing vector
137
+ * Adds two vectors entry by entry.
138
+ *
139
+ * Example: [1,2,3] + [4,5,6] -> [5,7,9]
140
+ * @param inputs - The two vectors to add
141
+ * @returns The vector of sums
88
142
  * @group sum
89
143
  * @shortname add
90
144
  * @drawable false
145
+ * @example
146
+ * ```typescript
147
+ * const sum = bitbybit.vector.add({ first: [1, 2, 3], second: [4, 5, 6] });
148
+ * ```
91
149
  */
92
150
  add(inputs: Inputs.Vector.TwoVectorsDto): number[];
93
151
  /**
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
96
- * @param inputs Vectors to be checked
97
- * @returns Boolean indicating if vector contains only true values
152
+ * Tells whether every value in a list of booleans is true.
153
+ *
154
+ * Example: [true, true, true] -> true, [true, false, true] -> false
155
+ * @param inputs - The booleans to check
156
+ * @returns True when no entry is false
98
157
  * @group sum
99
158
  * @shortname all
100
159
  * @drawable false
160
+ * @example
161
+ * ```typescript
162
+ * const allTrue = bitbybit.vector.all({ vector: [true, true, false] });
163
+ * ```
101
164
  */
102
165
  all(inputs: Inputs.Vector.VectorBoolDto): boolean;
103
166
  /**
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)
106
- * @param inputs Two vectors to be crossed
167
+ * Computes the cross product of two 3D vectors: a vector at right angles to both.
168
+ *
169
+ * Its direction follows the right-hand rule and its length is the area of the parallelogram the
170
+ * two vectors span.
171
+ * Example: [1,0,0] x [0,1,0] -> [0,0,1]
172
+ * @param inputs - The two 3D vectors
173
+ * @returns The vector perpendicular to both
107
174
  * @group base
108
175
  * @shortname cross
109
- * @returns Crossed vector
110
176
  * @drawable false
177
+ * @example
178
+ * ```typescript
179
+ * const normal = bitbybit.vector.cross({ first: [1, 0, 0], second: [0, 1, 0] });
180
+ * ```
111
181
  */
112
182
  cross(inputs: Inputs.Vector.TwoVectorsDto): number[];
113
183
  /**
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)
116
- * @param inputs Two vectors
117
- * @returns Number representing squared distance between two vectors
184
+ * Computes the squared distance between two vectors, which avoids the square root when only
185
+ * comparing distances.
186
+ *
187
+ * Example: [0,0,0] to [3,4,0] -> 25
188
+ * @param inputs - The two vectors
189
+ * @returns The squared distance
118
190
  * @group distance
119
191
  * @shortname dist squared
120
192
  * @drawable false
193
+ * @example
194
+ * ```typescript
195
+ * const d2 = bitbybit.vector.distSquared({ first: [0, 0, 0], second: [3, 4, 0] });
196
+ * ```
121
197
  */
122
198
  distSquared(inputs: Inputs.Vector.TwoVectorsDto): number;
123
199
  /**
124
- * Calculates the Euclidean distance between two vectors.
125
- * Example: [0,0,0] to [3,4,0] → 5, [1,1] to [4,5] → 5
126
- * @param inputs Two vectors
127
- * @returns Number representing distance between two vectors
200
+ * Computes the straight-line distance between two vectors.
201
+ *
202
+ * Example: [0,0,0] to [3,4,0] -> 5
203
+ * @param inputs - The two vectors
204
+ * @returns The distance in model units
128
205
  * @group distance
129
206
  * @shortname dist
130
207
  * @drawable false
208
+ * @example
209
+ * ```typescript
210
+ * const distance = bitbybit.vector.dist({ first: [0, 0, 0], second: [3, 4, 0] });
211
+ * ```
131
212
  */
132
213
  dist(inputs: Inputs.Vector.TwoVectorsDto): number;
133
214
  /**
134
- * Divides each element of the vector by a scalar value.
135
- * Example: [10,20,30] ÷ 2 → [5,10,15]
136
- * @param inputs Contains vector and a scalar
137
- * @returns Vector that is a result of division by a scalar
215
+ * Divides every entry of a vector by one number.
216
+ *
217
+ * Example: [10,20,30] / 2 -> [5,10,15]
218
+ * @param inputs - The vector and the number to divide by
219
+ * @returns The divided vector
138
220
  * @group base
139
221
  * @shortname div
140
222
  * @drawable false
223
+ * @example
224
+ * ```typescript
225
+ * const half = bitbybit.vector.div({ vector: [10, 20, 30], scalar: 2 });
226
+ * ```
141
227
  */
142
228
  div(inputs: Inputs.Vector.VectorScalarDto): number[];
143
229
  /**
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)
146
- * @param inputs Vector information
147
- * @returns Number representing distance between two vectors
230
+ * Subtracts the first value of a vector from its last, which for a sorted list is its range.
231
+ *
232
+ * Example: [1,3,5,9] -> 8
233
+ * @param inputs - The vector
234
+ * @returns Last value minus first value
148
235
  * @group base
149
236
  * @shortname domain
150
237
  * @drawable false
238
+ * @example
239
+ * ```typescript
240
+ * const span = bitbybit.vector.domain({ vector: [1, 3, 5, 9] });
241
+ * ```
151
242
  */
152
243
  domain(inputs: Inputs.Vector.VectorDto): number;
153
244
  /**
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
156
- * @param inputs Two vectors
157
- * @returns Number representing dot product of the vector
245
+ * Computes the dot product of two vectors: the sum of the products of matching entries.
246
+ *
247
+ * It is 0 for vectors at right angles and, for unit vectors, the cosine of the angle between
248
+ * them.
249
+ * Example: [1,2,3] and [4,5,6] -> 32
250
+ * @param inputs - The two vectors
251
+ * @returns The dot product
158
252
  * @group base
159
253
  * @shortname dot
160
254
  * @drawable false
255
+ * @example
256
+ * ```typescript
257
+ * const projection = bitbybit.vector.dot({ first: [1, 2, 3], second: [4, 5, 6] });
258
+ * ```
161
259
  */
162
260
  dot(inputs: Inputs.Vector.TwoVectorsDto): number;
163
261
  /**
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]
166
- * @param inputs Vector with possibly infinite values
167
- * @returns Vector array that contains boolean values for each number in the input
168
- * vector that identifies if value is finite (true) or infinite (false)
262
+ * Marks which entries of a vector are finite numbers.
263
+ *
264
+ * Example: [1, 2, Infinity, 3] -> [true, true, false, true]
265
+ * @param inputs - The vector to check
266
+ * @returns One boolean per entry, true when it is finite
169
267
  * @group validate
170
268
  * @shortname finite
171
269
  * @drawable false
270
+ * @example
271
+ * ```typescript
272
+ * const flags = bitbybit.vector.finite({ vector: [1, Infinity, 3] });
273
+ * ```
172
274
  */
173
275
  finite(inputs: Inputs.Vector.VectorDto): boolean[];
174
276
  /**
175
- * Checks if the vector has zero length (all elements are zero).
176
- * Example: [0,0,0] → true, [0,0,0.001] → false
177
- * @param inputs Vector to be checked
178
- * @returns Boolean that identifies if vector is zero length
277
+ * Tells whether a vector has no length, that is, every entry is exactly 0.
278
+ *
279
+ * Example: [0,0,0] -> true, [0,0,0.001] -> false
280
+ * @param inputs - The vector to check
281
+ * @returns True when the length is 0
179
282
  * @group validate
180
283
  * @shortname isZero
181
284
  * @drawable false
285
+ * @example
286
+ * ```typescript
287
+ * const zero = bitbybit.vector.isZero({ vector: [0, 0, 0] });
288
+ * ```
182
289
  */
183
290
  isZero(inputs: Inputs.Vector.VectorDto): boolean;
184
291
  /**
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
187
- * @param inputs Information for finding vector between two vectors using a fraction
188
- * @returns Vector that is in between two vectors
292
+ * Blends two vectors linearly by a fraction.
293
+ *
294
+ * `fraction` is the share of `first`: 1 gives `first`, 0 gives `second`, 0.5 the midpoint.
295
+ * Example: [0,0,0] and [10,10,10] at 0.5 -> [5,5,5]
296
+ * @param inputs - The two vectors and the fraction of the first
297
+ * @returns The blended vector
189
298
  * @group distance
190
299
  * @shortname lerp
191
300
  * @drawable false
301
+ * @example
302
+ * ```typescript
303
+ * const mid = bitbybit.vector.lerp({ first: [0, 0, 0], second: [10, 10, 10], fraction: 0.5 });
304
+ * ```
192
305
  */
193
306
  lerp(inputs: Inputs.Vector.FractionTwoVectorsDto): number[];
194
307
  /**
195
- * Finds the maximum (largest) value in the vector.
196
- * Example: [3, 7, 2, 9, 1] → 9
197
- * @param inputs Vector to be checked
198
- * @returns Largest number in the vector
308
+ * Finds the largest value in a vector.
309
+ *
310
+ * Example: [3, 7, 2, 9, 1] -> 9
311
+ * @param inputs - The vector
312
+ * @returns The largest entry
199
313
  * @group extract
200
314
  * @shortname max
201
315
  * @drawable false
316
+ * @example
317
+ * ```typescript
318
+ * const largest = bitbybit.vector.max({ vector: [3, 7, 2, 9, 1] });
319
+ * ```
202
320
  */
203
321
  max(inputs: Inputs.Vector.VectorDto): number;
204
322
  /**
205
- * Finds the minimum (smallest) value in the vector.
206
- * Example: [3, 7, 2, 9, 1] → 1
207
- * @param inputs Vector to be checked
208
- * @returns Lowest number in the vector
323
+ * Finds the smallest value in a vector.
324
+ *
325
+ * Example: [3, 7, 2, 9, 1] -> 1
326
+ * @param inputs - The vector
327
+ * @returns The smallest entry
209
328
  * @group extract
210
329
  * @shortname min
211
330
  * @drawable false
331
+ * @example
332
+ * ```typescript
333
+ * const smallest = bitbybit.vector.min({ vector: [3, 7, 2, 9, 1] });
334
+ * ```
212
335
  */
213
336
  min(inputs: Inputs.Vector.VectorDto): number;
214
337
  /**
215
- * Multiplies each element of the vector by a scalar value.
216
- * Example: [2,3,4] × 5 → [10,15,20]
217
- * @param inputs Vector with a scalar
218
- * @returns Vector that results from multiplication
338
+ * Multiplies every entry of a vector by one number.
339
+ *
340
+ * Example: [2,3,4] x 5 -> [10,15,20]
341
+ * @param inputs - The vector and the number to multiply by
342
+ * @returns The scaled vector
219
343
  * @group base
220
344
  * @shortname mul
221
345
  * @drawable false
346
+ * @example
347
+ * ```typescript
348
+ * const scaled = bitbybit.vector.mul({ vector: [2, 3, 4], scalar: 5 });
349
+ * ```
222
350
  */
223
351
  mul(inputs: Inputs.Vector.VectorScalarDto): number[];
224
352
  /**
225
- * Negates the vector (flips the sign of each element).
226
- * Example: [5,-3,2] → [-5,3,-2]
227
- * @param inputs Vector to negate
228
- * @returns Negative vector
353
+ * Flips the sign of every entry, so the vector points the opposite way.
354
+ *
355
+ * Example: [5,-3,2] -> [-5,3,-2]
356
+ * @param inputs - The vector to flip
357
+ * @returns The negated vector
229
358
  * @group base
230
359
  * @shortname neg
231
360
  * @drawable false
361
+ * @example
362
+ * ```typescript
363
+ * const opposite = bitbybit.vector.neg({ vector: [5, -3, 2] });
364
+ * ```
232
365
  */
233
366
  neg(inputs: Inputs.Vector.VectorDto): number[];
234
367
  /**
235
- * Computes the squared norm (squared magnitude/length) of the vector.
236
- * Example: [3,4,0] → 25 (length 5 squared)
237
- * @param inputs Vector for squared norm
238
- * @returns Number that is squared norm
368
+ * Computes the squared length of a vector, which avoids the square root when only comparing
369
+ * lengths.
370
+ *
371
+ * Example: [3,4,0] -> 25
372
+ * @param inputs - The vector
373
+ * @returns The squared length
239
374
  * @group base
240
375
  * @shortname norm squared
241
376
  * @drawable false
377
+ * @example
378
+ * ```typescript
379
+ * const n2 = bitbybit.vector.normSquared({ vector: [3, 4, 0] });
380
+ * ```
242
381
  */
243
382
  normSquared(inputs: Inputs.Vector.VectorDto): number;
244
383
  /**
245
- * Calculates the norm (magnitude/length) of the vector.
246
- * Example: [3,4,0] → 5, [1,0,0] → 1
247
- * @param inputs Vector to compute the norm
248
- * @returns Number that is norm of the vector
384
+ * Computes the length of a vector.
385
+ *
386
+ * Example: [3,4,0] -> 5, [1,0,0] -> 1
387
+ * @param inputs - The vector
388
+ * @returns The length in model units
249
389
  * @group base
250
390
  * @shortname norm
251
391
  * @drawable false
392
+ * @example
393
+ * ```typescript
394
+ * const len = bitbybit.vector.norm({ vector: [3, 4, 0] });
395
+ * ```
252
396
  */
253
397
  norm(inputs: Inputs.Vector.VectorDto): number;
254
398
  /**
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]
257
- * @param inputs Vector to normalize
258
- * @returns Unit vector that has length of 1
399
+ * Scales a 3D vector to length 1 while keeping its direction.
400
+ *
401
+ * A vector shorter than 1e-8 has no direction to keep, so the result is undefined.
402
+ * Example: [3,4,0] -> [0.6,0.8,0]
403
+ * @param inputs - The 3D vector to normalize
404
+ * @returns The unit vector, or undefined for a zero-length input
259
405
  * @group base
260
406
  * @shortname normalized
261
407
  * @drawable false
408
+ * @example
409
+ * ```typescript
410
+ * const direction = bitbybit.vector.normalized({ vector: [3, 4, 0] });
411
+ * ```
262
412
  */
263
413
  normalized(inputs: Inputs.Vector.VectorDto): number[] | undefined;
264
414
  /**
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]
267
- * @param inputs Provide a point, vector and a distance for finding a point
268
- * @returns Vector representing point on the ray
415
+ * Finds the point at a given distance from a start point along a direction.
416
+ *
417
+ * The direction is used as given, so a direction of length 2 travels twice the distance.
418
+ * Example: start [0,0,0], direction [1,0,0], distance 5 -> [5,0,0]
419
+ * @param inputs - The start point, the direction and the distance
420
+ * @returns The point on the ray
269
421
  * @group base
270
422
  * @shortname on ray
271
423
  * @drawable false
424
+ * @example
425
+ * ```typescript
426
+ * const ahead = bitbybit.vector.onRay({ point: [0, 0, 0], vector: [1, 0, 0], distance: 5 });
427
+ * ```
272
428
  */
273
429
  onRay(inputs: Inputs.Vector.RayPointDto): number[];
274
430
  /**
275
- * Creates a 3D vector from x, y, z coordinates.
276
- * Example: x=1, y=2, z=3 → [1,2,3]
277
- * @param inputs Vector coordinates
278
- * @returns Create a vector of xyz values
431
+ * Builds a 3D vector from its x, y and z values.
432
+ *
433
+ * Example: x=1, y=2, z=3 -> [1,2,3]
434
+ * @param inputs - The three values
435
+ * @returns The vector `[x, y, z]`
279
436
  * @group create
280
437
  * @shortname vector XYZ
281
438
  * @drawable true
439
+ * @example
440
+ * ```typescript
441
+ * const up = bitbybit.vector.vectorXYZ({ x: 0, y: 1, z: 0 });
442
+ * ```
282
443
  */
283
444
  vectorXYZ(inputs: Inputs.Vector.VectorXYZDto): Inputs.Base.Vector3;
284
445
  /**
285
- * Creates a 2D vector from x, y coordinates.
286
- * Example: x=3, y=4 → [3,4]
287
- * @param inputs Vector coordinates
288
- * @returns Create a vector of xy values
446
+ * Builds a 2D vector from its x and y values.
447
+ *
448
+ * Example: x=3, y=4 -> [3,4]
449
+ * @param inputs - The two values
450
+ * @returns The vector `[x, y]`
289
451
  * @group create
290
452
  * @shortname vector XY
291
453
  * @drawable true
454
+ * @example
455
+ * ```typescript
456
+ * const right = bitbybit.vector.vectorXY({ x: 1, y: 0 });
457
+ * ```
292
458
  */
293
459
  vectorXY(inputs: Inputs.Vector.VectorXYDto): Inputs.Base.Vector2;
294
460
  /**
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]
297
- * @param inputs Max value for the range
298
- * @returns Vector containing items from 0 to max
461
+ * Lists the whole numbers from 0 up to, but not including, `max`.
462
+ *
463
+ * Example: max=5 -> [0,1,2,3,4]
464
+ * @param inputs - The end of the range, which is left out
465
+ * @returns The numbers from 0 to max - 1
299
466
  * @group create
300
467
  * @shortname range
301
468
  * @drawable false
469
+ * @example
470
+ * ```typescript
471
+ * const indices = bitbybit.vector.range({ max: 5 });
472
+ * ```
302
473
  */
303
474
  range(inputs: Inputs.Vector.RangeMaxDto): number[];
304
475
  /**
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
307
- * @param inputs Contains information of two vectors and a reference vector
308
- * @returns Signed angle in degrees
476
+ * Measures the angle from the first vector to the second, turning around a reference direction,
477
+ * in degrees from 0 to 360.
478
+ *
479
+ * The turn is counter-clockwise when the reference vector points toward you: a clockwise turn
480
+ * of 30 degrees reads as 330.
481
+ * Example: [1,0,0] to [0,0,-1] around [0,1,0] -> 90
482
+ * @param inputs - The two vectors and the reference direction to turn around
483
+ * @returns Angle in degrees from 0 to 360
309
484
  * @group angles
310
485
  * @shortname signed angle
311
486
  * @drawable false
487
+ * @example
488
+ * ```typescript
489
+ * const angle = bitbybit.vector.signedAngleBetween({ first: [1, 0, 0], second: [0, 0, -1], reference: [0, 1, 0] });
490
+ * ```
312
491
  */
313
492
  signedAngleBetween(inputs: Inputs.Vector.TwoVectorsReferenceDto): number;
314
493
  /**
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]
317
- * @param inputs Span information containing min, max and step values
318
- * @returns Vector containing number between min, max and increasing at a given step
494
+ * Lists the numbers from `min` to `max`, stepping by `step`; `max` is included when a step
495
+ * lands on it.
496
+ *
497
+ * Example: min=0, max=10, step=2 -> [0,2,4,6,8,10]
498
+ * @param inputs - The start, the end and the step
499
+ * @returns The numbers in the span
319
500
  * @group create
320
501
  * @shortname span
321
502
  * @drawable false
503
+ * @example
504
+ * ```typescript
505
+ * const values = bitbybit.vector.span({ min: 0, max: 10, step: 2.5 });
506
+ * ```
322
507
  */
323
508
  span(inputs: Inputs.Vector.SpanDto): number[];
324
509
  /**
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
327
- * @param inputs Span information containing min, max and ease function
328
- * @returns Vector containing numbers between min, max and increasing in non-linear steps defined by nr of items in the vector and type
510
+ * Lists `nrItems` numbers from `min` to `max` spaced by an easing curve, so they bunch up at
511
+ * one end or both.
512
+ *
513
+ * With `intervals` on, the result holds the gaps between neighbors instead of the values
514
+ * themselves.
515
+ * Example: min=0, max=100, nrItems=5, ease='easeInQuad' -> [0, 6.25, 25, 56.25, 100]
516
+ * @param inputs - The start, the end, the number of items, the easing and whether to return the gaps
517
+ * @returns The eased numbers, or the gaps between them
329
518
  * @group create
330
519
  * @shortname span ease items
331
520
  * @drawable false
521
+ * @example
522
+ * ```typescript
523
+ * const eased = bitbybit.vector.spanEaseItems({ min: 0, max: 100, nrItems: 5, ease: Bit.Inputs.Math.easeEnum.easeInQuad, intervals: false });
524
+ * ```
332
525
  */
333
526
  spanEaseItems(inputs: Inputs.Vector.SpanEaseItemsDto): number[];
334
527
  /**
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]
337
- * @param inputs Span information containing min, max and step values
338
- * @returns Vector containing number between min, max by giving nr of items
528
+ * Lists `nrItems` evenly spaced numbers from `min` to `max`, both included.
529
+ *
530
+ * Example: min=0, max=10, nrItems=5 -> [0, 2.5, 5, 7.5, 10]
531
+ * @param inputs - The start, the end and the number of items
532
+ * @returns The evenly spaced numbers
339
533
  * @group create
340
534
  * @shortname span linear items
341
535
  * @drawable false
536
+ * @example
537
+ * ```typescript
538
+ * const values = bitbybit.vector.spanLinearItems({ min: 0, max: 10, nrItems: 5 });
539
+ * ```
342
540
  */
343
541
  spanLinearItems(inputs: Inputs.Vector.SpanLinearItemsDto): number[];
344
542
  /**
345
- * Subtracts the second vector from the first element-wise.
346
- * Example: [10,20,30] - [1,2,3] → [9,18,27]
347
- * @param inputs Two vectors
348
- * @returns Vector that result by subtraction two vectors
543
+ * Subtracts the second vector from the first, entry by entry.
544
+ *
545
+ * Example: [10,20,30] - [1,2,3] -> [9,18,27]
546
+ * @param inputs - The vector to subtract from and the vector to subtract
547
+ * @returns The vector of differences
349
548
  * @group base
350
549
  * @shortname sub
351
550
  * @drawable false
551
+ * @example
552
+ * ```typescript
553
+ * const diff = bitbybit.vector.sub({ first: [10, 20, 30], second: [1, 2, 3] });
554
+ * ```
352
555
  */
353
556
  sub(inputs: Inputs.Vector.TwoVectorsDto): number[];
354
557
  /**
355
- * Sums all values in the vector and returns a single number.
356
- * Example: [1,2,3,4] → 10, [5,10,15] → 30
357
- * @param inputs Vector to sum
358
- * @returns Number that results by adding up all values in the vector
558
+ * Adds up all values of a vector into one number.
559
+ *
560
+ * Example: [1,2,3,4] -> 10
561
+ * @param inputs - The vector to add up
562
+ * @returns The total
359
563
  * @group base
360
564
  * @shortname sum
361
565
  * @drawable false
566
+ * @example
567
+ * ```typescript
568
+ * const total = bitbybit.vector.sum({ vector: [1, 2, 3, 4] });
569
+ * ```
362
570
  */
363
571
  sum(inputs: Inputs.Vector.VectorDto): number;
364
572
  /**
365
- * Computes the squared length (squared magnitude) of a 3D vector.
366
- * Example: [3,4,0] → 25 (length 5 squared)
367
- * @param inputs Vector to compute the length
368
- * @returns Number that is squared length of the vector
573
+ * Computes the squared length of a 3D vector, which avoids the square root when only comparing
574
+ * lengths.
575
+ *
576
+ * Example: [3,4,0] -> 25
577
+ * @param inputs - The 3D vector
578
+ * @returns The squared length
369
579
  * @group base
370
580
  * @shortname length squared
371
581
  * @drawable false
582
+ * @example
583
+ * ```typescript
584
+ * const l2 = bitbybit.vector.lengthSq({ vector: [3, 4, 0] });
585
+ * ```
372
586
  */
373
587
  lengthSq(inputs: Inputs.Vector.Vector3Dto): number;
374
588
  /**
375
- * Computes the length (magnitude) of a 3D vector.
376
- * Example: [3,4,0] → 5, [1,0,0] → 1
377
- * @param inputs Vector to compute the length
378
- * @returns Number that is length of the vector
589
+ * Computes the length of a 3D vector.
590
+ *
591
+ * Example: [3,4,0] -> 5
592
+ * @param inputs - The 3D vector
593
+ * @returns The length in model units
379
594
  * @group base
380
595
  * @shortname length
381
596
  * @drawable false
597
+ * @example
598
+ * ```typescript
599
+ * const len = bitbybit.vector.length({ vector: [3, 4, 0] });
600
+ * ```
382
601
  */
383
602
  length(inputs: Inputs.Vector.Vector3Dto): number;
384
603
  /**
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
604
+ * Turns a list of number strings into numbers.
605
+ *
606
+ * A string that is not a number becomes NaN.
607
+ * Example: ['1', '2.5', '3'] -> [1, 2.5, 3]
608
+ * @param inputs - The strings to parse
609
+ * @returns The numbers
389
610
  * @group create
390
611
  * @shortname parse numbers
391
612
  * @drawable false
613
+ * @example
614
+ * ```typescript
615
+ * const numbers = bitbybit.vector.parseNumbers({ vector: ["1", "2.5", "-3"] });
616
+ * ```
392
617
  */
393
618
  parseNumbers(inputs: Inputs.Vector.VectorStringDto): number[];
394
619
  }