@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.
- package/babel.config.cjs +1 -0
- package/babel.config.d.cts +5 -0
- package/index.d.ts +1 -0
- package/{index.ts → index.js} +1 -2
- 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.ts → color-inputs.d.ts} +26 -48
- package/lib/api/inputs/color-inputs.js +164 -0
- package/lib/api/inputs/dates-inputs.d.ts +216 -0
- package/lib/api/inputs/dates-inputs.js +271 -0
- package/lib/api/inputs/{index.ts → index.d.ts} +1 -0
- package/lib/api/inputs/index.js +10 -0
- package/lib/api/inputs/{inputs.ts → inputs.d.ts} +1 -0
- package/lib/api/inputs/inputs.js +10 -0
- package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
- package/lib/api/inputs/lists-inputs.js +576 -0
- package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
- package/lib/api/inputs/logic-inputs.js +111 -0
- package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
- package/lib/api/inputs/math-inputs.js +391 -0
- package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
- 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.ts → transforms-inputs.d.ts} +35 -64
- package/lib/api/inputs/transforms-inputs.js +200 -0
- package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
- package/lib/api/inputs/vector-inputs.js +304 -0
- package/lib/api/services/color.d.ts +114 -0
- package/lib/api/services/{color.ts → color.js} +15 -34
- package/lib/api/services/dates.d.ts +367 -0
- package/lib/api/services/dates.js +450 -0
- package/lib/api/services/geometry-helper.d.ts +15 -0
- package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
- package/lib/api/services/{index.ts → index.d.ts} +2 -1
- package/lib/api/services/index.js +10 -0
- package/lib/api/services/lists.d.ts +287 -0
- package/lib/api/services/{lists.ts → lists.js} +59 -83
- package/lib/api/services/logic.d.ts +99 -0
- package/lib/api/services/{logic.ts → logic.js} +24 -32
- package/lib/api/services/math.d.ts +349 -0
- package/lib/api/services/{math.ts → math.js} +71 -136
- package/lib/api/services/point.d.ts +222 -0
- package/lib/api/services/{point.ts → point.js} +32 -67
- package/lib/api/services/text.d.ts +69 -0
- package/lib/api/services/{text.ts → text.js} +7 -17
- package/lib/api/services/transforms.d.ts +122 -0
- package/lib/api/services/{transforms.ts → transforms.js} +37 -83
- package/lib/api/services/vector.d.ts +320 -0
- package/lib/api/services/{vector.ts → vector.js} +42 -80
- package/lib/{index.ts → index.d.ts} +0 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/lib/api/inputs/base-inputs.ts +0 -18
- package/lib/api/inputs/text-inputs.ts +0 -108
- package/lib/api/services/color.test.ts +0 -86
- package/lib/api/services/lists.test.ts +0 -612
- package/lib/api/services/logic.test.ts +0 -187
- package/lib/api/services/math.test.ts +0 -622
- package/lib/api/services/text.test.ts +0 -55
- package/lib/api/services/vector.test.ts +0 -360
- package/tsconfig.bitbybit.json +0 -26
- package/tsconfig.json +0 -24
- /package/lib/api/{index.ts → index.d.ts} +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { GeometryHelper } from "./geometry-helper";
|
|
2
|
+
import * as Inputs from "../inputs";
|
|
3
|
+
import { Transforms } from "./transforms";
|
|
4
|
+
/**
|
|
5
|
+
* Contains various methods for points. Point in bitbybit is simply an array containing 3 numbers for [x, y, z].
|
|
6
|
+
* Because of this form Point can be interchanged with Vector, which also is an array in [x, y, z] form.
|
|
7
|
+
* When creating 2D points, z coordinate is simply set to 0 - [x, y, 0].
|
|
8
|
+
*/
|
|
9
|
+
export declare class Point {
|
|
10
|
+
private readonly geometryHelper;
|
|
11
|
+
private readonly transforms;
|
|
12
|
+
constructor(geometryHelper: GeometryHelper, transforms: Transforms);
|
|
13
|
+
/**
|
|
14
|
+
* Transforms the single point
|
|
15
|
+
* @param inputs Contains a point and the transformations to apply
|
|
16
|
+
* @returns Transformed point
|
|
17
|
+
* @group transforms
|
|
18
|
+
* @shortname transform point
|
|
19
|
+
* @drawable true
|
|
20
|
+
*/
|
|
21
|
+
transformPoint(inputs: Inputs.Point.TransformPointDto): Inputs.Base.Point3;
|
|
22
|
+
/**
|
|
23
|
+
* Transforms multiple points
|
|
24
|
+
* @param inputs Contains points and the transformations to apply
|
|
25
|
+
* @returns Transformed points
|
|
26
|
+
* @group transforms
|
|
27
|
+
* @shortname transform points
|
|
28
|
+
* @drawable true
|
|
29
|
+
*/
|
|
30
|
+
transformPoints(inputs: Inputs.Point.TransformPointsDto): Inputs.Base.Point3[];
|
|
31
|
+
/**
|
|
32
|
+
* Transforms multiple points by multiple transformations
|
|
33
|
+
* @param inputs Contains points and the transformations to apply
|
|
34
|
+
* @returns Transformed points
|
|
35
|
+
* @group transforms
|
|
36
|
+
* @shortname transforms for points
|
|
37
|
+
* @drawable true
|
|
38
|
+
*/
|
|
39
|
+
transformsForPoints(inputs: Inputs.Point.TransformsForPointsDto): Inputs.Base.Point3[];
|
|
40
|
+
/**
|
|
41
|
+
* Translate multiple points
|
|
42
|
+
* @param inputs Contains points and the translation vector
|
|
43
|
+
* @returns Translated points
|
|
44
|
+
* @group transforms
|
|
45
|
+
* @shortname translate points
|
|
46
|
+
* @drawable true
|
|
47
|
+
*/
|
|
48
|
+
translatePoints(inputs: Inputs.Point.TranslatePointsDto): Inputs.Base.Point3[];
|
|
49
|
+
/**
|
|
50
|
+
* Translate multiple points
|
|
51
|
+
* @param inputs Contains points and the translation vector
|
|
52
|
+
* @returns Translated points
|
|
53
|
+
* @group transforms
|
|
54
|
+
* @shortname translate points with vectors
|
|
55
|
+
* @drawable true
|
|
56
|
+
*/
|
|
57
|
+
translatePointsWithVectors(inputs: Inputs.Point.TranslatePointsWithVectorsDto): Inputs.Base.Point3[];
|
|
58
|
+
/**
|
|
59
|
+
* Translate multiple points by x, y, z values provided
|
|
60
|
+
* @param inputs Contains points and the translation in x y and z
|
|
61
|
+
* @returns Translated points
|
|
62
|
+
* @group transforms
|
|
63
|
+
* @shortname translate xyz points
|
|
64
|
+
* @drawable true
|
|
65
|
+
*/
|
|
66
|
+
translateXYZPoints(inputs: Inputs.Point.TranslateXYZPointsDto): Inputs.Base.Point3[];
|
|
67
|
+
/**
|
|
68
|
+
* Scale multiple points by providing center point and x, y, z scale factors
|
|
69
|
+
* @param inputs Contains points, center point and scale factors
|
|
70
|
+
* @returns Scaled points
|
|
71
|
+
* @group transforms
|
|
72
|
+
* @shortname scale points on center
|
|
73
|
+
* @drawable true
|
|
74
|
+
*/
|
|
75
|
+
scalePointsCenterXYZ(inputs: Inputs.Point.ScalePointsCenterXYZDto): Inputs.Base.Point3[];
|
|
76
|
+
/**
|
|
77
|
+
* Rotate multiple points by providing center point, axis and degrees of rotation
|
|
78
|
+
* @param inputs Contains points, axis, center point and angle of rotation
|
|
79
|
+
* @returns Rotated points
|
|
80
|
+
* @group transforms
|
|
81
|
+
* @shortname rotate points center axis
|
|
82
|
+
* @drawable true
|
|
83
|
+
*/
|
|
84
|
+
rotatePointsCenterAxis(inputs: Inputs.Point.RotatePointsCenterAxisDto): Inputs.Base.Point3[];
|
|
85
|
+
/**
|
|
86
|
+
* Measures the closest distance between a point and a collection of points
|
|
87
|
+
* @param inputs Point from which to measure and points to measure the distance against
|
|
88
|
+
* @returns Distance to closest point
|
|
89
|
+
* @group extract
|
|
90
|
+
* @shortname distance to closest pt
|
|
91
|
+
* @drawable false
|
|
92
|
+
*/
|
|
93
|
+
closestPointFromPointsDistance(inputs: Inputs.Point.ClosestPointFromPointsDto): number;
|
|
94
|
+
/**
|
|
95
|
+
* Finds the closest point index between a point and a collection of points. Caution, index is not 0 based, it starts with 1.
|
|
96
|
+
* @param inputs Point from which to find the index in a collection of points
|
|
97
|
+
* @returns Closest point index
|
|
98
|
+
* @group extract
|
|
99
|
+
* @shortname index of closest pt
|
|
100
|
+
* @drawable false
|
|
101
|
+
*/
|
|
102
|
+
closestPointFromPointsIndex(inputs: Inputs.Point.ClosestPointFromPointsDto): number;
|
|
103
|
+
/**
|
|
104
|
+
* Finds the closest point in a collection
|
|
105
|
+
* @param inputs Point and points collection to find the closest point in
|
|
106
|
+
* @returns Closest point
|
|
107
|
+
* @group extract
|
|
108
|
+
* @shortname closest pt
|
|
109
|
+
* @drawable true
|
|
110
|
+
*/
|
|
111
|
+
closestPointFromPoints(inputs: Inputs.Point.ClosestPointFromPointsDto): Inputs.Base.Point3;
|
|
112
|
+
/**
|
|
113
|
+
* Finds the distance between two points
|
|
114
|
+
* @param inputs Coordinates of start and end points
|
|
115
|
+
* @returns Distance
|
|
116
|
+
* @group measure
|
|
117
|
+
* @shortname distance
|
|
118
|
+
* @drawable false
|
|
119
|
+
*/
|
|
120
|
+
distance(inputs: Inputs.Point.StartEndPointsDto): number;
|
|
121
|
+
/**
|
|
122
|
+
* Finds the distances between the start point and multiple end points
|
|
123
|
+
* @param inputs Coordinates of start and end points
|
|
124
|
+
* @returns Distances
|
|
125
|
+
* @group measure
|
|
126
|
+
* @shortname distances to points
|
|
127
|
+
* @drawable false
|
|
128
|
+
*/
|
|
129
|
+
distancesToPoints(inputs: Inputs.Point.StartEndPointsListDto): number[];
|
|
130
|
+
/**
|
|
131
|
+
* Multiply point by a specified amount
|
|
132
|
+
* @param inputs The point to be multiplied and the amount of points to create
|
|
133
|
+
* @returns Distance
|
|
134
|
+
* @group transforms
|
|
135
|
+
* @shortname multiply point
|
|
136
|
+
* @drawable true
|
|
137
|
+
*/
|
|
138
|
+
multiplyPoint(inputs: Inputs.Point.MultiplyPointDto): Inputs.Base.Point3[];
|
|
139
|
+
/**
|
|
140
|
+
* Get x coordinate of the point
|
|
141
|
+
* @param inputs The point
|
|
142
|
+
* @returns X coordinate
|
|
143
|
+
* @group get
|
|
144
|
+
* @shortname x coord
|
|
145
|
+
* @drawable false
|
|
146
|
+
*/
|
|
147
|
+
getX(inputs: Inputs.Point.PointDto): number;
|
|
148
|
+
/**
|
|
149
|
+
* Get y coordinate of the point
|
|
150
|
+
* @param inputs The point
|
|
151
|
+
* @returns Y coordinate
|
|
152
|
+
* @group get
|
|
153
|
+
* @shortname y coord
|
|
154
|
+
* @drawable false
|
|
155
|
+
*/
|
|
156
|
+
getY(inputs: Inputs.Point.PointDto): number;
|
|
157
|
+
/**
|
|
158
|
+
* Get z coordinate of the point
|
|
159
|
+
* @param inputs The point
|
|
160
|
+
* @returns Z coordinate
|
|
161
|
+
* @group get
|
|
162
|
+
* @shortname z coord
|
|
163
|
+
* @drawable false
|
|
164
|
+
*/
|
|
165
|
+
getZ(inputs: Inputs.Point.PointDto): number;
|
|
166
|
+
/**
|
|
167
|
+
* Get average point of points
|
|
168
|
+
* @param inputs The points
|
|
169
|
+
* @returns point
|
|
170
|
+
* @group extract
|
|
171
|
+
* @shortname average point
|
|
172
|
+
* @drawable true
|
|
173
|
+
*/
|
|
174
|
+
averagePoint(inputs: Inputs.Point.PointsDto): Inputs.Base.Point3;
|
|
175
|
+
/**
|
|
176
|
+
* Creates the xyz point
|
|
177
|
+
* @param inputs xyz information
|
|
178
|
+
* @returns point 3d
|
|
179
|
+
* @group create
|
|
180
|
+
* @shortname point xyz
|
|
181
|
+
* @drawable true
|
|
182
|
+
*/
|
|
183
|
+
pointXYZ(inputs: Inputs.Point.PointXYZDto): Inputs.Base.Point3;
|
|
184
|
+
/**
|
|
185
|
+
* Creates the xy point
|
|
186
|
+
* @param inputs xy information
|
|
187
|
+
* @returns point 3d
|
|
188
|
+
* @group create
|
|
189
|
+
* @shortname point xy
|
|
190
|
+
* @drawable false
|
|
191
|
+
*/
|
|
192
|
+
pointXY(inputs: Inputs.Point.PointXYDto): Inputs.Base.Point2;
|
|
193
|
+
/**
|
|
194
|
+
* Creates the spiral out of multiple points
|
|
195
|
+
* @param inputs Spiral information
|
|
196
|
+
* @returns Specified number of points in the array along the spiral
|
|
197
|
+
* @group create
|
|
198
|
+
* @shortname spiral
|
|
199
|
+
* @drawable true
|
|
200
|
+
*/
|
|
201
|
+
spiral(inputs: Inputs.Point.SpiralDto): Inputs.Base.Point3[];
|
|
202
|
+
/**
|
|
203
|
+
* Creates a flat point grid on XY plane. This grid contains center points for hexagons of the given radius.
|
|
204
|
+
* Be aware that we control only the nr of hexagons to be made and not the length and width of the grid.
|
|
205
|
+
* @param inputs Information about hexagon and the grid
|
|
206
|
+
* @returns Points in the array on the grid
|
|
207
|
+
* @group create
|
|
208
|
+
* @shortname hex grid
|
|
209
|
+
* @drawable true
|
|
210
|
+
*/
|
|
211
|
+
hexGrid(inputs: Inputs.Point.HexGridCentersDto): Inputs.Base.Point3[];
|
|
212
|
+
/**
|
|
213
|
+
* Removes consecutive duplicates from the point array with tolerance
|
|
214
|
+
* @param inputs points, tolerance and check first and last
|
|
215
|
+
* @returns Points in the array without consecutive duplicates
|
|
216
|
+
* @group clean
|
|
217
|
+
* @shortname remove duplicates
|
|
218
|
+
* @drawable true
|
|
219
|
+
*/
|
|
220
|
+
removeConsecutiveDuplicates(inputs: Inputs.Point.RemoveConsecutiveDuplicatesDto): Inputs.Base.Point3[];
|
|
221
|
+
private closestPointFromPointData;
|
|
222
|
+
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { GeometryHelper } from "./geometry-helper";
|
|
2
|
-
import * as Inputs from "../inputs";
|
|
3
|
-
import { Transforms } from "./transforms";
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* Contains various methods for points. Point in bitbybit is simply an array containing 3 numbers for [x, y, z].
|
|
7
3
|
* Because of this form Point can be interchanged with Vector, which also is an array in [x, y, z] form.
|
|
8
4
|
* When creating 2D points, z coordinate is simply set to 0 - [x, y, 0].
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
export class Point {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
constructor(geometryHelper, transforms) {
|
|
8
|
+
this.geometryHelper = geometryHelper;
|
|
9
|
+
this.transforms = transforms;
|
|
10
|
+
}
|
|
15
11
|
/**
|
|
16
12
|
* Transforms the single point
|
|
17
13
|
* @param inputs Contains a point and the transformations to apply
|
|
@@ -20,13 +16,12 @@ export class Point {
|
|
|
20
16
|
* @shortname transform point
|
|
21
17
|
* @drawable true
|
|
22
18
|
*/
|
|
23
|
-
transformPoint(inputs
|
|
19
|
+
transformPoint(inputs) {
|
|
24
20
|
const transformation = inputs.transformation;
|
|
25
21
|
let transformedControlPoints = [inputs.point];
|
|
26
22
|
transformedControlPoints = this.geometryHelper.transformControlPoints(transformation, transformedControlPoints);
|
|
27
23
|
return transformedControlPoints[0];
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
/**
|
|
31
26
|
* Transforms multiple points
|
|
32
27
|
* @param inputs Contains points and the transformations to apply
|
|
@@ -35,10 +30,9 @@ export class Point {
|
|
|
35
30
|
* @shortname transform points
|
|
36
31
|
* @drawable true
|
|
37
32
|
*/
|
|
38
|
-
transformPoints(inputs
|
|
33
|
+
transformPoints(inputs) {
|
|
39
34
|
return this.geometryHelper.transformControlPoints(inputs.transformation, inputs.points);
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
/**
|
|
43
37
|
* Transforms multiple points by multiple transformations
|
|
44
38
|
* @param inputs Contains points and the transformations to apply
|
|
@@ -47,7 +41,7 @@ export class Point {
|
|
|
47
41
|
* @shortname transforms for points
|
|
48
42
|
* @drawable true
|
|
49
43
|
*/
|
|
50
|
-
transformsForPoints(inputs
|
|
44
|
+
transformsForPoints(inputs) {
|
|
51
45
|
if (inputs.points.length !== inputs.transformation.length) {
|
|
52
46
|
throw new Error("You must provide equal nr of points and transformations");
|
|
53
47
|
}
|
|
@@ -55,7 +49,6 @@ export class Point {
|
|
|
55
49
|
return this.geometryHelper.transformControlPoints(inputs.transformation[index], [pt])[0];
|
|
56
50
|
});
|
|
57
51
|
}
|
|
58
|
-
|
|
59
52
|
/**
|
|
60
53
|
* Translate multiple points
|
|
61
54
|
* @param inputs Contains points and the translation vector
|
|
@@ -64,11 +57,10 @@ export class Point {
|
|
|
64
57
|
* @shortname translate points
|
|
65
58
|
* @drawable true
|
|
66
59
|
*/
|
|
67
|
-
translatePoints(inputs
|
|
60
|
+
translatePoints(inputs) {
|
|
68
61
|
const translationTransform = this.transforms.translationXYZ({ translation: inputs.translation });
|
|
69
62
|
return this.geometryHelper.transformControlPoints(translationTransform, inputs.points);
|
|
70
63
|
}
|
|
71
|
-
|
|
72
64
|
/**
|
|
73
65
|
* Translate multiple points
|
|
74
66
|
* @param inputs Contains points and the translation vector
|
|
@@ -77,7 +69,7 @@ export class Point {
|
|
|
77
69
|
* @shortname translate points with vectors
|
|
78
70
|
* @drawable true
|
|
79
71
|
*/
|
|
80
|
-
translatePointsWithVectors(inputs
|
|
72
|
+
translatePointsWithVectors(inputs) {
|
|
81
73
|
if (inputs.points.length !== inputs.translations.length) {
|
|
82
74
|
throw new Error("You must provide equal nr of points and translations");
|
|
83
75
|
}
|
|
@@ -86,7 +78,6 @@ export class Point {
|
|
|
86
78
|
return this.geometryHelper.transformControlPoints(translationTransforms[index], [pt])[0];
|
|
87
79
|
});
|
|
88
80
|
}
|
|
89
|
-
|
|
90
81
|
/**
|
|
91
82
|
* Translate multiple points by x, y, z values provided
|
|
92
83
|
* @param inputs Contains points and the translation in x y and z
|
|
@@ -95,11 +86,10 @@ export class Point {
|
|
|
95
86
|
* @shortname translate xyz points
|
|
96
87
|
* @drawable true
|
|
97
88
|
*/
|
|
98
|
-
translateXYZPoints(inputs
|
|
89
|
+
translateXYZPoints(inputs) {
|
|
99
90
|
const translationTransform = this.transforms.translationXYZ({ translation: [inputs.x, inputs.y, inputs.z] });
|
|
100
91
|
return this.geometryHelper.transformControlPoints(translationTransform, inputs.points);
|
|
101
92
|
}
|
|
102
|
-
|
|
103
93
|
/**
|
|
104
94
|
* Scale multiple points by providing center point and x, y, z scale factors
|
|
105
95
|
* @param inputs Contains points, center point and scale factors
|
|
@@ -108,11 +98,10 @@ export class Point {
|
|
|
108
98
|
* @shortname scale points on center
|
|
109
99
|
* @drawable true
|
|
110
100
|
*/
|
|
111
|
-
scalePointsCenterXYZ(inputs
|
|
101
|
+
scalePointsCenterXYZ(inputs) {
|
|
112
102
|
const scaleTransforms = this.transforms.scaleCenterXYZ({ center: inputs.center, scaleXyz: inputs.scaleXyz });
|
|
113
103
|
return this.geometryHelper.transformControlPoints(scaleTransforms, inputs.points);
|
|
114
104
|
}
|
|
115
|
-
|
|
116
105
|
/**
|
|
117
106
|
* Rotate multiple points by providing center point, axis and degrees of rotation
|
|
118
107
|
* @param inputs Contains points, axis, center point and angle of rotation
|
|
@@ -121,11 +110,10 @@ export class Point {
|
|
|
121
110
|
* @shortname rotate points center axis
|
|
122
111
|
* @drawable true
|
|
123
112
|
*/
|
|
124
|
-
rotatePointsCenterAxis(inputs
|
|
113
|
+
rotatePointsCenterAxis(inputs) {
|
|
125
114
|
const rotationTransforms = this.transforms.rotationCenterAxis({ center: inputs.center, axis: inputs.axis, angle: inputs.angle });
|
|
126
115
|
return this.geometryHelper.transformControlPoints(rotationTransforms, inputs.points);
|
|
127
116
|
}
|
|
128
|
-
|
|
129
117
|
/**
|
|
130
118
|
* Measures the closest distance between a point and a collection of points
|
|
131
119
|
* @param inputs Point from which to measure and points to measure the distance against
|
|
@@ -134,10 +122,9 @@ export class Point {
|
|
|
134
122
|
* @shortname distance to closest pt
|
|
135
123
|
* @drawable false
|
|
136
124
|
*/
|
|
137
|
-
closestPointFromPointsDistance(inputs
|
|
125
|
+
closestPointFromPointsDistance(inputs) {
|
|
138
126
|
return this.closestPointFromPointData(inputs).distance;
|
|
139
127
|
}
|
|
140
|
-
|
|
141
128
|
/**
|
|
142
129
|
* Finds the closest point index between a point and a collection of points. Caution, index is not 0 based, it starts with 1.
|
|
143
130
|
* @param inputs Point from which to find the index in a collection of points
|
|
@@ -146,10 +133,9 @@ export class Point {
|
|
|
146
133
|
* @shortname index of closest pt
|
|
147
134
|
* @drawable false
|
|
148
135
|
*/
|
|
149
|
-
closestPointFromPointsIndex(inputs
|
|
136
|
+
closestPointFromPointsIndex(inputs) {
|
|
150
137
|
return this.closestPointFromPointData(inputs).index;
|
|
151
138
|
}
|
|
152
|
-
|
|
153
139
|
/**
|
|
154
140
|
* Finds the closest point in a collection
|
|
155
141
|
* @param inputs Point and points collection to find the closest point in
|
|
@@ -158,10 +144,9 @@ export class Point {
|
|
|
158
144
|
* @shortname closest pt
|
|
159
145
|
* @drawable true
|
|
160
146
|
*/
|
|
161
|
-
closestPointFromPoints(inputs
|
|
162
|
-
return this.closestPointFromPointData(inputs).point
|
|
147
|
+
closestPointFromPoints(inputs) {
|
|
148
|
+
return this.closestPointFromPointData(inputs).point;
|
|
163
149
|
}
|
|
164
|
-
|
|
165
150
|
/**
|
|
166
151
|
* Finds the distance between two points
|
|
167
152
|
* @param inputs Coordinates of start and end points
|
|
@@ -170,13 +155,12 @@ export class Point {
|
|
|
170
155
|
* @shortname distance
|
|
171
156
|
* @drawable false
|
|
172
157
|
*/
|
|
173
|
-
distance(inputs
|
|
158
|
+
distance(inputs) {
|
|
174
159
|
const x = inputs.endPoint[0] - inputs.startPoint[0];
|
|
175
160
|
const y = inputs.endPoint[1] - inputs.startPoint[1];
|
|
176
161
|
const z = inputs.endPoint[2] - inputs.startPoint[2];
|
|
177
162
|
return Math.sqrt(x * x + y * y + z * z);
|
|
178
163
|
}
|
|
179
|
-
|
|
180
164
|
/**
|
|
181
165
|
* Finds the distances between the start point and multiple end points
|
|
182
166
|
* @param inputs Coordinates of start and end points
|
|
@@ -185,12 +169,11 @@ export class Point {
|
|
|
185
169
|
* @shortname distances to points
|
|
186
170
|
* @drawable false
|
|
187
171
|
*/
|
|
188
|
-
distancesToPoints(inputs
|
|
172
|
+
distancesToPoints(inputs) {
|
|
189
173
|
return inputs.endPoints.map(pt => {
|
|
190
174
|
return this.distance({ startPoint: inputs.startPoint, endPoint: pt });
|
|
191
175
|
});
|
|
192
176
|
}
|
|
193
|
-
|
|
194
177
|
/**
|
|
195
178
|
* Multiply point by a specified amount
|
|
196
179
|
* @param inputs The point to be multiplied and the amount of points to create
|
|
@@ -199,14 +182,13 @@ export class Point {
|
|
|
199
182
|
* @shortname multiply point
|
|
200
183
|
* @drawable true
|
|
201
184
|
*/
|
|
202
|
-
multiplyPoint(inputs
|
|
185
|
+
multiplyPoint(inputs) {
|
|
203
186
|
const points = [];
|
|
204
187
|
for (let i = 0; i < inputs.amountOfPoints; i++) {
|
|
205
188
|
points.push([inputs.point[0], inputs.point[1], inputs.point[2]]);
|
|
206
189
|
}
|
|
207
190
|
return points;
|
|
208
191
|
}
|
|
209
|
-
|
|
210
192
|
/**
|
|
211
193
|
* Get x coordinate of the point
|
|
212
194
|
* @param inputs The point
|
|
@@ -215,10 +197,9 @@ export class Point {
|
|
|
215
197
|
* @shortname x coord
|
|
216
198
|
* @drawable false
|
|
217
199
|
*/
|
|
218
|
-
getX(inputs
|
|
200
|
+
getX(inputs) {
|
|
219
201
|
return inputs.point[0];
|
|
220
202
|
}
|
|
221
|
-
|
|
222
203
|
/**
|
|
223
204
|
* Get y coordinate of the point
|
|
224
205
|
* @param inputs The point
|
|
@@ -227,10 +208,9 @@ export class Point {
|
|
|
227
208
|
* @shortname y coord
|
|
228
209
|
* @drawable false
|
|
229
210
|
*/
|
|
230
|
-
getY(inputs
|
|
211
|
+
getY(inputs) {
|
|
231
212
|
return inputs.point[1];
|
|
232
213
|
}
|
|
233
|
-
|
|
234
214
|
/**
|
|
235
215
|
* Get z coordinate of the point
|
|
236
216
|
* @param inputs The point
|
|
@@ -239,10 +219,9 @@ export class Point {
|
|
|
239
219
|
* @shortname z coord
|
|
240
220
|
* @drawable false
|
|
241
221
|
*/
|
|
242
|
-
getZ(inputs
|
|
222
|
+
getZ(inputs) {
|
|
243
223
|
return inputs.point[2];
|
|
244
224
|
}
|
|
245
|
-
|
|
246
225
|
/**
|
|
247
226
|
* Get average point of points
|
|
248
227
|
* @param inputs The points
|
|
@@ -251,24 +230,21 @@ export class Point {
|
|
|
251
230
|
* @shortname average point
|
|
252
231
|
* @drawable true
|
|
253
232
|
*/
|
|
254
|
-
averagePoint(inputs
|
|
233
|
+
averagePoint(inputs) {
|
|
255
234
|
const xVals = [];
|
|
256
235
|
const yVals = [];
|
|
257
236
|
const zVals = [];
|
|
258
|
-
|
|
259
237
|
inputs.points.forEach(pt => {
|
|
260
238
|
xVals.push(pt[0]);
|
|
261
239
|
yVals.push(pt[1]);
|
|
262
240
|
zVals.push(pt[2]);
|
|
263
241
|
});
|
|
264
|
-
|
|
265
242
|
return [
|
|
266
243
|
xVals.reduce((p, c) => p + c, 0) / inputs.points.length,
|
|
267
244
|
yVals.reduce((p, c) => p + c, 0) / inputs.points.length,
|
|
268
245
|
zVals.reduce((p, c) => p + c, 0) / inputs.points.length,
|
|
269
246
|
];
|
|
270
247
|
}
|
|
271
|
-
|
|
272
248
|
/**
|
|
273
249
|
* Creates the xyz point
|
|
274
250
|
* @param inputs xyz information
|
|
@@ -277,10 +253,9 @@ export class Point {
|
|
|
277
253
|
* @shortname point xyz
|
|
278
254
|
* @drawable true
|
|
279
255
|
*/
|
|
280
|
-
pointXYZ(inputs
|
|
256
|
+
pointXYZ(inputs) {
|
|
281
257
|
return [inputs.x, inputs.y, inputs.z];
|
|
282
258
|
}
|
|
283
|
-
|
|
284
259
|
/**
|
|
285
260
|
* Creates the xy point
|
|
286
261
|
* @param inputs xy information
|
|
@@ -289,10 +264,9 @@ export class Point {
|
|
|
289
264
|
* @shortname point xy
|
|
290
265
|
* @drawable false
|
|
291
266
|
*/
|
|
292
|
-
pointXY(inputs
|
|
267
|
+
pointXY(inputs) {
|
|
293
268
|
return [inputs.x, inputs.y];
|
|
294
269
|
}
|
|
295
|
-
|
|
296
270
|
/**
|
|
297
271
|
* Creates the spiral out of multiple points
|
|
298
272
|
* @param inputs Spiral information
|
|
@@ -301,7 +275,7 @@ export class Point {
|
|
|
301
275
|
* @shortname spiral
|
|
302
276
|
* @drawable true
|
|
303
277
|
*/
|
|
304
|
-
spiral(inputs
|
|
278
|
+
spiral(inputs) {
|
|
305
279
|
const phi = inputs.phi;
|
|
306
280
|
const b = Math.log(phi) / (Math.PI / inputs.widening);
|
|
307
281
|
const spiral = [];
|
|
@@ -314,7 +288,6 @@ export class Point {
|
|
|
314
288
|
}
|
|
315
289
|
return spiral;
|
|
316
290
|
}
|
|
317
|
-
|
|
318
291
|
/**
|
|
319
292
|
* Creates a flat point grid on XY plane. This grid contains center points for hexagons of the given radius.
|
|
320
293
|
* Be aware that we control only the nr of hexagons to be made and not the length and width of the grid.
|
|
@@ -324,7 +297,7 @@ export class Point {
|
|
|
324
297
|
* @shortname hex grid
|
|
325
298
|
* @drawable true
|
|
326
299
|
*/
|
|
327
|
-
hexGrid(inputs
|
|
300
|
+
hexGrid(inputs) {
|
|
328
301
|
const xLength = Math.sqrt(Math.pow(inputs.radiusHexagon, 2) - Math.pow(inputs.radiusHexagon / 2, 2));
|
|
329
302
|
const points = [];
|
|
330
303
|
for (let ix = 0; ix < inputs.nrHexagonsX; ix++) {
|
|
@@ -335,7 +308,6 @@ export class Point {
|
|
|
335
308
|
points.push([adjustX, coordY, 0]);
|
|
336
309
|
}
|
|
337
310
|
}
|
|
338
|
-
|
|
339
311
|
if (inputs.orientOnCenter) {
|
|
340
312
|
const compensateX = points[points.length - 1][0] / 2;
|
|
341
313
|
const compensateY = points[points.length - 1][1] / 2;
|
|
@@ -343,16 +315,13 @@ export class Point {
|
|
|
343
315
|
points[index] = [p[0] - compensateX, p[1] - compensateY, 0];
|
|
344
316
|
});
|
|
345
317
|
}
|
|
346
|
-
|
|
347
318
|
if (inputs.pointsOnGround) {
|
|
348
319
|
points.forEach((p, index) => {
|
|
349
320
|
points[index] = [p[0], 0, p[1]];
|
|
350
321
|
});
|
|
351
322
|
}
|
|
352
|
-
|
|
353
323
|
return points;
|
|
354
324
|
}
|
|
355
|
-
|
|
356
325
|
/**
|
|
357
326
|
* Removes consecutive duplicates from the point array with tolerance
|
|
358
327
|
* @param inputs points, tolerance and check first and last
|
|
@@ -361,26 +330,22 @@ export class Point {
|
|
|
361
330
|
* @shortname remove duplicates
|
|
362
331
|
* @drawable true
|
|
363
332
|
*/
|
|
364
|
-
removeConsecutiveDuplicates(inputs
|
|
333
|
+
removeConsecutiveDuplicates(inputs) {
|
|
365
334
|
return this.geometryHelper.removeConsecutivePointDuplicates(inputs.points, inputs.checkFirstAndLast, inputs.tolerance);
|
|
366
335
|
}
|
|
367
|
-
|
|
368
|
-
private closestPointFromPointData(inputs: Inputs.Point.ClosestPointFromPointsDto): {
|
|
369
|
-
index: number, point: Inputs.Base.Point3, distance: number
|
|
370
|
-
} {
|
|
336
|
+
closestPointFromPointData(inputs) {
|
|
371
337
|
let distance = Number.MAX_SAFE_INTEGER;
|
|
372
|
-
let closestPointIndex
|
|
373
|
-
let point
|
|
338
|
+
let closestPointIndex;
|
|
339
|
+
let point;
|
|
374
340
|
for (let i = 0; i < inputs.points.length; i++) {
|
|
375
341
|
const pt = inputs.points[i];
|
|
376
342
|
const currentDist = this.distance({ startPoint: inputs.point, endPoint: pt });
|
|
377
343
|
if (currentDist < distance) {
|
|
378
344
|
distance = currentDist;
|
|
379
345
|
closestPointIndex = i;
|
|
380
|
-
point = pt
|
|
346
|
+
point = pt;
|
|
381
347
|
}
|
|
382
348
|
}
|
|
383
349
|
return { index: closestPointIndex + 1, distance, point };
|
|
384
350
|
}
|
|
385
|
-
|
|
386
351
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as Inputs from "../inputs";
|
|
2
|
+
/**
|
|
3
|
+
* Contains various text methods.
|
|
4
|
+
*/
|
|
5
|
+
export declare class TextBitByBit {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a text
|
|
8
|
+
* @param inputs a text
|
|
9
|
+
* @returns text
|
|
10
|
+
* @group create
|
|
11
|
+
* @shortname text
|
|
12
|
+
* @drawable false
|
|
13
|
+
*/
|
|
14
|
+
create(inputs: Inputs.Text.TextDto): string;
|
|
15
|
+
/**
|
|
16
|
+
* Split the text to multiple pieces by a separator
|
|
17
|
+
* @param inputs a text
|
|
18
|
+
* @returns text
|
|
19
|
+
* @group transform
|
|
20
|
+
* @shortname split
|
|
21
|
+
* @drawable false
|
|
22
|
+
*/
|
|
23
|
+
split(inputs: Inputs.Text.TextSplitDto): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Replace all occurrences of a text by another text
|
|
26
|
+
* @param inputs a text
|
|
27
|
+
* @returns text
|
|
28
|
+
* @group transform
|
|
29
|
+
* @shortname replaceAll
|
|
30
|
+
* @drawable false
|
|
31
|
+
*/
|
|
32
|
+
replaceAll(inputs: Inputs.Text.TextReplaceDto): string;
|
|
33
|
+
/**
|
|
34
|
+
* Join multiple items by a separator into text
|
|
35
|
+
* @param inputs a list of items
|
|
36
|
+
* @returns text
|
|
37
|
+
* @group transform
|
|
38
|
+
* @shortname join
|
|
39
|
+
* @drawable false
|
|
40
|
+
*/
|
|
41
|
+
join(inputs: Inputs.Text.TextJoinDto): string;
|
|
42
|
+
/**
|
|
43
|
+
* Transform any item to text
|
|
44
|
+
* @param inputs any item
|
|
45
|
+
* @returns text
|
|
46
|
+
* @group transform
|
|
47
|
+
* @shortname to string
|
|
48
|
+
* @drawable false
|
|
49
|
+
*/
|
|
50
|
+
toString<T>(inputs: Inputs.Text.ToStringDto<T>): string;
|
|
51
|
+
/**
|
|
52
|
+
* Transform each item in list to text
|
|
53
|
+
* @param inputs list of items
|
|
54
|
+
* @returns texts
|
|
55
|
+
* @group transform
|
|
56
|
+
* @shortname to strings
|
|
57
|
+
* @drawable false
|
|
58
|
+
*/
|
|
59
|
+
toStringEach<T>(inputs: Inputs.Text.ToStringEachDto<T>): string[];
|
|
60
|
+
/**
|
|
61
|
+
* Format a text with values
|
|
62
|
+
* @param inputs a text and values
|
|
63
|
+
* @returns formatted text
|
|
64
|
+
* @group transform
|
|
65
|
+
* @shortname format
|
|
66
|
+
* @drawable false
|
|
67
|
+
*/
|
|
68
|
+
format(inputs: Inputs.Text.TextFormatDto): string;
|
|
69
|
+
}
|