@bitbybit-dev/base 0.19.8 → 0.20.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 (65) hide show
  1. package/babel.config.cjs +1 -0
  2. package/babel.config.d.cts +5 -0
  3. package/index.d.ts +1 -0
  4. package/{index.ts → index.js} +1 -2
  5. package/lib/api/index.js +1 -0
  6. package/lib/api/inputs/base-inputs.d.ts +35 -0
  7. package/lib/api/inputs/base-inputs.js +1 -0
  8. package/lib/api/inputs/{color-inputs.ts → color-inputs.d.ts} +26 -48
  9. package/lib/api/inputs/color-inputs.js +164 -0
  10. package/lib/api/inputs/dates-inputs.d.ts +216 -0
  11. package/lib/api/inputs/dates-inputs.js +271 -0
  12. package/lib/api/inputs/{index.ts → index.d.ts} +1 -0
  13. package/lib/api/inputs/index.js +10 -0
  14. package/lib/api/inputs/{inputs.ts → inputs.d.ts} +1 -0
  15. package/lib/api/inputs/inputs.js +10 -0
  16. package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
  17. package/lib/api/inputs/lists-inputs.js +576 -0
  18. package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
  19. package/lib/api/inputs/logic-inputs.js +111 -0
  20. package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
  21. package/lib/api/inputs/math-inputs.js +391 -0
  22. package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
  23. package/lib/api/inputs/point-inputs.js +521 -0
  24. package/lib/api/inputs/text-inputs.d.ts +83 -0
  25. package/lib/api/inputs/text-inputs.js +120 -0
  26. package/lib/api/inputs/{transforms-inputs.ts → transforms-inputs.d.ts} +35 -64
  27. package/lib/api/inputs/transforms-inputs.js +200 -0
  28. package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
  29. package/lib/api/inputs/vector-inputs.js +304 -0
  30. package/lib/api/services/color.d.ts +114 -0
  31. package/lib/api/services/{color.ts → color.js} +15 -34
  32. package/lib/api/services/dates.d.ts +367 -0
  33. package/lib/api/services/dates.js +450 -0
  34. package/lib/api/services/geometry-helper.d.ts +15 -0
  35. package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
  36. package/lib/api/services/{index.ts → index.d.ts} +2 -1
  37. package/lib/api/services/index.js +10 -0
  38. package/lib/api/services/lists.d.ts +287 -0
  39. package/lib/api/services/{lists.ts → lists.js} +59 -83
  40. package/lib/api/services/logic.d.ts +99 -0
  41. package/lib/api/services/{logic.ts → logic.js} +24 -32
  42. package/lib/api/services/math.d.ts +349 -0
  43. package/lib/api/services/{math.ts → math.js} +71 -136
  44. package/lib/api/services/point.d.ts +222 -0
  45. package/lib/api/services/{point.ts → point.js} +32 -67
  46. package/lib/api/services/text.d.ts +69 -0
  47. package/lib/api/services/{text.ts → text.js} +7 -17
  48. package/lib/api/services/transforms.d.ts +122 -0
  49. package/lib/api/services/{transforms.ts → transforms.js} +37 -83
  50. package/lib/api/services/vector.d.ts +320 -0
  51. package/lib/api/services/{vector.ts → vector.js} +42 -80
  52. package/lib/{index.ts → index.d.ts} +0 -1
  53. package/lib/index.js +1 -0
  54. package/package.json +1 -1
  55. package/lib/api/inputs/base-inputs.ts +0 -18
  56. package/lib/api/inputs/text-inputs.ts +0 -108
  57. package/lib/api/services/color.test.ts +0 -86
  58. package/lib/api/services/lists.test.ts +0 -612
  59. package/lib/api/services/logic.test.ts +0 -187
  60. package/lib/api/services/math.test.ts +0 -622
  61. package/lib/api/services/text.test.ts +0 -55
  62. package/lib/api/services/vector.test.ts +0 -360
  63. package/tsconfig.bitbybit.json +0 -26
  64. package/tsconfig.json +0 -24
  65. /package/lib/api/{index.ts → index.d.ts} +0 -0
