@bitbybit-dev/base 1.2.0 → 1.3.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/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +13 -12
- package/lib/api/inputs/color-inputs.d.ts +97 -48
- package/lib/api/inputs/color-inputs.js +95 -46
- package/lib/api/inputs/dates-inputs.d.ts +67 -26
- package/lib/api/inputs/dates-inputs.js +57 -16
- package/lib/api/inputs/io-inputs.d.ts +13 -15
- package/lib/api/inputs/io-inputs.js +7 -8
- package/lib/api/inputs/line-inputs.d.ts +88 -33
- package/lib/api/inputs/line-inputs.js +61 -11
- package/lib/api/inputs/lists-inputs.d.ts +207 -96
- package/lib/api/inputs/lists-inputs.js +153 -45
- package/lib/api/inputs/logic-inputs.d.ts +52 -22
- package/lib/api/inputs/logic-inputs.js +41 -12
- package/lib/api/inputs/math-inputs.d.ts +113 -52
- package/lib/api/inputs/math-inputs.js +112 -51
- package/lib/api/inputs/mesh-inputs.d.ts +30 -11
- package/lib/api/inputs/mesh-inputs.js +21 -3
- package/lib/api/inputs/point-inputs.d.ts +240 -107
- package/lib/api/inputs/point-inputs.js +199 -73
- package/lib/api/inputs/polyline-inputs.d.ts +68 -28
- package/lib/api/inputs/polyline-inputs.js +48 -13
- package/lib/api/inputs/text-inputs.d.ts +117 -46
- package/lib/api/inputs/text-inputs.js +111 -41
- package/lib/api/inputs/transforms-inputs.d.ts +65 -23
- package/lib/api/inputs/transforms-inputs.js +64 -22
- package/lib/api/inputs/vector-inputs.d.ts +154 -76
- package/lib/api/inputs/vector-inputs.js +132 -57
- package/lib/api/models/point/hex-grid-data.d.ts +1 -1
- package/lib/api/models/point/hex-grid-data.js +1 -1
- package/lib/api/services/color.d.ts +149 -70
- package/lib/api/services/color.js +149 -70
- package/lib/api/services/dates.d.ts +313 -150
- package/lib/api/services/dates.js +313 -150
- package/lib/api/services/line.d.ts +138 -68
- package/lib/api/services/line.js +138 -68
- package/lib/api/services/lists.d.ts +357 -177
- package/lib/api/services/lists.js +357 -177
- package/lib/api/services/logic.d.ts +98 -45
- package/lib/api/services/logic.js +98 -45
- package/lib/api/services/math.d.ts +363 -211
- package/lib/api/services/math.js +363 -211
- package/lib/api/services/mesh.d.ts +73 -31
- package/lib/api/services/mesh.js +73 -31
- package/lib/api/services/point.d.ts +367 -147
- package/lib/api/services/point.js +367 -147
- package/lib/api/services/polyline.d.ts +146 -71
- package/lib/api/services/polyline.js +146 -71
- package/lib/api/services/text.d.ts +320 -165
- package/lib/api/services/text.js +320 -165
- package/lib/api/services/transforms.d.ts +145 -58
- package/lib/api/services/transforms.js +145 -58
- package/lib/api/services/vector.d.ts +381 -156
- package/lib/api/services/vector.js +381 -156
- package/package.json +1 -1
|
@@ -5,9 +5,10 @@ import { Vector } from "./vector";
|
|
|
5
5
|
import * as Models from "../models";
|
|
6
6
|
import { Lists } from "./lists";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Points as plain number arrays. A point is `[x, y, z]` with Y pointing up, the same shape as a
|
|
9
|
+
* vector, so the two can be passed to each other's methods; a 2D point is `[x, y]`. Every method
|
|
10
|
+
* returns new points or numbers and never changes its inputs. Angles are in degrees and lengths in
|
|
11
|
+
* model units.
|
|
11
12
|
*/
|
|
12
13
|
export declare class Point {
|
|
13
14
|
private readonly geometryHelper;
|
|
@@ -16,346 +17,565 @@ export declare class Point {
|
|
|
16
17
|
private readonly lists;
|
|
17
18
|
constructor(geometryHelper: GeometryHelper, transforms: Transforms, vector: Vector, lists: Lists);
|
|
18
19
|
/**
|
|
19
|
-
* Applies transformation matrix
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
20
|
+
* Applies a transformation matrix, or a list of them in order, to one point.
|
|
21
|
+
*
|
|
22
|
+
* Example: point [0,0,0] with a translation by [5,5,0] -> [5,5,0]
|
|
23
|
+
* @param inputs - The point and the transformation to apply
|
|
24
|
+
* @returns The transformed point
|
|
23
25
|
* @group transforms
|
|
24
26
|
* @shortname transform point
|
|
25
27
|
* @drawable true
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const moved = bitbybit.point.transformPoint({
|
|
31
|
+
* point: [0, 0, 0],
|
|
32
|
+
* transformation: bitbybit.transforms.translationXYZ({ translation: [5, 5, 0] }),
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
26
35
|
*/
|
|
27
36
|
transformPoint(inputs: Inputs.Point.TransformPointDto): Inputs.Base.Point3;
|
|
28
37
|
/**
|
|
29
|
-
* Applies same transformation matrix
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
38
|
+
* Applies the same transformation matrix, or list of them in order, to every point.
|
|
39
|
+
*
|
|
40
|
+
* Example: five points with a 90 degree rotation -> all five rotated together
|
|
41
|
+
* @param inputs - The points and the transformation to apply to each
|
|
42
|
+
* @returns The transformed points, in the same order
|
|
33
43
|
* @group transforms
|
|
34
44
|
* @shortname transform points
|
|
35
45
|
* @drawable true
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const rotated = bitbybit.point.transformPoints({
|
|
49
|
+
* points: [[1, 0, 0], [2, 0, 0]],
|
|
50
|
+
* transformation: bitbybit.transforms.rotationCenterAxis({ center: [0, 0, 0], axis: [0, 1, 0], angle: 90 }),
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
36
53
|
*/
|
|
37
54
|
transformPoints(inputs: Inputs.Point.TransformPointsDto): Inputs.Base.Point3[];
|
|
38
55
|
/**
|
|
39
|
-
* Applies different transformation
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
56
|
+
* Applies a different transformation to each point: the first transformation to the first
|
|
57
|
+
* point, and so on.
|
|
58
|
+
*
|
|
59
|
+
* The two lists must have the same length, or an error is thrown.
|
|
60
|
+
* Example: three points with three translations -> each point moved by its own translation
|
|
61
|
+
* @param inputs - The points and one transformation per point
|
|
62
|
+
* @returns The transformed points, in the same order
|
|
44
63
|
* @group transforms
|
|
45
64
|
* @shortname transforms for points
|
|
46
65
|
* @drawable true
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const placed = bitbybit.point.transformsForPoints({
|
|
69
|
+
* points: [[0, 0, 0], [1, 0, 0]],
|
|
70
|
+
* transformation: bitbybit.transforms.translationsXYZ({ translations: [[0, 1, 0], [0, 2, 0]] }),
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
47
73
|
*/
|
|
48
74
|
transformsForPoints(inputs: Inputs.Point.TransformsForPointsDto): Inputs.Base.Point3[];
|
|
49
75
|
/**
|
|
50
|
-
* Moves
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
76
|
+
* Moves every point by the same vector.
|
|
77
|
+
*
|
|
78
|
+
* Example: points [[0,0,0], [1,0,0]] by [5,5,0] -> [[5,5,0], [6,5,0]]
|
|
79
|
+
* @param inputs - The points and the vector to move them by
|
|
80
|
+
* @returns The moved points, in the same order
|
|
54
81
|
* @group transforms
|
|
55
82
|
* @shortname translate points
|
|
56
83
|
* @drawable true
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const moved = bitbybit.point.translatePoints({ points: [[0, 0, 0], [1, 0, 0]], translation: [5, 5, 0] });
|
|
87
|
+
* ```
|
|
57
88
|
*/
|
|
58
89
|
translatePoints(inputs: Inputs.Point.TranslatePointsDto): Inputs.Base.Point3[];
|
|
59
90
|
/**
|
|
60
|
-
* Moves
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
91
|
+
* Moves each point by its own vector: the first point by the first vector, and so on.
|
|
92
|
+
*
|
|
93
|
+
* The two lists must have the same length, or an error is thrown.
|
|
94
|
+
* Example: three points with three vectors -> each point moved by its own vector
|
|
95
|
+
* @param inputs - The points and one vector per point
|
|
96
|
+
* @returns The moved points, in the same order
|
|
65
97
|
* @group transforms
|
|
66
98
|
* @shortname translate points with vectors
|
|
67
99
|
* @drawable true
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const moved = bitbybit.point.translatePointsWithVectors({
|
|
103
|
+
* points: [[0, 0, 0], [1, 0, 0]],
|
|
104
|
+
* translations: [[0, 1, 0], [0, 2, 0]],
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
68
107
|
*/
|
|
69
108
|
translatePointsWithVectors(inputs: Inputs.Point.TranslatePointsWithVectorsDto): Inputs.Base.Point3[];
|
|
70
109
|
/**
|
|
71
|
-
* Moves
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
110
|
+
* Moves every point by the given x, y and z amounts.
|
|
111
|
+
*
|
|
112
|
+
* Example: point [0,0,0] with x=10, y=5, z=0 -> [10,5,0]
|
|
113
|
+
* @param inputs - The points and the distance to move along each axis
|
|
114
|
+
* @returns The moved points, in the same order
|
|
75
115
|
* @group transforms
|
|
76
116
|
* @shortname translate xyz points
|
|
77
117
|
* @drawable true
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const lifted = bitbybit.point.translateXYZPoints({ points: [[0, 0, 0], [1, 0, 0]], x: 0, y: 5, z: 0 });
|
|
121
|
+
* ```
|
|
78
122
|
*/
|
|
79
123
|
translateXYZPoints(inputs: Inputs.Point.TranslateXYZPointsDto): Inputs.Base.Point3[];
|
|
80
124
|
/**
|
|
81
|
-
* Scales
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @
|
|
125
|
+
* Scales points away from or toward a center, with its own factor per axis.
|
|
126
|
+
*
|
|
127
|
+
* Example: point [10,0,0] about center [5,0,0] with factors [2,1,1] -> [15,0,0]
|
|
128
|
+
* @param inputs - The points, the center to scale about and the factor per axis
|
|
129
|
+
* @returns The scaled points, in the same order
|
|
85
130
|
* @group transforms
|
|
86
131
|
* @shortname scale points on center
|
|
87
132
|
* @drawable true
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const stretched = bitbybit.point.scalePointsCenterXYZ({
|
|
136
|
+
* points: [[10, 0, 0], [0, 10, 0]],
|
|
137
|
+
* center: [0, 0, 0],
|
|
138
|
+
* scaleXyz: [2, 1, 1],
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
88
141
|
*/
|
|
89
142
|
scalePointsCenterXYZ(inputs: Inputs.Point.ScalePointsCenterXYZDto): Inputs.Base.Point3[];
|
|
90
143
|
/**
|
|
91
|
-
* Stretches
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
144
|
+
* Stretches points along one direction, measured from a center; distances across that direction
|
|
145
|
+
* stay as they are.
|
|
146
|
+
*
|
|
147
|
+
* Example: point [10,0,0] from center [0,0,0] along [1,0,0] with scale 2 -> [20,0,0]
|
|
148
|
+
* @param inputs - The points, the center, the direction to stretch along and the factor
|
|
149
|
+
* @returns The stretched points, in the same order
|
|
95
150
|
* @group transforms
|
|
96
151
|
* @shortname stretch points dir from center
|
|
97
152
|
* @drawable true
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const taller = bitbybit.point.stretchPointsDirFromCenter({
|
|
156
|
+
* points: [[0, 1, 0], [0, 2, 0]],
|
|
157
|
+
* center: [0, 0, 0],
|
|
158
|
+
* direction: [0, 1, 0],
|
|
159
|
+
* scale: 2,
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
98
162
|
*/
|
|
99
163
|
stretchPointsDirFromCenter(inputs: Inputs.Point.StretchPointsDirFromCenterDto): Inputs.Base.Point3[];
|
|
100
164
|
/**
|
|
101
|
-
* Rotates
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
165
|
+
* Rotates points around an axis that passes through a center.
|
|
166
|
+
*
|
|
167
|
+
* The angle is in degrees and turns counter-clockwise when the axis points toward you.
|
|
168
|
+
* Example: point [10,0,0] around the Y axis through [0,0,0] by 90 -> [0,0,-10]
|
|
169
|
+
* @param inputs - The points, the axis direction, the center it passes through and the angle in degrees
|
|
170
|
+
* @returns The rotated points, in the same order
|
|
105
171
|
* @group transforms
|
|
106
172
|
* @shortname rotate points center axis
|
|
107
173
|
* @drawable true
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const turned = bitbybit.point.rotatePointsCenterAxis({
|
|
177
|
+
* points: [[10, 0, 0]],
|
|
178
|
+
* center: [0, 0, 0],
|
|
179
|
+
* axis: [0, 1, 0],
|
|
180
|
+
* angle: 90,
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
108
183
|
*/
|
|
109
184
|
rotatePointsCenterAxis(inputs: Inputs.Point.RotatePointsCenterAxisDto): Inputs.Base.Point3[];
|
|
110
185
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
186
|
+
* Finds the smallest axis-aligned box that holds all the points.
|
|
187
|
+
*
|
|
188
|
+
* The result carries the min and max corners, the center, and the width (X), height (Y) and
|
|
189
|
+
* length (Z).
|
|
190
|
+
* Example: points [[0,0,0], [10,5,3]] -> min [0,0,0], max [10,5,3], center [5,2.5,1.5]
|
|
191
|
+
* @param inputs - The points to enclose
|
|
192
|
+
* @returns The bounding box with its corners, center and sizes
|
|
115
193
|
* @group extract
|
|
116
194
|
* @shortname bounding box pts
|
|
117
195
|
* @drawable true
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const box = bitbybit.point.boundingBoxOfPoints({ points: [[0, 0, 0], [10, 5, 3], [-2, 1, 1]] });
|
|
199
|
+
* ```
|
|
118
200
|
*/
|
|
119
201
|
boundingBoxOfPoints(inputs: Inputs.Point.PointsDto): Inputs.Base.BoundingBox;
|
|
120
202
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @
|
|
203
|
+
* Measures the distance from a point to the nearest point in a list.
|
|
204
|
+
*
|
|
205
|
+
* Example: point [0,0,0] and points [[5,0,0], [10,0,0], [3,0,0]] -> 3
|
|
206
|
+
* @param inputs - The point to measure from and the points to search
|
|
207
|
+
* @returns The distance to the nearest point, in model units
|
|
125
208
|
* @group extract
|
|
126
209
|
* @shortname distance to closest pt
|
|
127
210
|
* @drawable false
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const nearest = bitbybit.point.closestPointFromPointsDistance({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
|
|
214
|
+
* ```
|
|
128
215
|
*/
|
|
129
216
|
closestPointFromPointsDistance(inputs: Inputs.Point.ClosestPointFromPointsDto): number;
|
|
130
217
|
/**
|
|
131
|
-
* Finds
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* @
|
|
218
|
+
* Finds the position of the nearest point in a list, counted from 1.
|
|
219
|
+
*
|
|
220
|
+
* Example: point [0,0,0] and points [[5,0,0], [10,0,0], [3,0,0]] -> 3
|
|
221
|
+
* @param inputs - The point to measure from and the points to search
|
|
222
|
+
* @returns The 1-based index of the nearest point
|
|
135
223
|
* @group extract
|
|
136
224
|
* @shortname index of closest pt
|
|
137
225
|
* @drawable false
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const index = bitbybit.point.closestPointFromPointsIndex({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
|
|
229
|
+
* ```
|
|
138
230
|
*/
|
|
139
231
|
closestPointFromPointsIndex(inputs: Inputs.Point.ClosestPointFromPointsDto): number;
|
|
140
232
|
/**
|
|
141
|
-
* Finds the nearest point in a
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* @
|
|
233
|
+
* Finds the nearest point in a list to a given point.
|
|
234
|
+
*
|
|
235
|
+
* Example: point [0,0,0] and points [[5,0,0], [10,0,0], [3,0,0]] -> [3,0,0]
|
|
236
|
+
* @param inputs - The point to measure from and the points to search
|
|
237
|
+
* @returns The nearest point
|
|
145
238
|
* @group extract
|
|
146
239
|
* @shortname closest pt
|
|
147
240
|
* @drawable true
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const nearest = bitbybit.point.closestPointFromPoints({ point: [0, 0, 0], points: [[5, 0, 0], [3, 0, 0]] });
|
|
244
|
+
* ```
|
|
148
245
|
*/
|
|
149
246
|
closestPointFromPoints(inputs: Inputs.Point.ClosestPointFromPointsDto): Inputs.Base.Point3;
|
|
150
247
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* @
|
|
248
|
+
* Measures the straight-line distance between two points.
|
|
249
|
+
*
|
|
250
|
+
* Example: [0,0,0] to [3,4,0] -> 5
|
|
251
|
+
* @param inputs - The two points
|
|
252
|
+
* @returns The distance in model units
|
|
155
253
|
* @group measure
|
|
156
254
|
* @shortname distance
|
|
157
255
|
* @drawable false
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const d = bitbybit.point.distance({ startPoint: [0, 0, 0], endPoint: [3, 4, 0] });
|
|
259
|
+
* ```
|
|
158
260
|
*/
|
|
159
261
|
distance(inputs: Inputs.Point.StartEndPointsDto): number;
|
|
160
262
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* @
|
|
263
|
+
* Measures the distance from one point to each point in a list.
|
|
264
|
+
*
|
|
265
|
+
* Example: start [0,0,0] and end points [[3,0,0], [0,4,0], [5,0,0]] -> [3, 4, 5]
|
|
266
|
+
* @param inputs - The start point and the points to measure to
|
|
267
|
+
* @returns One distance per end point, in the same order
|
|
165
268
|
* @group measure
|
|
166
269
|
* @shortname distances to points
|
|
167
270
|
* @drawable false
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* const distances = bitbybit.point.distancesToPoints({ startPoint: [0, 0, 0], endPoints: [[3, 0, 0], [0, 4, 0]] });
|
|
274
|
+
* ```
|
|
168
275
|
*/
|
|
169
276
|
distancesToPoints(inputs: Inputs.Point.StartEndPointsListDto): number[];
|
|
170
277
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* @
|
|
278
|
+
* Repeats one point a given number of times in a list.
|
|
279
|
+
*
|
|
280
|
+
* Example: point [5,5,0] three times -> [[5,5,0], [5,5,0], [5,5,0]]
|
|
281
|
+
* @param inputs - The point and how many copies to make
|
|
282
|
+
* @returns The list of copies
|
|
175
283
|
* @group transforms
|
|
176
284
|
* @shortname multiply point
|
|
177
285
|
* @drawable true
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* const copies = bitbybit.point.multiplyPoint({ point: [5, 5, 0], amountOfPoints: 3 });
|
|
289
|
+
* ```
|
|
178
290
|
*/
|
|
179
291
|
multiplyPoint(inputs: Inputs.Point.MultiplyPointDto): Inputs.Base.Point3[];
|
|
180
292
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* @
|
|
293
|
+
* Reads the X value of a point.
|
|
294
|
+
*
|
|
295
|
+
* Example: [5,10,3] -> 5
|
|
296
|
+
* @param inputs - The point
|
|
297
|
+
* @returns The X value
|
|
185
298
|
* @group get
|
|
186
299
|
* @shortname x coord
|
|
187
300
|
* @drawable false
|
|
188
301
|
*/
|
|
189
302
|
getX(inputs: Inputs.Point.PointDto): number;
|
|
190
303
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* @
|
|
304
|
+
* Reads the Y value of a point, the one that points up.
|
|
305
|
+
*
|
|
306
|
+
* Example: [5,10,3] -> 10
|
|
307
|
+
* @param inputs - The point
|
|
308
|
+
* @returns The Y value
|
|
195
309
|
* @group get
|
|
196
310
|
* @shortname y coord
|
|
197
311
|
* @drawable false
|
|
198
312
|
*/
|
|
199
313
|
getY(inputs: Inputs.Point.PointDto): number;
|
|
200
314
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* @
|
|
315
|
+
* Reads the Z value of a point.
|
|
316
|
+
*
|
|
317
|
+
* Example: [5,10,3] -> 3
|
|
318
|
+
* @param inputs - The point
|
|
319
|
+
* @returns The Z value
|
|
205
320
|
* @group get
|
|
206
321
|
* @shortname z coord
|
|
207
322
|
* @drawable false
|
|
208
323
|
*/
|
|
209
324
|
getZ(inputs: Inputs.Point.PointDto): number;
|
|
210
325
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* @
|
|
326
|
+
* Finds the average of the points, which is their center of mass when they weigh the same.
|
|
327
|
+
*
|
|
328
|
+
* Example: [[0,0,0], [10,0,0], [10,10,0]] -> [6.67,3.33,0]
|
|
329
|
+
* @param inputs - The points to average
|
|
330
|
+
* @returns The average point
|
|
215
331
|
* @group extract
|
|
216
332
|
* @shortname average point
|
|
217
333
|
* @drawable true
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* const center = bitbybit.point.averagePoint({ points: [[0, 0, 0], [10, 0, 0], [10, 10, 0]] });
|
|
337
|
+
* ```
|
|
218
338
|
*/
|
|
219
339
|
averagePoint(inputs: Inputs.Point.PointsDto): Inputs.Base.Point3;
|
|
220
340
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* @
|
|
341
|
+
* Builds a 3D point from its x, y and z values.
|
|
342
|
+
*
|
|
343
|
+
* Example: x=10, y=5, z=3 -> [10,5,3]
|
|
344
|
+
* @param inputs - The three values
|
|
345
|
+
* @returns The point `[x, y, z]`
|
|
225
346
|
* @group create
|
|
226
347
|
* @shortname point xyz
|
|
227
348
|
* @drawable true
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* const point = bitbybit.point.pointXYZ({ x: 10, y: 5, z: 3 });
|
|
352
|
+
* ```
|
|
228
353
|
*/
|
|
229
354
|
pointXYZ(inputs: Inputs.Point.PointXYZDto): Inputs.Base.Point3;
|
|
230
355
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* @
|
|
356
|
+
* Builds a 2D point from its x and y values.
|
|
357
|
+
*
|
|
358
|
+
* Example: x=10, y=5 -> [10,5]
|
|
359
|
+
* @param inputs - The two values
|
|
360
|
+
* @returns The point `[x, y]`
|
|
235
361
|
* @group create
|
|
236
362
|
* @shortname point xy
|
|
237
363
|
* @drawable false
|
|
364
|
+
* @example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* const point = bitbybit.point.pointXY({ x: 10, y: 5 });
|
|
367
|
+
* ```
|
|
238
368
|
*/
|
|
239
369
|
pointXY(inputs: Inputs.Point.PointXYDto): Inputs.Base.Point2;
|
|
240
370
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
371
|
+
* Lays out points along a logarithmic spiral in the XY plane, from the origin outward to
|
|
372
|
+
* `radius`.
|
|
373
|
+
*
|
|
374
|
+
* `numberPoints` sets how many points are placed, `phi` and `widening` how quickly the spiral
|
|
375
|
+
* opens, and `factor` where along the curve it starts. Every point has z = 0.
|
|
376
|
+
* @param inputs - The point count, the radius and the shape of the spiral
|
|
377
|
+
* @returns The points along the spiral, from the center outward
|
|
246
378
|
* @group create
|
|
247
379
|
* @shortname spiral
|
|
248
380
|
* @drawable true
|
|
381
|
+
* @example
|
|
382
|
+
* ```typescript
|
|
383
|
+
* const points = bitbybit.point.spiral({ phi: 0.9, numberPoints: 100, widening: 3, radius: 10, factor: 1 });
|
|
384
|
+
* ```
|
|
249
385
|
*/
|
|
250
386
|
spiral(inputs: Inputs.Point.SpiralDto): Inputs.Base.Point3[];
|
|
251
387
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
388
|
+
* Lays out the centers of a honeycomb of hexagons in the XY plane.
|
|
389
|
+
*
|
|
390
|
+
* `radiusHexagon` is the distance from a hexagon's center to a corner; columns run along X and
|
|
391
|
+
* rows along Y, every second row shifted by half a column. `orientOnCenter` centers the grid on
|
|
392
|
+
* the origin, `pointsOnGround` lays it on the XZ plane.
|
|
393
|
+
* @param inputs - The hexagon size, how many columns and rows, and where to place the grid
|
|
394
|
+
* @returns The center points, row by row
|
|
257
395
|
* @group create
|
|
258
396
|
* @shortname hex grid
|
|
259
397
|
* @drawable true
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* const centers = bitbybit.point.hexGrid({ radiusHexagon: 1, nrHexagonsX: 5, nrHexagonsY: 4, orientOnCenter: true, pointsOnGround: false });
|
|
401
|
+
* ```
|
|
260
402
|
*/
|
|
261
403
|
hexGrid(inputs: Inputs.Point.HexGridCentersDto): Inputs.Base.Point3[];
|
|
262
404
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
405
|
+
* Lays out a honeycomb of hexagons that fills a given width and height, sizing the hexagons
|
|
406
|
+
* from the counts.
|
|
407
|
+
*
|
|
408
|
+
* The result carries the center points and the six corners of every hexagon. A corner points up
|
|
409
|
+
* unless `flatTop` is set; the extend flags stretch the outer rows past the edges to cover the
|
|
410
|
+
* rectangle without a jagged border.
|
|
411
|
+
* @param inputs - The area to fill, the hexagon counts, the orientation and the placement options
|
|
412
|
+
* @returns The centers and the corner points of every hexagon
|
|
268
413
|
* @group create
|
|
269
414
|
* @shortname scaled hex grid to fit
|
|
270
415
|
* @drawable false
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* const grid = bitbybit.point.hexGridScaledToFit({
|
|
419
|
+
* width: 10,
|
|
420
|
+
* height: 10,
|
|
421
|
+
* nrHexagonsInWidth: 5,
|
|
422
|
+
* nrHexagonsInHeight: 5,
|
|
423
|
+
* flatTop: false,
|
|
424
|
+
* centerGrid: true,
|
|
425
|
+
* });
|
|
426
|
+
* ```
|
|
271
427
|
*/
|
|
272
428
|
hexGridScaledToFit(inputs: Inputs.Point.HexGridScaledToFitDto): Models.Point.HexGridData;
|
|
273
429
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
430
|
+
* Finds the largest fillet that fits a corner: the arc touches both segments and stays inside
|
|
431
|
+
* them.
|
|
432
|
+
*
|
|
433
|
+
* The corner is `end`; `start` and `center` are the far ends of the two segments that meet
|
|
434
|
+
* there. The radius is limited by the shorter segment. A straight or folded-back corner, or a
|
|
435
|
+
* segment shorter than `tolerance`, gives 0.
|
|
436
|
+
* @param inputs - The far end of each segment, the corner they share, and the tolerance
|
|
437
|
+
* @returns The largest fillet radius, in model units
|
|
279
438
|
* @group fillet
|
|
280
439
|
* @shortname max fillet radius
|
|
281
440
|
* @drawable false
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* const radius = bitbybit.point.maxFilletRadius({ start: [10, 0, 0], center: [0, 10, 0], end: [0, 0, 0], tolerance: 1e-7 });
|
|
444
|
+
* ```
|
|
282
445
|
*/
|
|
283
446
|
maxFilletRadius(inputs: Inputs.Point.ThreePointsToleranceDto): number;
|
|
284
447
|
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
448
|
+
* Finds the largest fillet at a corner whose arc touches each segment within its nearer half,
|
|
449
|
+
* so neighboring corners of a polyline can each be filleted without the arcs overlapping.
|
|
450
|
+
*
|
|
451
|
+
* The corner is `end`; `start` and `center` are the far ends of the two segments. A straight or
|
|
452
|
+
* folded-back corner, or a segment shorter than `tolerance`, gives 0.
|
|
453
|
+
* @param inputs - The far end of each segment, the corner they share, and the tolerance
|
|
454
|
+
* @returns The largest fillet radius under the half-segment rule, in model units
|
|
290
455
|
* @group fillet
|
|
291
456
|
* @shortname max fillet radius half line
|
|
292
457
|
* @drawable false
|
|
458
|
+
* @example
|
|
459
|
+
* ```typescript
|
|
460
|
+
* const radius = bitbybit.point.maxFilletRadiusHalfLine({ start: [10, 0, 0], center: [0, 10, 0], end: [0, 0, 0], tolerance: 1e-7 });
|
|
461
|
+
* ```
|
|
293
462
|
*/
|
|
294
463
|
maxFilletRadiusHalfLine(inputs: Inputs.Point.ThreePointsToleranceDto): number;
|
|
295
464
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
465
|
+
* Finds the largest fillet for every corner of a polyline, each limited to the nearer half of
|
|
466
|
+
* its segments so the fillets never overlap.
|
|
467
|
+
*
|
|
468
|
+
* With `checkLastWithFirst` on, the polyline is treated as closed and the two corners at the
|
|
469
|
+
* ends are included. Fewer than three points give an empty list.
|
|
470
|
+
* @param inputs - The polyline points, whether it is closed, and the tolerance
|
|
471
|
+
* @returns One radius per corner, in the order of the corners
|
|
301
472
|
* @group fillet
|
|
302
473
|
* @shortname max fillets half line
|
|
303
474
|
* @drawable false
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* const radii = bitbybit.point.maxFilletsHalfLine({
|
|
478
|
+
* points: [[0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0]],
|
|
479
|
+
* checkLastWithFirst: true,
|
|
480
|
+
* tolerance: 1e-7,
|
|
481
|
+
* });
|
|
482
|
+
* ```
|
|
304
483
|
*/
|
|
305
484
|
maxFilletsHalfLine(inputs: Inputs.Point.PointsMaxFilletsHalfLineDto): number[];
|
|
306
485
|
/**
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
* @
|
|
313
|
-
*
|
|
314
|
-
* calculated maximum radius is 0.
|
|
486
|
+
* Finds one fillet radius that fits every corner of a polyline: the smallest of the per-corner
|
|
487
|
+
* maximums under the half-segment rule.
|
|
488
|
+
*
|
|
489
|
+
* With `checkLastWithFirst` on, the polyline is treated as closed. Fewer than three points, or
|
|
490
|
+
* any corner that allows no fillet, give 0.
|
|
491
|
+
* @param inputs - The polyline points, whether it is closed, and the tolerance
|
|
492
|
+
* @returns The radius that fits every corner, in model units
|
|
315
493
|
* @group fillet
|
|
316
494
|
* @shortname safest fillet radii points
|
|
317
495
|
* @drawable false
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* const radius = bitbybit.point.safestPointsMaxFilletHalfLine({
|
|
499
|
+
* points: [[0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0]],
|
|
500
|
+
* checkLastWithFirst: true,
|
|
501
|
+
* tolerance: 1e-7,
|
|
502
|
+
* });
|
|
503
|
+
* ```
|
|
318
504
|
*/
|
|
319
505
|
safestPointsMaxFilletHalfLine(inputs: Inputs.Point.PointsMaxFilletsHalfLineDto): number;
|
|
320
506
|
/**
|
|
321
|
-
* Removes
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
507
|
+
* Removes a point when it repeats the one right before it; the same point further away is kept.
|
|
508
|
+
*
|
|
509
|
+
* With `checkFirstAndLast` on, a last point that repeats the first is dropped too. Points
|
|
510
|
+
* within `tolerance` of each other count as the same.
|
|
511
|
+
* Example: [[0,0,0], [0,0,0], [1,0,0], [1,0,0], [2,0,0]] -> [[0,0,0], [1,0,0], [2,0,0]]
|
|
512
|
+
* @param inputs - The points, the tolerance and whether to compare the first and last
|
|
513
|
+
* @returns The points without consecutive repeats
|
|
325
514
|
* @group clean
|
|
326
515
|
* @shortname remove duplicates
|
|
327
516
|
* @drawable true
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
* const cleaned = bitbybit.point.removeConsecutiveDuplicates({
|
|
520
|
+
* points: [[0, 0, 0], [0, 0, 0], [1, 0, 0]],
|
|
521
|
+
* tolerance: 1e-7,
|
|
522
|
+
* checkFirstAndLast: false,
|
|
523
|
+
* });
|
|
524
|
+
* ```
|
|
328
525
|
*/
|
|
329
526
|
removeConsecutiveDuplicates(inputs: Inputs.Point.RemoveConsecutiveDuplicatesDto): Inputs.Base.Point3[];
|
|
330
527
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
528
|
+
* Finds the direction at right angles to the plane through three points, with length 1.
|
|
529
|
+
*
|
|
530
|
+
* The direction follows the right-hand rule going from the first point to the second to the
|
|
531
|
+
* third; `reverseNormal` flips it. Points on one line have no plane, so the result is
|
|
532
|
+
* undefined.
|
|
533
|
+
* Example: [0,0,0], [1,0,0], [0,1,0] -> [0,0,1]
|
|
534
|
+
* @param inputs - The three points and whether to flip the result
|
|
535
|
+
* @returns The unit normal, or undefined when the points are on one line
|
|
335
536
|
* @group create
|
|
336
537
|
* @shortname normal from 3 points
|
|
337
538
|
* @drawable true
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* const normal = bitbybit.point.normalFromThreePoints({
|
|
542
|
+
* point1: [0, 0, 0],
|
|
543
|
+
* point2: [1, 0, 0],
|
|
544
|
+
* point3: [0, 1, 0],
|
|
545
|
+
* reverseNormal: false,
|
|
546
|
+
* });
|
|
547
|
+
* ```
|
|
338
548
|
*/
|
|
339
549
|
normalFromThreePoints(inputs: Inputs.Point.ThreePointsNormalDto): Inputs.Base.Vector3 | undefined;
|
|
340
550
|
private closestPointFromPointData;
|
|
341
551
|
/**
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* @
|
|
552
|
+
* Tells whether two points are closer together than a tolerance.
|
|
553
|
+
*
|
|
554
|
+
* Example: [1.0000001, 2, 3] and [1, 2, 3] with tolerance 1e-6 -> true
|
|
555
|
+
* @param inputs - The two points and the tolerance
|
|
556
|
+
* @returns True when the distance between them is below the tolerance
|
|
346
557
|
* @group measure
|
|
347
558
|
* @shortname two points almost equal
|
|
348
559
|
* @drawable false
|
|
560
|
+
* @example
|
|
561
|
+
* ```typescript
|
|
562
|
+
* const same = bitbybit.point.twoPointsAlmostEqual({ point1: [1, 2, 3], point2: [1, 2, 3.0000001], tolerance: 1e-6 });
|
|
563
|
+
* ```
|
|
349
564
|
*/
|
|
350
565
|
twoPointsAlmostEqual(inputs: Inputs.Point.TwoPointsToleranceDto): boolean;
|
|
351
566
|
/**
|
|
352
|
-
* Sorts points
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* @
|
|
567
|
+
* Sorts points by X, then by Y for equal X, then by Z.
|
|
568
|
+
*
|
|
569
|
+
* Example: [[5,0,0], [1,0,0], [3,0,0]] -> [[1,0,0], [3,0,0], [5,0,0]]
|
|
570
|
+
* @param inputs - The points to sort
|
|
571
|
+
* @returns A sorted copy of the points
|
|
356
572
|
* @group sort
|
|
357
573
|
* @shortname sort points
|
|
358
574
|
* @drawable true
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* const sorted = bitbybit.point.sortPoints({ points: [[5, 0, 0], [1, 0, 0], [3, 0, 0]] });
|
|
578
|
+
* ```
|
|
359
579
|
*/
|
|
360
580
|
sortPoints(inputs: Inputs.Point.PointsDto): Inputs.Base.Point3[];
|
|
361
581
|
/**
|