@bitbybit-dev/base 0.19.9 → 0.20.1
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/inputs/base-inputs.d.ts +35 -0
- package/lib/api/inputs/base-inputs.js +19 -1
- package/lib/api/inputs/dates-inputs.d.ts +216 -0
- package/lib/api/inputs/dates-inputs.js +271 -0
- package/lib/api/inputs/index.d.ts +1 -0
- package/lib/api/inputs/index.js +1 -0
- package/lib/api/inputs/inputs.d.ts +1 -0
- package/lib/api/inputs/inputs.js +1 -0
- package/lib/api/inputs/point-inputs.d.ts +23 -0
- package/lib/api/inputs/point-inputs.js +22 -0
- package/lib/api/inputs/text-inputs.d.ts +106 -0
- package/lib/api/inputs/text-inputs.js +141 -0
- package/lib/api/inputs/vector-inputs.d.ts +20 -0
- package/lib/api/inputs/vector-inputs.js +21 -0
- package/lib/api/models/index.d.ts +1 -0
- package/lib/api/models/index.js +1 -0
- package/lib/api/models/simplex.d.ts +206 -0
- package/lib/api/models/simplex.js +112 -0
- package/lib/api/models/text/bucket.d.ts +2 -0
- package/lib/api/models/text/bucket.js +2 -0
- package/lib/api/models/text/index.d.ts +1 -0
- package/lib/api/models/text/index.js +1 -0
- package/lib/api/models/text/vector-char-data.d.ts +19 -0
- package/lib/api/models/text/vector-char-data.js +13 -0
- package/lib/api/models/text/vector-text-data.d.ts +19 -0
- package/lib/api/models/text/vector-text-data.js +13 -0
- package/lib/api/services/dates.d.ts +367 -0
- package/lib/api/services/dates.js +450 -0
- package/lib/api/services/index.d.ts +1 -0
- package/lib/api/services/index.js +1 -0
- package/lib/api/services/point.d.ts +21 -1
- package/lib/api/services/point.js +79 -1
- package/lib/api/services/text.d.ts +24 -0
- package/lib/api/services/text.js +157 -0
- package/lib/api/services/vector.d.ts +9 -0
- package/lib/api/services/vector.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains various date methods.
|
|
3
|
+
*/
|
|
4
|
+
export class Dates {
|
|
5
|
+
/**
|
|
6
|
+
* Returns a date as a string value.
|
|
7
|
+
* @param inputs a date
|
|
8
|
+
* @returns date as string
|
|
9
|
+
* @group convert
|
|
10
|
+
* @shortname date to string
|
|
11
|
+
* @drawable false
|
|
12
|
+
*/
|
|
13
|
+
toDateString(inputs) {
|
|
14
|
+
return inputs.date.toDateString();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns a date as a string value in ISO format.
|
|
18
|
+
* @param inputs a date
|
|
19
|
+
* @returns date as string
|
|
20
|
+
* @group convert
|
|
21
|
+
* @shortname date to iso string
|
|
22
|
+
* @drawable false
|
|
23
|
+
*/
|
|
24
|
+
toISOString(inputs) {
|
|
25
|
+
return inputs.date.toISOString();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns a date as a string value in JSON format.
|
|
29
|
+
* @param inputs a date
|
|
30
|
+
* @returns date as string
|
|
31
|
+
* @group convert
|
|
32
|
+
* @shortname date to json
|
|
33
|
+
* @drawable false
|
|
34
|
+
*/
|
|
35
|
+
toJSON(inputs) {
|
|
36
|
+
return inputs.date.toJSON();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns a string representation of a date. The format of the string depends on the locale.
|
|
40
|
+
* @param inputs a date
|
|
41
|
+
* @returns date as string
|
|
42
|
+
* @group convert
|
|
43
|
+
* @shortname date to locale string
|
|
44
|
+
* @drawable false
|
|
45
|
+
*/
|
|
46
|
+
toString(inputs) {
|
|
47
|
+
return inputs.date.toString();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns a time as a string value.
|
|
51
|
+
* @param inputs a date
|
|
52
|
+
* @returns time as string
|
|
53
|
+
* @group convert
|
|
54
|
+
* @shortname date to time string
|
|
55
|
+
* @drawable false
|
|
56
|
+
*/
|
|
57
|
+
toTimeString(inputs) {
|
|
58
|
+
return inputs.date.toTimeString();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns a date converted to a string using Universal Coordinated Time (UTC).
|
|
62
|
+
* @param inputs a date
|
|
63
|
+
* @returns date as utc string
|
|
64
|
+
* @group convert
|
|
65
|
+
* @shortname date to utc string
|
|
66
|
+
* @drawable false
|
|
67
|
+
*/
|
|
68
|
+
toUTCString(inputs) {
|
|
69
|
+
return inputs.date.toUTCString();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the current date and time.
|
|
73
|
+
* @returns date
|
|
74
|
+
* @group create
|
|
75
|
+
* @shortname now
|
|
76
|
+
* @drawable false
|
|
77
|
+
*/
|
|
78
|
+
now() {
|
|
79
|
+
return new Date(Date.now());
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new date object using the provided date params.
|
|
83
|
+
* @param inputs a date
|
|
84
|
+
* @returns date
|
|
85
|
+
* @group create
|
|
86
|
+
* @shortname create date
|
|
87
|
+
* @drawable false
|
|
88
|
+
*/
|
|
89
|
+
createDate(inputs) {
|
|
90
|
+
return new Date(inputs.year, inputs.month, inputs.day, inputs.hours, inputs.minutes, inputs.seconds, inputs.milliseconds);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
|
|
94
|
+
* @param inputs a date
|
|
95
|
+
* @returns date
|
|
96
|
+
* @group create
|
|
97
|
+
* @shortname create utc date
|
|
98
|
+
* @drawable false
|
|
99
|
+
*/
|
|
100
|
+
createDateUTC(inputs) {
|
|
101
|
+
return new Date(Date.UTC(inputs.year, inputs.month, inputs.day, inputs.hours, inputs.minutes, inputs.seconds, inputs.milliseconds));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a new date object using the provided unix time stamp.
|
|
105
|
+
* @param inputs a unix time stamp
|
|
106
|
+
* @returns date
|
|
107
|
+
* @group create
|
|
108
|
+
* @shortname create from unix timestamp
|
|
109
|
+
* @drawable false
|
|
110
|
+
*/
|
|
111
|
+
createFromUnixTimeStamp(inputs) {
|
|
112
|
+
return new Date(inputs.unixTimeStamp);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970.
|
|
116
|
+
* @param inputs a date string
|
|
117
|
+
* @returns the number of milliseconds between that date and midnight, January 1, 1970.
|
|
118
|
+
* @group parse
|
|
119
|
+
* @shortname parse date string
|
|
120
|
+
* @drawable false
|
|
121
|
+
*/
|
|
122
|
+
parseDate(inputs) {
|
|
123
|
+
return Date.parse(inputs.dateString);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Gets the day-of-the-month, using local time.
|
|
127
|
+
* @returns date
|
|
128
|
+
* @group get
|
|
129
|
+
* @shortname get date of month
|
|
130
|
+
* @drawable false
|
|
131
|
+
*/
|
|
132
|
+
getDayOfMonth(inputs) {
|
|
133
|
+
return inputs.date.getDate();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Gets the day of the week, using local time.
|
|
137
|
+
* @returns day
|
|
138
|
+
* @group get
|
|
139
|
+
* @shortname get weekday
|
|
140
|
+
* @drawable false
|
|
141
|
+
*/
|
|
142
|
+
getWeekday(inputs) {
|
|
143
|
+
return inputs.date.getDay();
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Gets the year, using local time.
|
|
147
|
+
* @returns year
|
|
148
|
+
* @group get
|
|
149
|
+
* @shortname get year
|
|
150
|
+
* @drawable false
|
|
151
|
+
*/
|
|
152
|
+
getYear(inputs) {
|
|
153
|
+
return inputs.date.getFullYear();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Gets the month, using local time.
|
|
157
|
+
* @returns month
|
|
158
|
+
* @group get
|
|
159
|
+
* @shortname get month
|
|
160
|
+
* @drawable false
|
|
161
|
+
*/
|
|
162
|
+
getMonth(inputs) {
|
|
163
|
+
return inputs.date.getMonth();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Gets the hours in a date, using local time.
|
|
167
|
+
* @returns hours
|
|
168
|
+
* @group get
|
|
169
|
+
* @shortname get hours
|
|
170
|
+
* @drawable false
|
|
171
|
+
*/
|
|
172
|
+
getHours(inputs) {
|
|
173
|
+
return inputs.date.getHours();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Gets the minutes of a Date object, using local time.
|
|
177
|
+
* @returns minutes
|
|
178
|
+
* @group get
|
|
179
|
+
* @shortname get minutes
|
|
180
|
+
* @drawable false
|
|
181
|
+
*/
|
|
182
|
+
getMinutes(inputs) {
|
|
183
|
+
return inputs.date.getMinutes();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Gets the seconds of a Date object, using local time.
|
|
187
|
+
* @returns seconds
|
|
188
|
+
* @group get
|
|
189
|
+
* @shortname get seconds
|
|
190
|
+
* @drawable false
|
|
191
|
+
*/
|
|
192
|
+
getSeconds(inputs) {
|
|
193
|
+
return inputs.date.getSeconds();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Gets the milliseconds of a Date, using local time.
|
|
197
|
+
* @returns milliseconds
|
|
198
|
+
* @group get
|
|
199
|
+
* @shortname get milliseconds
|
|
200
|
+
* @drawable false
|
|
201
|
+
*/
|
|
202
|
+
getMilliseconds(inputs) {
|
|
203
|
+
return inputs.date.getMilliseconds();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
|
|
207
|
+
* @returns time
|
|
208
|
+
* @group get
|
|
209
|
+
* @shortname get time
|
|
210
|
+
* @drawable false
|
|
211
|
+
*/
|
|
212
|
+
getTime(inputs) {
|
|
213
|
+
return inputs.date.getTime();
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Gets the year using Universal Coordinated Time (UTC).
|
|
217
|
+
* @returns year
|
|
218
|
+
* @group get
|
|
219
|
+
* @shortname get utc year
|
|
220
|
+
* @drawable false
|
|
221
|
+
*/
|
|
222
|
+
getUTCYear(inputs) {
|
|
223
|
+
return inputs.date.getUTCFullYear();
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Gets the month of a Date object using Universal Coordinated Time (UTC).
|
|
227
|
+
* @returns month
|
|
228
|
+
* @group get
|
|
229
|
+
* @shortname get utc month
|
|
230
|
+
* @drawable false
|
|
231
|
+
*/
|
|
232
|
+
getUTCMonth(inputs) {
|
|
233
|
+
return inputs.date.getUTCMonth();
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Gets the day-of-the-month, using Universal Coordinated Time (UTC).
|
|
237
|
+
* @returns day
|
|
238
|
+
* @group get
|
|
239
|
+
* @shortname get utc day
|
|
240
|
+
* @drawable false
|
|
241
|
+
*/
|
|
242
|
+
getUTCDay(inputs) {
|
|
243
|
+
return inputs.date.getUTCDate();
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Gets the hours value in a Date object using Universal Coordinated Time (UTC).
|
|
247
|
+
* @returns hours
|
|
248
|
+
* @group get
|
|
249
|
+
* @shortname get utc hours
|
|
250
|
+
* @drawable false
|
|
251
|
+
*/
|
|
252
|
+
getUTCHours(inputs) {
|
|
253
|
+
return inputs.date.getUTCHours();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Gets the minutes of a Date object using Universal Coordinated Time (UTC).
|
|
257
|
+
* @returns minutes
|
|
258
|
+
* @group get
|
|
259
|
+
* @shortname get utc minutes
|
|
260
|
+
* @drawable false
|
|
261
|
+
*/
|
|
262
|
+
getUTCMinutes(inputs) {
|
|
263
|
+
return inputs.date.getUTCMinutes();
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Gets the seconds of a Date object using Universal Coordinated Time (UTC).
|
|
267
|
+
* @returns seconds
|
|
268
|
+
* @group get
|
|
269
|
+
* @shortname get utc seconds
|
|
270
|
+
* @drawable false
|
|
271
|
+
*/
|
|
272
|
+
getUTCSeconds(inputs) {
|
|
273
|
+
return inputs.date.getUTCSeconds();
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).
|
|
277
|
+
* @returns milliseconds
|
|
278
|
+
* @group get
|
|
279
|
+
* @shortname get utc milliseconds
|
|
280
|
+
* @drawable false
|
|
281
|
+
*/
|
|
282
|
+
getUTCMilliseconds(inputs) {
|
|
283
|
+
return inputs.date.getUTCMilliseconds();
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Sets the year of the Date object using local time.
|
|
287
|
+
* @param inputs a date and the year
|
|
288
|
+
* @returns date
|
|
289
|
+
* @group set
|
|
290
|
+
* @shortname set year
|
|
291
|
+
* @drawable false
|
|
292
|
+
* */
|
|
293
|
+
setYear(inputs) {
|
|
294
|
+
return new Date(inputs.date.setFullYear(inputs.year));
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Sets the month value in the Date object using local time.
|
|
298
|
+
* @param inputs a date and the month
|
|
299
|
+
* @returns date
|
|
300
|
+
* @group set
|
|
301
|
+
* @shortname set month
|
|
302
|
+
* @drawable false
|
|
303
|
+
* */
|
|
304
|
+
setMonth(inputs) {
|
|
305
|
+
return new Date(inputs.date.setMonth(inputs.month));
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Sets the numeric day-of-the-month value of the Date object using local time.
|
|
309
|
+
* @param inputs a date and the day
|
|
310
|
+
* @returns date
|
|
311
|
+
* @group set
|
|
312
|
+
* @shortname set day of month
|
|
313
|
+
* @drawable false
|
|
314
|
+
*/
|
|
315
|
+
setDayOfMonth(inputs) {
|
|
316
|
+
return new Date(inputs.date.setDate(inputs.day));
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Sets the hour value in the Date object using local time.
|
|
320
|
+
* @param inputs a date and the hours
|
|
321
|
+
* @returns date
|
|
322
|
+
* @group set
|
|
323
|
+
* @shortname set hours
|
|
324
|
+
* @drawable false
|
|
325
|
+
* */
|
|
326
|
+
setHours(inputs) {
|
|
327
|
+
return new Date(inputs.date.setHours(inputs.hours));
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Sets the minutes value in the Date object using local time.
|
|
331
|
+
* @param inputs a date and the minutes
|
|
332
|
+
* @returns date
|
|
333
|
+
* @group set
|
|
334
|
+
* @shortname set minutes
|
|
335
|
+
* @drawable false
|
|
336
|
+
* */
|
|
337
|
+
setMinutes(inputs) {
|
|
338
|
+
return new Date(inputs.date.setMinutes(inputs.minutes));
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Sets the seconds value in the Date object using local time.
|
|
342
|
+
* @param inputs a date and the seconds
|
|
343
|
+
* @returns date
|
|
344
|
+
* @group set
|
|
345
|
+
* @shortname set seconds
|
|
346
|
+
* @drawable false
|
|
347
|
+
*/
|
|
348
|
+
setSeconds(inputs) {
|
|
349
|
+
return new Date(inputs.date.setSeconds(inputs.seconds));
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Sets the milliseconds value in the Date object using local time.
|
|
353
|
+
* @param inputs a date and the milliseconds
|
|
354
|
+
* @returns date
|
|
355
|
+
* @group set
|
|
356
|
+
* @shortname set milliseconds
|
|
357
|
+
* @drawable false
|
|
358
|
+
*/
|
|
359
|
+
setMilliseconds(inputs) {
|
|
360
|
+
return new Date(inputs.date.setMilliseconds(inputs.milliseconds));
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Sets the date and time value in the Date object.
|
|
364
|
+
* @param inputs a date and the time
|
|
365
|
+
* @returns date
|
|
366
|
+
* @group set
|
|
367
|
+
* @shortname set time
|
|
368
|
+
* @drawable false
|
|
369
|
+
*/
|
|
370
|
+
setTime(inputs) {
|
|
371
|
+
return new Date(inputs.date.setTime(inputs.time));
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Sets the year value in the Date object using Universal Coordinated Time (UTC).
|
|
375
|
+
* @param inputs a date and the year
|
|
376
|
+
* @returns date
|
|
377
|
+
* @group set
|
|
378
|
+
* @shortname set utc year
|
|
379
|
+
* @drawable false
|
|
380
|
+
* */
|
|
381
|
+
setUTCYear(inputs) {
|
|
382
|
+
return new Date(inputs.date.setUTCFullYear(inputs.year));
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Sets the month value in the Date object using Universal Coordinated Time (UTC).
|
|
386
|
+
* @param inputs a date and the month
|
|
387
|
+
* @returns date
|
|
388
|
+
* @group set
|
|
389
|
+
* @shortname set utc month
|
|
390
|
+
* @drawable false
|
|
391
|
+
* */
|
|
392
|
+
setUTCMonth(inputs) {
|
|
393
|
+
return new Date(inputs.date.setUTCMonth(inputs.month));
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
|
|
397
|
+
* @param inputs a date and the day
|
|
398
|
+
* @returns date
|
|
399
|
+
* @group set
|
|
400
|
+
* @shortname set utc day
|
|
401
|
+
* @drawable false
|
|
402
|
+
*/
|
|
403
|
+
setUTCDay(inputs) {
|
|
404
|
+
return new Date(inputs.date.setUTCDate(inputs.day));
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Sets the hours value in the Date object using Universal Coordinated Time (UTC).
|
|
408
|
+
* @param inputs a date and the hours
|
|
409
|
+
* @returns date
|
|
410
|
+
* @group set
|
|
411
|
+
* @shortname set utc hours
|
|
412
|
+
* @drawable false
|
|
413
|
+
* */
|
|
414
|
+
setUTCHours(inputs) {
|
|
415
|
+
return new Date(inputs.date.setUTCHours(inputs.hours));
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
|
|
419
|
+
* @param inputs a date and the minutes
|
|
420
|
+
* @returns date
|
|
421
|
+
* @group set
|
|
422
|
+
* @shortname set utc minutes
|
|
423
|
+
* @drawable false
|
|
424
|
+
* */
|
|
425
|
+
setUTCMinutes(inputs) {
|
|
426
|
+
return new Date(inputs.date.setUTCMinutes(inputs.minutes));
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
|
|
430
|
+
* @param inputs a date and the seconds
|
|
431
|
+
* @returns date
|
|
432
|
+
* @group set
|
|
433
|
+
* @shortname set utc seconds
|
|
434
|
+
* @drawable false
|
|
435
|
+
*/
|
|
436
|
+
setUTCSeconds(inputs) {
|
|
437
|
+
return new Date(inputs.date.setUTCSeconds(inputs.seconds));
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
|
|
441
|
+
* @param inputs a date and the milliseconds
|
|
442
|
+
* @returns date
|
|
443
|
+
* @group set
|
|
444
|
+
* @shortname set utc milliseconds
|
|
445
|
+
* @drawable false
|
|
446
|
+
*/
|
|
447
|
+
setUTCMilliseconds(inputs) {
|
|
448
|
+
return new Date(inputs.date.setUTCMilliseconds(inputs.milliseconds));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GeometryHelper } from "./geometry-helper";
|
|
2
2
|
import * as Inputs from "../inputs";
|
|
3
3
|
import { Transforms } from "./transforms";
|
|
4
|
+
import { Vector } from "./vector";
|
|
4
5
|
/**
|
|
5
6
|
* Contains various methods for points. Point in bitbybit is simply an array containing 3 numbers for [x, y, z].
|
|
6
7
|
* Because of this form Point can be interchanged with Vector, which also is an array in [x, y, z] form.
|
|
@@ -9,7 +10,8 @@ import { Transforms } from "./transforms";
|
|
|
9
10
|
export declare class Point {
|
|
10
11
|
private readonly geometryHelper;
|
|
11
12
|
private readonly transforms;
|
|
12
|
-
|
|
13
|
+
private readonly vector;
|
|
14
|
+
constructor(geometryHelper: GeometryHelper, transforms: Transforms, vector: Vector);
|
|
13
15
|
/**
|
|
14
16
|
* Transforms the single point
|
|
15
17
|
* @param inputs Contains a point and the transformations to apply
|
|
@@ -82,6 +84,15 @@ export declare class Point {
|
|
|
82
84
|
* @drawable true
|
|
83
85
|
*/
|
|
84
86
|
rotatePointsCenterAxis(inputs: Inputs.Point.RotatePointsCenterAxisDto): Inputs.Base.Point3[];
|
|
87
|
+
/**
|
|
88
|
+
* Gets a bounding box of the points
|
|
89
|
+
* @param inputs Points
|
|
90
|
+
* @returns Bounding box of points
|
|
91
|
+
* @group extract
|
|
92
|
+
* @shortname bounding box pts
|
|
93
|
+
* @drawable true
|
|
94
|
+
*/
|
|
95
|
+
boundingBoxOfPoints(inputs: Inputs.Point.PointsDto): Inputs.Base.BoundingBox;
|
|
85
96
|
/**
|
|
86
97
|
* Measures the closest distance between a point and a collection of points
|
|
87
98
|
* @param inputs Point from which to measure and points to measure the distance against
|
|
@@ -218,5 +229,14 @@ export declare class Point {
|
|
|
218
229
|
* @drawable true
|
|
219
230
|
*/
|
|
220
231
|
removeConsecutiveDuplicates(inputs: Inputs.Point.RemoveConsecutiveDuplicatesDto): Inputs.Base.Point3[];
|
|
232
|
+
/**
|
|
233
|
+
* Creates a normal vector from 3 points
|
|
234
|
+
* @param inputs Three points and the reverse normal flag
|
|
235
|
+
* @returns Normal vector
|
|
236
|
+
* @group create
|
|
237
|
+
* @shortname normal from 3 points
|
|
238
|
+
* @drawable true
|
|
239
|
+
*/
|
|
240
|
+
normalFromThreePoints(inputs: Inputs.Point.ThreePointsNormalDto): Inputs.Base.Vector3;
|
|
221
241
|
private closestPointFromPointData;
|
|
222
242
|
}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* When creating 2D points, z coordinate is simply set to 0 - [x, y, 0].
|
|
5
5
|
*/
|
|
6
6
|
export class Point {
|
|
7
|
-
constructor(geometryHelper, transforms) {
|
|
7
|
+
constructor(geometryHelper, transforms, vector) {
|
|
8
8
|
this.geometryHelper = geometryHelper;
|
|
9
9
|
this.transforms = transforms;
|
|
10
|
+
this.vector = vector;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Transforms the single point
|
|
@@ -114,6 +115,42 @@ export class Point {
|
|
|
114
115
|
const rotationTransforms = this.transforms.rotationCenterAxis({ center: inputs.center, axis: inputs.axis, angle: inputs.angle });
|
|
115
116
|
return this.geometryHelper.transformControlPoints(rotationTransforms, inputs.points);
|
|
116
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Gets a bounding box of the points
|
|
120
|
+
* @param inputs Points
|
|
121
|
+
* @returns Bounding box of points
|
|
122
|
+
* @group extract
|
|
123
|
+
* @shortname bounding box pts
|
|
124
|
+
* @drawable true
|
|
125
|
+
*/
|
|
126
|
+
boundingBoxOfPoints(inputs) {
|
|
127
|
+
const xVals = [];
|
|
128
|
+
const yVals = [];
|
|
129
|
+
const zVals = [];
|
|
130
|
+
inputs.points.forEach(pt => {
|
|
131
|
+
xVals.push(pt[0]);
|
|
132
|
+
yVals.push(pt[1]);
|
|
133
|
+
zVals.push(pt[2]);
|
|
134
|
+
});
|
|
135
|
+
const min = [Math.min(...xVals), Math.min(...yVals), Math.min(...zVals)];
|
|
136
|
+
const max = [Math.max(...xVals), Math.max(...yVals), Math.max(...zVals)];
|
|
137
|
+
const center = [
|
|
138
|
+
(min[0] + max[0]) / 2,
|
|
139
|
+
(min[1] + max[1]) / 2,
|
|
140
|
+
(min[2] + max[2]) / 2,
|
|
141
|
+
];
|
|
142
|
+
const width = max[0] - min[0];
|
|
143
|
+
const height = max[1] - min[1];
|
|
144
|
+
const length = max[2] - min[2];
|
|
145
|
+
return {
|
|
146
|
+
min,
|
|
147
|
+
max,
|
|
148
|
+
center,
|
|
149
|
+
width,
|
|
150
|
+
height,
|
|
151
|
+
length,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
117
154
|
/**
|
|
118
155
|
* Measures the closest distance between a point and a collection of points
|
|
119
156
|
* @param inputs Point from which to measure and points to measure the distance against
|
|
@@ -333,6 +370,47 @@ export class Point {
|
|
|
333
370
|
removeConsecutiveDuplicates(inputs) {
|
|
334
371
|
return this.geometryHelper.removeConsecutivePointDuplicates(inputs.points, inputs.checkFirstAndLast, inputs.tolerance);
|
|
335
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Creates a normal vector from 3 points
|
|
375
|
+
* @param inputs Three points and the reverse normal flag
|
|
376
|
+
* @returns Normal vector
|
|
377
|
+
* @group create
|
|
378
|
+
* @shortname normal from 3 points
|
|
379
|
+
* @drawable true
|
|
380
|
+
*/
|
|
381
|
+
normalFromThreePoints(inputs) {
|
|
382
|
+
const p1 = inputs.point1;
|
|
383
|
+
const p2 = inputs.point2;
|
|
384
|
+
const p3 = inputs.point3;
|
|
385
|
+
if (!p1 || !p2 || !p3 || p1.length !== 3 || p2.length !== 3 || p3.length !== 3) {
|
|
386
|
+
throw new Error("All points must be arrays of 3 numbers [x, y, z]");
|
|
387
|
+
}
|
|
388
|
+
// Calculate vector A = p2 - p1
|
|
389
|
+
const ax = p2[0] - p1[0];
|
|
390
|
+
const ay = p2[1] - p1[1];
|
|
391
|
+
const az = p2[2] - p1[2];
|
|
392
|
+
// Calculate vector B = p3 - p1
|
|
393
|
+
const bx = p3[0] - p1[0];
|
|
394
|
+
const by = p3[1] - p1[1];
|
|
395
|
+
const bz = p3[2] - p1[2];
|
|
396
|
+
// Calculate the cross product N = A x B
|
|
397
|
+
let nx = (ay * bz) - (az * by);
|
|
398
|
+
let ny = (az * bx) - (ax * bz);
|
|
399
|
+
let nz = (ax * by) - (ay * bx);
|
|
400
|
+
// Check for collinear points (resulting in a zero vector)
|
|
401
|
+
// A zero vector indicates the points don't form a unique plane.
|
|
402
|
+
// You might want to handle this case depending on your application.
|
|
403
|
+
if (nx === 0 && ny === 0 && nz === 0) {
|
|
404
|
+
console.warn("Points are collinear or coincident; cannot calculate a unique normal.");
|
|
405
|
+
return undefined; // Or return [0, 0, 0] if that's acceptable
|
|
406
|
+
}
|
|
407
|
+
if (inputs.reverseNormal) {
|
|
408
|
+
nx = -nx;
|
|
409
|
+
ny = -ny;
|
|
410
|
+
nz = -nz;
|
|
411
|
+
}
|
|
412
|
+
return this.vector.normalized({ vector: [nx, ny, nz] });
|
|
413
|
+
}
|
|
336
414
|
closestPointFromPointData(inputs) {
|
|
337
415
|
let distance = Number.MAX_SAFE_INTEGER;
|
|
338
416
|
let closestPointIndex;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as Inputs from "../inputs";
|
|
2
|
+
import * as Models from "../models";
|
|
3
|
+
import { Point } from "./point";
|
|
2
4
|
/**
|
|
3
5
|
* Contains various text methods.
|
|
4
6
|
*/
|
|
5
7
|
export declare class TextBitByBit {
|
|
8
|
+
private readonly point;
|
|
9
|
+
constructor(point: Point);
|
|
6
10
|
/**
|
|
7
11
|
* Creates a text
|
|
8
12
|
* @param inputs a text
|
|
@@ -66,4 +70,24 @@ export declare class TextBitByBit {
|
|
|
66
70
|
* @drawable false
|
|
67
71
|
*/
|
|
68
72
|
format(inputs: Inputs.Text.TextFormatDto): string;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a vector segments for character and includes width and height information
|
|
75
|
+
* @param inputs a text
|
|
76
|
+
* @returns width, height and segments as json
|
|
77
|
+
* @group vector
|
|
78
|
+
* @shortname vector char
|
|
79
|
+
* @drawable false
|
|
80
|
+
*/
|
|
81
|
+
vectorChar(inputs: Inputs.Text.VectorCharDto): Models.Text.VectorCharData;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a vector text lines for a given text and includes width and height information
|
|
84
|
+
* @param inputs a text as string
|
|
85
|
+
* @returns segments
|
|
86
|
+
* @group vector
|
|
87
|
+
* @shortname vector text
|
|
88
|
+
* @drawable false
|
|
89
|
+
*/
|
|
90
|
+
vectorText(inputs: Inputs.Text.VectorTextDto): Models.Text.VectorTextData[];
|
|
91
|
+
private vectorParamsChar;
|
|
92
|
+
private translateLine;
|
|
69
93
|
}
|