@@ -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
+ }
@@ -0,0 +1,15 @@
1
+ import * as Inputs from "../inputs";
2
+ export declare class GeometryHelper {
3
+ transformControlPoints(transformation: number[][] | number[][][], transformedControlPoints: Inputs.Base.Point3[]): Inputs.Base.Point3[];
4
+ getFlatTransformations(transformation: number[][] | number[][][]): number[][];
5
+ getArrayDepth: (value: any) => number;
6
+ transformPointsByMatrixArray(points: Inputs.Base.Point3[], transform: number[]): Inputs.Base.Point3[];
7
+ transformPointsCoordinates(points: Inputs.Base.Point3[], transform: number[]): Inputs.Base.Point3[];
8
+ removeAllDuplicateVectors(vectors: number[][], tolerance?: number): number[][];
9
+ removeConsecutiveVectorDuplicates(vectors: number[][], checkFirstAndLast?: boolean, tolerance?: number): number[][];
10
+ vectorsTheSame(vec1: number[], vec2: number[], tolerance: number): boolean;
11
+ approxEq(num1: number, num2: number, tolerance: number): boolean;
12
+ removeConsecutivePointDuplicates(points: Inputs.Base.Point3[], checkFirstAndLast?: boolean, tolerance?: number): Inputs.Base.Point3[];
13
+ arePointsTheSame(pointA: Inputs.Base.Point3 | Inputs.Base.Point2, pointB: Inputs.Base.Point3 | Inputs.Base.Point2, tolerance: number): boolean;
14
+ private transformCoordinates;
15
+ }
@@ -1,41 +1,34 @@
1
- import * as Inputs from "../inputs";
2
-
3
1
  export class GeometryHelper {
4
-
5
- transformControlPoints(transformation: number[][] | number[][][], transformedControlPoints: Inputs.Base.Point3[]): Inputs.Base.Point3[] {
2
+ constructor() {
3
+ this.getArrayDepth = (value) => {
4
+ return Array.isArray(value) ?
5
+ 1 + Math.max(...value.map(this.getArrayDepth)) :
6
+ 0;
7
+ };
8
+ }
9
+ transformControlPoints(transformation, transformedControlPoints) {
6
10
  const transformationArrays = this.getFlatTransformations(transformation);
7
-
8
11
  transformationArrays.forEach(transform => {
9
-
10
12
  transformedControlPoints = this.transformPointsByMatrixArray(transformedControlPoints, transform);
11
13
  });
12
14
  return transformedControlPoints;
13
15
  }
14
-
15
- getFlatTransformations(transformation: number[][] | number[][][]): number[][] {
16
+ getFlatTransformations(transformation) {
16
17
  let transformationArrays = [];
17
-
18
18
  if (this.getArrayDepth(transformation) === 3) {
19
19
  transformation.forEach(transform => {
20
20
  transformationArrays.push(...transform);
21
21
  });
22
- } else {
22
+ }
23
+ else {
23
24
  transformationArrays = transformation;
24
25
  }
25
26
  return transformationArrays;
26
- }
27
-
28
- getArrayDepth = (value): number => {
29
- return Array.isArray(value) ?
30
- 1 + Math.max(...value.map(this.getArrayDepth)) :
31
- 0;
32
- };
33
-
34
- transformPointsByMatrixArray(points: Inputs.Base.Point3[], transform: number[]): Inputs.Base.Point3[] {
27
+ }
28
+ transformPointsByMatrixArray(points, transform) {
35
29
  return this.transformPointsCoordinates(points, transform);
36
30
  }
37
-
38
- transformPointsCoordinates(points: Inputs.Base.Point3[], transform: number[]): Inputs.Base.Point3[] {
31
+ transformPointsCoordinates(points, transform) {
39
32
  const transformedPoints = [];
40
33
  for (const pt of points) {
41
34
  const transformedVector = this.transformCoordinates(pt[0], pt[1], pt[2], transform);
@@ -43,10 +36,9 @@ export class GeometryHelper {
43
36
  }
44
37
  return transformedPoints;
45
38
  }
46
-
47
39
  // Algorithm works with arbitrary length numeric vectors. This algorithm is more costly for longer arrays of vectors
48
- removeAllDuplicateVectors(vectors: number[][], tolerance = 1e-7): number[][] {
49
- const cleanVectors: number[][] = [];
40
+ removeAllDuplicateVectors(vectors, tolerance = 1e-7) {
41
+ const cleanVectors = [];
50
42
  vectors.forEach(vector => {
51
43
  // when there are no vectors in cleanVectors array that match the current vector, push it in.
52
44
  if (!cleanVectors.some(s => this.vectorsTheSame(vector, s, tolerance))) {
@@ -55,10 +47,9 @@ export class GeometryHelper {
55
47
  });
56
48
  return cleanVectors;
57
49
  }
58
-
59
50
  // Algorithm works with arbitrary length numeric vectors.
60
- removeConsecutiveVectorDuplicates(vectors: number[][], checkFirstAndLast = true, tolerance = 1e-7): number[][] {
61
- const vectorsRemaining: number[][] = [];
51
+ removeConsecutiveVectorDuplicates(vectors, checkFirstAndLast = true, tolerance = 1e-7) {
52
+ const vectorsRemaining = [];
62
53
  if (vectors.length > 1) {
63
54
  for (let i = 1; i < vectors.length; i++) {
64
55
  const currentVector = vectors[i];
@@ -77,17 +68,18 @@ export class GeometryHelper {
77
68
  vectorsRemaining.pop();
78
69
  }
79
70
  }
80
- } else if (vectors.length === 1) {
71
+ }
72
+ else if (vectors.length === 1) {
81
73
  vectorsRemaining.push(...vectors);
82
74
  }
83
75
  return vectorsRemaining;
84
76
  }
85
-
86
- vectorsTheSame(vec1: number[], vec2: number[], tolerance: number) {
77
+ vectorsTheSame(vec1, vec2, tolerance) {
87
78
  let result = false;
88
79
  if (vec1.length !== vec2.length) {
89
80
  return result;
90
- } else {
81
+ }
82
+ else {
91
83
  result = true;
92
84
  for (let i = 0; i < vec1.length; i++) {
93
85
  if (!this.approxEq(vec1[i], vec2[i], tolerance)) {
@@ -98,13 +90,11 @@ export class GeometryHelper {
98
90
  }
99
91
  return result;
100
92
  }
101
-
102
- approxEq(num1: number, num2: number, tolerance: number): boolean {
93
+ approxEq(num1, num2, tolerance) {
103
94
  const res = Math.abs(num1 - num2) < tolerance;
104
95
  return res;
105
96
  }
106
-
107
- removeConsecutivePointDuplicates(points: Inputs.Base.Point3[], checkFirstAndLast = true, tolerance = 1e-7): Inputs.Base.Point3[] {
97
+ removeConsecutivePointDuplicates(points, checkFirstAndLast = true, tolerance = 1e-7) {
108
98
  const pointsRemaining = [];
109
99
  if (points.length > 1) {
110
100
  for (let i = 1; i < points.length; i++) {
@@ -124,20 +114,21 @@ export class GeometryHelper {
124
114
  pointsRemaining.pop();
125
115
  }
126
116
  }
127
- } else if (points.length === 1) {
117
+ }
118
+ else if (points.length === 1) {
128
119
  pointsRemaining.push(...points);
129
120
  }
130
121
  return pointsRemaining;
131
122
  }
132
-
133
- arePointsTheSame(pointA: Inputs.Base.Point3 | Inputs.Base.Point2, pointB: Inputs.Base.Point3 | Inputs.Base.Point2, tolerance: number): boolean {
123
+ arePointsTheSame(pointA, pointB, tolerance) {
134
124
  let result = false;
135
125
  if (pointA.length === 2 && pointB.length === 2) {
136
126
  if (this.approxEq(pointA[0], pointB[0], tolerance) &&
137
127
  this.approxEq(pointA[1], pointB[1], tolerance)) {
138
128
  result = true;
139
129
  }
140
- } else if (pointA.length === 3 && pointB.length === 3) {
130
+ }
131
+ else if (pointA.length === 3 && pointB.length === 3) {
141
132
  if (this.approxEq(pointA[0], pointB[0], tolerance) &&
142
133
  this.approxEq(pointA[1], pointB[1], tolerance) &&
143
134
  this.approxEq(pointA[2], pointB[2], tolerance)) {
@@ -146,18 +137,15 @@ export class GeometryHelper {
146
137
  }
147
138
  return result;
148
139
  }
149
-
150
- private transformCoordinates(x: number, y: number, z: number, transformation: number[]): Inputs.Base.Vector3 {
140
+ transformCoordinates(x, y, z, transformation) {
151
141
  const m = transformation;
152
142
  const rx = x * m[0] + y * m[4] + z * m[8] + m[12];
153
143
  const ry = x * m[1] + y * m[5] + z * m[9] + m[13];
154
144
  const rz = x * m[2] + y * m[6] + z * m[10] + m[14];
155
145
  const rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
156
-
157
146
  const newx = rx * rw;
158
147
  const newy = ry * rw;
159
148
  const newz = rz * rw;
160
149
  return [newx, newy, newz];
161
150
  }
162
-
163
151
  }
@@ -4,6 +4,7 @@ export * from "./logic";
4
4
  export * from "./math";
5
5
  export * from "./point";
6
6
  export * from "./text";
7
+ export * from "./dates";
7
8
  export * from "./vector";
8
9
  export * from "./transforms";
9
- export * from "./geometry-helper";
10
+ export * from "./geometry-helper";
@@ -0,0 +1,10 @@
1
+ export * from "./color";
2
+ export * from "./lists";
3
+ export * from "./logic";
4
+ export * from "./math";
5
+ export * from "./point";
6
+ export * from "./text";
7
+ export * from "./dates";
8
+ export * from "./vector";
9
+ export * from "./transforms";
10
+ export * from "./geometry-helper";