@bitbybit-dev/base 0.19.0-alpha.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.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/babel.config.cjs +14 -0
- package/babel.config.d.cts +5 -0
- package/index.d.ts +1 -0
- package/index.js +4 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/inputs/base-inputs.d.ts +35 -0
- package/lib/api/inputs/base-inputs.js +1 -0
- package/lib/api/inputs/color-inputs.d.ts +122 -0
- package/lib/api/inputs/color-inputs.js +164 -0
- package/lib/api/inputs/index.d.ts +8 -0
- package/lib/api/inputs/index.js +8 -0
- package/lib/api/inputs/inputs.d.ts +10 -0
- package/lib/api/inputs/inputs.js +10 -0
- package/lib/api/inputs/lists-inputs.d.ts +478 -0
- package/lib/api/inputs/lists-inputs.js +576 -0
- package/lib/api/inputs/logic-inputs.d.ts +163 -0
- package/lib/api/inputs/logic-inputs.js +111 -0
- package/lib/api/inputs/math-inputs.d.ts +311 -0
- package/lib/api/inputs/math-inputs.js +391 -0
- package/lib/api/inputs/point-inputs.d.ts +446 -0
- package/lib/api/inputs/point-inputs.js +521 -0
- package/lib/api/inputs/text-inputs.d.ts +83 -0
- package/lib/api/inputs/text-inputs.js +120 -0
- package/lib/api/inputs/transforms-inputs.d.ts +136 -0
- package/lib/api/inputs/transforms-inputs.js +200 -0
- package/lib/api/inputs/vector-inputs.d.ts +300 -0
- package/lib/api/inputs/vector-inputs.js +304 -0
- package/lib/api/services/color.d.ts +114 -0
- package/lib/api/services/color.js +170 -0
- package/lib/api/services/geometry-helper.d.ts +15 -0
- package/lib/api/services/geometry-helper.js +151 -0
- package/lib/api/services/index.d.ts +9 -0
- package/lib/api/services/index.js +9 -0
- package/lib/api/services/lists.d.ts +287 -0
- package/lib/api/services/lists.js +682 -0
- package/lib/api/services/logic.d.ts +99 -0
- package/lib/api/services/logic.js +203 -0
- package/lib/api/services/math.d.ts +349 -0
- package/lib/api/services/math.js +621 -0
- package/lib/api/services/point.d.ts +223 -0
- package/lib/api/services/point.js +351 -0
- package/lib/api/services/text.d.ts +69 -0
- package/lib/api/services/text.js +84 -0
- package/lib/api/services/transforms.d.ts +122 -0
- package/lib/api/services/transforms.js +256 -0
- package/lib/api/services/vector.d.ts +320 -0
- package/lib/api/services/vector.js +468 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import * as Inputs from "../inputs/inputs";
|
|
2
|
+
import { GeometryHelper } from "./geometry-helper";
|
|
3
|
+
import { MathBitByBit } from "./math";
|
|
4
|
+
/**
|
|
5
|
+
* Contains various methods for vector mathematics. Vector in bitbybit is simply an array, usually containing numbers.
|
|
6
|
+
* In 3D [x, y, z] form describes space, where y is the up vector.
|
|
7
|
+
* Because of this form Vector can be interchanged with Point, which also is an array in [x, y, z] form.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Vector {
|
|
10
|
+
private readonly math;
|
|
11
|
+
private readonly geometryHelper;
|
|
12
|
+
constructor(math: MathBitByBit, geometryHelper: GeometryHelper);
|
|
13
|
+
/**
|
|
14
|
+
* Removes all duplicate vectors from the input array
|
|
15
|
+
* @param inputs Contains vectors and a tolerance value
|
|
16
|
+
* @returns Array of vectors without duplicates
|
|
17
|
+
* @group remove
|
|
18
|
+
* @shortname remove all duplicates
|
|
19
|
+
* @drawable false
|
|
20
|
+
*/
|
|
21
|
+
removeAllDuplicateVectors(inputs: Inputs.Vector.RemoveAllDuplicateVectorsDto): number[][];
|
|
22
|
+
/**
|
|
23
|
+
* Removes consecutive duplicate vectors from the input array
|
|
24
|
+
* @param inputs Contains vectors and a tolerance value
|
|
25
|
+
* @returns Array of vectors without duplicates
|
|
26
|
+
* @group remove
|
|
27
|
+
* @shortname remove consecutive duplicates
|
|
28
|
+
* @drawable false
|
|
29
|
+
*/
|
|
30
|
+
removeConsecutiveDuplicateVectors(inputs: Inputs.Vector.RemoveConsecutiveDuplicateVectorsDto): number[][];
|
|
31
|
+
/**
|
|
32
|
+
* Measures the angle between two vectors in degrees
|
|
33
|
+
* @param inputs Contains two vectors represented as number arrays
|
|
34
|
+
* @group angles
|
|
35
|
+
* @shortname angle
|
|
36
|
+
* @returns Number in degrees
|
|
37
|
+
* @drawable false
|
|
38
|
+
*/
|
|
39
|
+
angleBetween(inputs: Inputs.Vector.TwoVectorsDto): number;
|
|
40
|
+
/**
|
|
41
|
+
* Measures the normalized 2d angle between two vectors in degrees
|
|
42
|
+
* @param inputs Contains two vectors represented as number arrays
|
|
43
|
+
* @returns Number in degrees
|
|
44
|
+
* @group angles
|
|
45
|
+
* @shortname angle normalized 2d
|
|
46
|
+
* @drawable false
|
|
47
|
+
*/
|
|
48
|
+
angleBetweenNormalized2d(inputs: Inputs.Vector.TwoVectorsDto): number;
|
|
49
|
+
/**
|
|
50
|
+
* Measures a positive angle between two vectors given the reference vector in degrees
|
|
51
|
+
* @param inputs Contains information of two vectors and a reference vector
|
|
52
|
+
* @returns Number in degrees
|
|
53
|
+
* @group angles
|
|
54
|
+
* @shortname positive angle
|
|
55
|
+
* @drawable false
|
|
56
|
+
*/
|
|
57
|
+
positiveAngleBetween(inputs: Inputs.Vector.TwoVectorsReferenceDto): number;
|
|
58
|
+
/**
|
|
59
|
+
* Adds all vector xyz values together and create a new vector
|
|
60
|
+
* @param inputs Vectors to be added
|
|
61
|
+
* @returns New vector that has xyz values as sums of all the vectors
|
|
62
|
+
* @group sum
|
|
63
|
+
* @shortname add all
|
|
64
|
+
* @drawable false
|
|
65
|
+
*/
|
|
66
|
+
addAll(inputs: Inputs.Vector.VectorsDto): number[];
|
|
67
|
+
/**
|
|
68
|
+
* Adds two vectors together
|
|
69
|
+
* @param inputs Two vectors to be added
|
|
70
|
+
* @returns Number array representing vector
|
|
71
|
+
* @group sum
|
|
72
|
+
* @shortname add
|
|
73
|
+
* @drawable false
|
|
74
|
+
*/
|
|
75
|
+
add(inputs: Inputs.Vector.TwoVectorsDto): number[];
|
|
76
|
+
/**
|
|
77
|
+
* Checks if the boolean array contains only true values, if there's a single false it will return false.
|
|
78
|
+
* @param inputs Vectors to be checked
|
|
79
|
+
* @returns Boolean indicating if vector contains only true values
|
|
80
|
+
* @group sum
|
|
81
|
+
* @shortname all
|
|
82
|
+
* @drawable false
|
|
83
|
+
*/
|
|
84
|
+
all(inputs: Inputs.Vector.VectorBoolDto): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Cross two vectors
|
|
87
|
+
* @param inputs Two vectors to be crossed
|
|
88
|
+
* @group base
|
|
89
|
+
* @shortname all
|
|
90
|
+
* @returns Crossed vector
|
|
91
|
+
* @drawable false
|
|
92
|
+
*/
|
|
93
|
+
cross(inputs: Inputs.Vector.TwoVectorsDto): number[];
|
|
94
|
+
/**
|
|
95
|
+
* Squared distance between two vectors
|
|
96
|
+
* @param inputs Two vectors
|
|
97
|
+
* @returns Number representing squared distance between two vectors
|
|
98
|
+
* @group distance
|
|
99
|
+
* @shortname dist squared
|
|
100
|
+
* @drawable false
|
|
101
|
+
*/
|
|
102
|
+
distSquared(inputs: Inputs.Vector.TwoVectorsDto): number;
|
|
103
|
+
/**
|
|
104
|
+
* Distance between two vectors
|
|
105
|
+
* @param inputs Two vectors
|
|
106
|
+
* @returns Number representing distance between two vectors
|
|
107
|
+
* @group distance
|
|
108
|
+
* @shortname dist
|
|
109
|
+
* @drawable false
|
|
110
|
+
*/
|
|
111
|
+
dist(inputs: Inputs.Vector.TwoVectorsDto): number;
|
|
112
|
+
/**
|
|
113
|
+
* Divide the vector by a scalar value
|
|
114
|
+
* @param inputs Contains vector and a scalar
|
|
115
|
+
* @returns Vector that is a result of division by a scalar
|
|
116
|
+
* @group base
|
|
117
|
+
* @shortname div
|
|
118
|
+
* @drawable false
|
|
119
|
+
*/
|
|
120
|
+
div(inputs: Inputs.Vector.VectorScalarDto): number[];
|
|
121
|
+
/**
|
|
122
|
+
* Computes the domain between minimum and maximum values of the vector
|
|
123
|
+
* @param inputs Vector information
|
|
124
|
+
* @returns Number representing distance between two vectors
|
|
125
|
+
* @group base
|
|
126
|
+
* @shortname domain
|
|
127
|
+
* @drawable false
|
|
128
|
+
*/
|
|
129
|
+
domain(inputs: Inputs.Vector.VectorDto): number;
|
|
130
|
+
/**
|
|
131
|
+
* Dot product between two vectors
|
|
132
|
+
* @param inputs Two vectors
|
|
133
|
+
* @returns Number representing dot product of the vector
|
|
134
|
+
* @group base
|
|
135
|
+
* @shortname dot
|
|
136
|
+
* @drawable false
|
|
137
|
+
*/
|
|
138
|
+
dot(inputs: Inputs.Vector.TwoVectorsDto): number;
|
|
139
|
+
/**
|
|
140
|
+
* Checks if vector is finite for each number and returns a boolean array
|
|
141
|
+
* @param inputs Vector with possibly infinite values
|
|
142
|
+
* @returns Vector array that contains boolean values for each number in the input
|
|
143
|
+
* vector that identifies if value is finite (true) or infinite (false)
|
|
144
|
+
* @group validate
|
|
145
|
+
* @shortname finite
|
|
146
|
+
* @drawable false
|
|
147
|
+
*/
|
|
148
|
+
finite(inputs: Inputs.Vector.VectorDto): boolean[];
|
|
149
|
+
/**
|
|
150
|
+
* Checks if the vector is zero length
|
|
151
|
+
* @param inputs Vector to be checked
|
|
152
|
+
* @returns Boolean that identifies if vector is zero length
|
|
153
|
+
* @group validate
|
|
154
|
+
* @shortname isZero
|
|
155
|
+
* @drawable false
|
|
156
|
+
*/
|
|
157
|
+
isZero(inputs: Inputs.Vector.VectorDto): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Finds in between vector between two vectors by providing a fracture
|
|
160
|
+
* @param inputs Information for finding vector between two vectors using a fraction
|
|
161
|
+
* @returns Vector that is in between two vectors
|
|
162
|
+
* @group distance
|
|
163
|
+
* @shortname lerp
|
|
164
|
+
* @drawable false
|
|
165
|
+
*/
|
|
166
|
+
lerp(inputs: Inputs.Vector.FractionTwoVectorsDto): number[];
|
|
167
|
+
/**
|
|
168
|
+
* Finds the maximum value in the vector
|
|
169
|
+
* @param inputs Vector to be checked
|
|
170
|
+
* @returns Largest number in the vector
|
|
171
|
+
* @group extract
|
|
172
|
+
* @shortname max
|
|
173
|
+
* @drawable false
|
|
174
|
+
*/
|
|
175
|
+
max(inputs: Inputs.Vector.VectorDto): number;
|
|
176
|
+
/**
|
|
177
|
+
* Finds the minimum value in the vector
|
|
178
|
+
* @param inputs Vector to be checked
|
|
179
|
+
* @returns Lowest number in the vector
|
|
180
|
+
* @group extract
|
|
181
|
+
* @shortname min
|
|
182
|
+
* @drawable false
|
|
183
|
+
*/
|
|
184
|
+
min(inputs: Inputs.Vector.VectorDto): number;
|
|
185
|
+
/**
|
|
186
|
+
* Multiple vector with the scalar
|
|
187
|
+
* @param inputs Vector with a scalar
|
|
188
|
+
* @returns Vector that results from multiplication
|
|
189
|
+
* @group base
|
|
190
|
+
* @shortname mul
|
|
191
|
+
* @drawable false
|
|
192
|
+
*/
|
|
193
|
+
mul(inputs: Inputs.Vector.VectorScalarDto): number[];
|
|
194
|
+
/**
|
|
195
|
+
* Negates the vector
|
|
196
|
+
* @param inputs Vector to negate
|
|
197
|
+
* @returns Negative vector
|
|
198
|
+
* @group base
|
|
199
|
+
* @shortname neg
|
|
200
|
+
* @drawable false
|
|
201
|
+
*/
|
|
202
|
+
neg(inputs: Inputs.Vector.VectorDto): number[];
|
|
203
|
+
/**
|
|
204
|
+
* Compute squared norm
|
|
205
|
+
* @param inputs Vector for squared norm
|
|
206
|
+
* @returns Number that is squared norm
|
|
207
|
+
* @group base
|
|
208
|
+
* @shortname norm squared
|
|
209
|
+
* @drawable false
|
|
210
|
+
*/
|
|
211
|
+
normSquared(inputs: Inputs.Vector.VectorDto): number;
|
|
212
|
+
/**
|
|
213
|
+
* Norm of the vector
|
|
214
|
+
* @param inputs Vector to compute the norm
|
|
215
|
+
* @returns Number that is norm of the vector
|
|
216
|
+
* @group base
|
|
217
|
+
* @shortname norm
|
|
218
|
+
* @drawable false
|
|
219
|
+
*/
|
|
220
|
+
norm(inputs: Inputs.Vector.VectorDto): number;
|
|
221
|
+
/**
|
|
222
|
+
* Normalize the vector into a unit vector, that has a length of 1
|
|
223
|
+
* @param inputs Vector to normalize
|
|
224
|
+
* @returns Unit vector that has length of 1
|
|
225
|
+
* @group base
|
|
226
|
+
* @shortname normalized
|
|
227
|
+
* @drawable false
|
|
228
|
+
*/
|
|
229
|
+
normalized(inputs: Inputs.Vector.VectorDto): number[];
|
|
230
|
+
/**
|
|
231
|
+
* Finds a point coordinates on the given distance ray that spans between the point along the direction vector
|
|
232
|
+
* @param inputs Provide a point, vector and a distance for finding a point
|
|
233
|
+
* @returns Vector representing point on the ray
|
|
234
|
+
* @group base
|
|
235
|
+
* @shortname on ray
|
|
236
|
+
* @drawable false
|
|
237
|
+
*/
|
|
238
|
+
onRay(inputs: Inputs.Vector.RayPointDto): number[];
|
|
239
|
+
/**
|
|
240
|
+
* Create a xyz vector
|
|
241
|
+
* @param inputs Vector coordinates
|
|
242
|
+
* @returns Create a vector of xyz values
|
|
243
|
+
* @group create
|
|
244
|
+
* @shortname vector XYZ
|
|
245
|
+
* @drawable true
|
|
246
|
+
*/
|
|
247
|
+
vectorXYZ(inputs: Inputs.Vector.VectorXYZDto): Inputs.Base.Vector3;
|
|
248
|
+
/**
|
|
249
|
+
* Create 2d xy vector
|
|
250
|
+
* @param inputs Vector coordinates
|
|
251
|
+
* @returns Create a vector of xy values
|
|
252
|
+
* @group create
|
|
253
|
+
* @shortname vector XY
|
|
254
|
+
* @drawable true
|
|
255
|
+
*/
|
|
256
|
+
vectorXY(inputs: Inputs.Vector.VectorXYDto): Inputs.Base.Vector2;
|
|
257
|
+
/**
|
|
258
|
+
* Creates a vector of integers between 0 and maximum ceiling integer
|
|
259
|
+
* @param inputs Max value for the range
|
|
260
|
+
* @returns Vector containing items from 0 to max
|
|
261
|
+
* @group create
|
|
262
|
+
* @shortname range
|
|
263
|
+
* @drawable false
|
|
264
|
+
*/
|
|
265
|
+
range(inputs: Inputs.Vector.RangeMaxDto): number[];
|
|
266
|
+
/**
|
|
267
|
+
* Computes signed angle between two vectors and a reference. This will always return a smaller angle between two possible angles.
|
|
268
|
+
* @param inputs Contains information of two vectors and a reference vector
|
|
269
|
+
* @returns Signed angle in degrees
|
|
270
|
+
* @group angles
|
|
271
|
+
* @shortname signed angle
|
|
272
|
+
* @drawable false
|
|
273
|
+
*/
|
|
274
|
+
signedAngleBetween(inputs: Inputs.Vector.TwoVectorsReferenceDto): number;
|
|
275
|
+
/**
|
|
276
|
+
* Creates a vector that contains numbers spanning between minimum and maximum values at a given step
|
|
277
|
+
* @param inputs Span information containing min, max and step values
|
|
278
|
+
* @returns Vector containing number between min, max and increasing at a given step
|
|
279
|
+
* @group create
|
|
280
|
+
* @shortname span
|
|
281
|
+
* @drawable false
|
|
282
|
+
*/
|
|
283
|
+
span(inputs: Inputs.Vector.SpanDto): number[];
|
|
284
|
+
/**
|
|
285
|
+
* Creates a vector that contains numbers spanning between minimum and maximum values at a given ease function
|
|
286
|
+
* @param inputs Span information containing min, max and ease function
|
|
287
|
+
* @returns Vector containing numbers between min, max and increasing in non-linear steps defined by nr of items in the vector and type
|
|
288
|
+
* @group create
|
|
289
|
+
* @shortname span ease items
|
|
290
|
+
* @drawable false
|
|
291
|
+
*/
|
|
292
|
+
spanEaseItems(inputs: Inputs.Vector.SpanEaseItemsDto): number[];
|
|
293
|
+
/**
|
|
294
|
+
* Creates a vector that contains numbers spanning between minimum and maximum values by giving nr of items
|
|
295
|
+
* @param inputs Span information containing min, max and step values
|
|
296
|
+
* @returns Vector containing number between min, max by giving nr of items
|
|
297
|
+
* @group create
|
|
298
|
+
* @shortname span linear items
|
|
299
|
+
* @drawable false
|
|
300
|
+
*/
|
|
301
|
+
spanLinearItems(inputs: Inputs.Vector.SpanLinearItemsDto): number[];
|
|
302
|
+
/**
|
|
303
|
+
* Subtract two vectors
|
|
304
|
+
* @param inputs Two vectors
|
|
305
|
+
* @returns Vector that result by subtraction two vectors
|
|
306
|
+
* @group base
|
|
307
|
+
* @shortname sub
|
|
308
|
+
* @drawable false
|
|
309
|
+
*/
|
|
310
|
+
sub(inputs: Inputs.Vector.TwoVectorsDto): number[];
|
|
311
|
+
/**
|
|
312
|
+
* Sums the values of the vector
|
|
313
|
+
* @param inputs Vector to sum
|
|
314
|
+
* @returns Number that results by adding up all values in the vector
|
|
315
|
+
* @group base
|
|
316
|
+
* @shortname sum
|
|
317
|
+
* @drawable false
|
|
318
|
+
*/
|
|
319
|
+
sum(inputs: Inputs.Vector.VectorDto): number;
|
|
320
|
+
}
|