@bitbybit-dev/base 0.20.13 → 0.21.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 (38) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/lists-inputs.d.ts +39 -0
  3. package/lib/api/inputs/lists-inputs.js +43 -0
  4. package/lib/api/inputs/math-inputs.d.ts +154 -0
  5. package/lib/api/inputs/math-inputs.js +217 -0
  6. package/lib/api/inputs/text-inputs.d.ts +139 -0
  7. package/lib/api/inputs/text-inputs.js +215 -0
  8. package/lib/api/inputs/vector-inputs.d.ts +8 -0
  9. package/lib/api/inputs/vector-inputs.js +8 -0
  10. package/lib/api/services/color.d.ts +27 -12
  11. package/lib/api/services/color.js +27 -12
  12. package/lib/api/services/dates.d.ts +62 -30
  13. package/lib/api/services/dates.js +62 -30
  14. package/lib/api/services/geometry-helper.d.ts +50 -0
  15. package/lib/api/services/geometry-helper.js +50 -2
  16. package/lib/api/services/helpers/dxf/dxf.d.ts +19 -9
  17. package/lib/api/services/helpers/dxf/dxf.js +19 -9
  18. package/lib/api/services/line.d.ts +34 -16
  19. package/lib/api/services/line.js +34 -16
  20. package/lib/api/services/lists.d.ts +175 -32
  21. package/lib/api/services/lists.js +275 -32
  22. package/lib/api/services/logic.d.ts +24 -13
  23. package/lib/api/services/logic.js +24 -13
  24. package/lib/api/services/math.d.ts +180 -35
  25. package/lib/api/services/math.js +215 -35
  26. package/lib/api/services/mesh.d.ts +17 -6
  27. package/lib/api/services/mesh.js +17 -6
  28. package/lib/api/services/point.d.ts +63 -32
  29. package/lib/api/services/point.js +63 -32
  30. package/lib/api/services/polyline.d.ts +27 -11
  31. package/lib/api/services/polyline.js +27 -11
  32. package/lib/api/services/text.d.ts +286 -7
  33. package/lib/api/services/text.js +350 -7
  34. package/lib/api/services/transforms.d.ts +30 -16
  35. package/lib/api/services/transforms.js +30 -16
  36. package/lib/api/services/vector.d.ts +85 -38
  37. package/lib/api/services/vector.js +87 -38
  38. package/package.json +1 -1
@@ -16,7 +16,8 @@ export declare class Point {
16
16
  private readonly lists;
17
17
  constructor(geometryHelper: GeometryHelper, transforms: Transforms, vector: Vector, lists: Lists);
18
18
  /**
19
- * Transforms the single point
19
+ * Applies transformation matrix to a single point (rotates, scales, or translates).
20
+ * Example: point=[0,0,0] with translation [5,5,0] → [5,5,0]
20
21
  * @param inputs Contains a point and the transformations to apply
21
22
  * @returns Transformed point
22
23
  * @group transforms
@@ -25,7 +26,8 @@ export declare class Point {
25
26
  */
26
27
  transformPoint(inputs: Inputs.Point.TransformPointDto): Inputs.Base.Point3;
27
28
  /**
28
- * Transforms multiple points
29
+ * Applies same transformation matrix to multiple points (batch transform).
30
+ * Example: 5 points with rotation 90° → all 5 points rotated together
29
31
  * @param inputs Contains points and the transformations to apply
30
32
  * @returns Transformed points
31
33
  * @group transforms
@@ -34,7 +36,9 @@ export declare class Point {
34
36
  */
35
37
  transformPoints(inputs: Inputs.Point.TransformPointsDto): Inputs.Base.Point3[];
36
38
  /**
37
- * Transforms multiple points by multiple transformations
39
+ * Applies different transformation matrices to corresponding points (one transform per point).
40
+ * Arrays must have equal length.
41
+ * Example: 3 points with 3 different translations → each point moved independently
38
42
  * @param inputs Contains points and the transformations to apply
39
43
  * @returns Transformed points
40
44
  * @group transforms
@@ -43,7 +47,8 @@ export declare class Point {
43
47
  */
44
48
  transformsForPoints(inputs: Inputs.Point.TransformsForPointsDto): Inputs.Base.Point3[];
45
49
  /**
46
- * Translate multiple points
50
+ * Moves multiple points by a translation vector (same offset for all points).
51
+ * Example: points=[[0,0,0], [1,0,0]], translation=[5,5,0] → [[5,5,0], [6,5,0]]
47
52
  * @param inputs Contains points and the translation vector
48
53
  * @returns Translated points
49
54
  * @group transforms
@@ -52,7 +57,9 @@ export declare class Point {
52
57
  */
53
58
  translatePoints(inputs: Inputs.Point.TranslatePointsDto): Inputs.Base.Point3[];
54
59
  /**
55
- * Translate multiple points
60
+ * Moves multiple points by corresponding translation vectors (one vector per point).
61
+ * Arrays must have equal length.
62
+ * Example: 3 points with 3 different vectors → each point moved by its corresponding vector
56
63
  * @param inputs Contains points and the translation vector
57
64
  * @returns Translated points
58
65
  * @group transforms
@@ -61,7 +68,8 @@ export declare class Point {
61
68
  */
62
69
  translatePointsWithVectors(inputs: Inputs.Point.TranslatePointsWithVectorsDto): Inputs.Base.Point3[];
63
70
  /**
64
- * Translate multiple points by x, y, z values provided
71
+ * Moves multiple points by separate X, Y, Z values (convenience method for translation).
72
+ * Example: points=[[0,0,0]], x=10, y=5, z=0 → [[10,5,0]]
65
73
  * @param inputs Contains points and the translation in x y and z
66
74
  * @returns Translated points
67
75
  * @group transforms
@@ -70,7 +78,8 @@ export declare class Point {
70
78
  */
71
79
  translateXYZPoints(inputs: Inputs.Point.TranslateXYZPointsDto): Inputs.Base.Point3[];
72
80
  /**
73
- * Scale multiple points by providing center point and x, y, z scale factors
81
+ * Scales multiple points around a center point with different factors per axis.
82
+ * Example: points=[[10,0,0]], center=[5,0,0], scaleXyz=[2,1,1] → [[15,0,0]] (doubles X distance from center)
74
83
  * @param inputs Contains points, center point and scale factors
75
84
  * @returns Scaled points
76
85
  * @group transforms
@@ -79,7 +88,8 @@ export declare class Point {
79
88
  */
80
89
  scalePointsCenterXYZ(inputs: Inputs.Point.ScalePointsCenterXYZDto): Inputs.Base.Point3[];
81
90
  /**
82
- * Stretch multiple points by providing center point, direction and uniform scale factor
91
+ * Stretches multiple points along a direction from a center point (directional scaling).
92
+ * Example: points=[[10,0,0]], center=[0,0,0], direction=[1,0,0], scale=2 → [[20,0,0]]
83
93
  * @param inputs Contains points, center point, direction and scale factor
84
94
  * @returns Stretched points
85
95
  * @group transforms
@@ -88,7 +98,8 @@ export declare class Point {
88
98
  */
89
99
  stretchPointsDirFromCenter(inputs: Inputs.Point.StretchPointsDirFromCenterDto): Inputs.Base.Point3[];
90
100
  /**
91
- * Rotate multiple points by providing center point, axis and degrees of rotation
101
+ * Rotates multiple points around a center point along a custom axis.
102
+ * Example: points=[[10,0,0]], center=[0,0,0], axis=[0,1,0], angle=90° → [[0,0,-10]]
92
103
  * @param inputs Contains points, axis, center point and angle of rotation
93
104
  * @returns Rotated points
94
105
  * @group transforms
@@ -97,7 +108,8 @@ export declare class Point {
97
108
  */
98
109
  rotatePointsCenterAxis(inputs: Inputs.Point.RotatePointsCenterAxisDto): Inputs.Base.Point3[];
99
110
  /**
100
- * Gets a bounding box of the points
111
+ * Calculates axis-aligned bounding box containing all points (min, max, center, width, height, length).
112
+ * Example: points=[[0,0,0], [10,5,3]] → {min:[0,0,0], max:[10,5,3], center:[5,2.5,1.5], width:10, height:5, length:3}
101
113
  * @param inputs Points
102
114
  * @returns Bounding box of points
103
115
  * @group extract
@@ -106,7 +118,8 @@ export declare class Point {
106
118
  */
107
119
  boundingBoxOfPoints(inputs: Inputs.Point.PointsDto): Inputs.Base.BoundingBox;
108
120
  /**
109
- * Measures the closest distance between a point and a collection of points
121
+ * Calculates distance to the nearest point in a collection.
122
+ * Example: point=[0,0,0], points=[[5,0,0], [10,0,0], [3,0,0]] → 3 (distance to [3,0,0])
110
123
  * @param inputs Point from which to measure and points to measure the distance against
111
124
  * @returns Distance to closest point
112
125
  * @group extract
@@ -115,7 +128,8 @@ export declare class Point {
115
128
  */
116
129
  closestPointFromPointsDistance(inputs: Inputs.Point.ClosestPointFromPointsDto): number;
117
130
  /**
118
- * Finds the closest point index between a point and a collection of points. Caution, index is not 0 based, it starts with 1.
131
+ * Finds array index of the nearest point in a collection (1-based index, not 0-based).
132
+ * Example: point=[0,0,0], points=[[5,0,0], [10,0,0], [3,0,0]] → 3 (index of [3,0,0])
119
133
  * @param inputs Point from which to find the index in a collection of points
120
134
  * @returns Closest point index
121
135
  * @group extract
@@ -124,7 +138,8 @@ export declare class Point {
124
138
  */
125
139
  closestPointFromPointsIndex(inputs: Inputs.Point.ClosestPointFromPointsDto): number;
126
140
  /**
127
- * Finds the closest point in a collection
141
+ * Finds the nearest point in a collection to a reference point.
142
+ * Example: point=[0,0,0], points=[[5,0,0], [10,0,0], [3,0,0]] → [3,0,0]
128
143
  * @param inputs Point and points collection to find the closest point in
129
144
  * @returns Closest point
130
145
  * @group extract
@@ -133,7 +148,8 @@ export declare class Point {
133
148
  */
134
149
  closestPointFromPoints(inputs: Inputs.Point.ClosestPointFromPointsDto): Inputs.Base.Point3;
135
150
  /**
136
- * Finds the distance between two points
151
+ * Calculates Euclidean distance between two points.
152
+ * Example: start=[0,0,0], end=[3,4,0] → 5 (using Pythagorean theorem: √(3²+4²))
137
153
  * @param inputs Coordinates of start and end points
138
154
  * @returns Distance
139
155
  * @group measure
@@ -142,7 +158,8 @@ export declare class Point {
142
158
  */
143
159
  distance(inputs: Inputs.Point.StartEndPointsDto): number;
144
160
  /**
145
- * Finds the distances between the start point and multiple end points
161
+ * Calculates distances from a start point to multiple end points.
162
+ * Example: start=[0,0,0], endPoints=[[3,0,0], [0,4,0], [5,0,0]] → [3, 4, 5]
146
163
  * @param inputs Coordinates of start and end points
147
164
  * @returns Distances
148
165
  * @group measure
@@ -151,7 +168,8 @@ export declare class Point {
151
168
  */
152
169
  distancesToPoints(inputs: Inputs.Point.StartEndPointsListDto): number[];
153
170
  /**
154
- * Multiply point by a specified amount
171
+ * Duplicates a point N times (creates array with N copies of the same point).
172
+ * Example: point=[5,5,0], amountOfPoints=3 → [[5,5,0], [5,5,0], [5,5,0]]
155
173
  * @param inputs The point to be multiplied and the amount of points to create
156
174
  * @returns Distance
157
175
  * @group transforms
@@ -160,7 +178,8 @@ export declare class Point {
160
178
  */
161
179
  multiplyPoint(inputs: Inputs.Point.MultiplyPointDto): Inputs.Base.Point3[];
162
180
  /**
163
- * Get x coordinate of the point
181
+ * Extracts X coordinate from a point.
182
+ * Example: point=[5,10,3] → 5
164
183
  * @param inputs The point
165
184
  * @returns X coordinate
166
185
  * @group get
@@ -169,7 +188,8 @@ export declare class Point {
169
188
  */
170
189
  getX(inputs: Inputs.Point.PointDto): number;
171
190
  /**
172
- * Get y coordinate of the point
191
+ * Extracts Y coordinate from a point.
192
+ * Example: point=[5,10,3] → 10
173
193
  * @param inputs The point
174
194
  * @returns Y coordinate
175
195
  * @group get
@@ -178,7 +198,8 @@ export declare class Point {
178
198
  */
179
199
  getY(inputs: Inputs.Point.PointDto): number;
180
200
  /**
181
- * Get z coordinate of the point
201
+ * Extracts Z coordinate from a point.
202
+ * Example: point=[5,10,3] → 3
182
203
  * @param inputs The point
183
204
  * @returns Z coordinate
184
205
  * @group get
@@ -187,7 +208,8 @@ export declare class Point {
187
208
  */
188
209
  getZ(inputs: Inputs.Point.PointDto): number;
189
210
  /**
190
- * Get average point of points
211
+ * Calculates centroid (average position) of multiple points.
212
+ * Example: points=[[0,0,0], [10,0,0], [10,10,0]] → [6.67,3.33,0]
191
213
  * @param inputs The points
192
214
  * @returns point
193
215
  * @group extract
@@ -196,7 +218,8 @@ export declare class Point {
196
218
  */
197
219
  averagePoint(inputs: Inputs.Point.PointsDto): Inputs.Base.Point3;
198
220
  /**
199
- * Creates the xyz point
221
+ * Creates a 3D point from X, Y, Z coordinates.
222
+ * Example: x=10, y=5, z=3 → [10,5,3]
200
223
  * @param inputs xyz information
201
224
  * @returns point 3d
202
225
  * @group create
@@ -205,7 +228,8 @@ export declare class Point {
205
228
  */
206
229
  pointXYZ(inputs: Inputs.Point.PointXYZDto): Inputs.Base.Point3;
207
230
  /**
208
- * Creates the xy point
231
+ * Creates a 2D point from X, Y coordinates.
232
+ * Example: x=10, y=5 → [10,5]
209
233
  * @param inputs xy information
210
234
  * @returns point 3d
211
235
  * @group create
@@ -214,7 +238,9 @@ export declare class Point {
214
238
  */
215
239
  pointXY(inputs: Inputs.Point.PointXYDto): Inputs.Base.Point2;
216
240
  /**
217
- * Creates the spiral out of multiple points
241
+ * Creates logarithmic spiral points using golden angle or custom widening factor.
242
+ * Generates natural spiral patterns common in nature (sunflower, nautilus shell).
243
+ * Example: numberPoints=100, radius=10, phi=1.618 → 100 points forming outward spiral
218
244
  * @param inputs Spiral information
219
245
  * @returns Specified number of points in the array along the spiral
220
246
  * @group create
@@ -223,8 +249,9 @@ export declare class Point {
223
249
  */
224
250
  spiral(inputs: Inputs.Point.SpiralDto): Inputs.Base.Point3[];
225
251
  /**
226
- * Creates a flat point grid on XY plane. This grid contains center points for hexagons of the given radius.
227
- * Be aware that we control only the nr of hexagons to be made and not the length and width of the grid.
252
+ * Creates hexagonal grid center points on XY plane (honeycomb pattern).
253
+ * Grid size controlled by number of hexagons, not width/height.
254
+ * Example: radiusHexagon=1, nrHexagonsX=3, nrHexagonsY=3 → 9 hex centers in grid pattern
228
255
  * @param inputs Information about hexagon and the grid
229
256
  * @returns Points in the array on the grid
230
257
  * @group create
@@ -233,9 +260,9 @@ export declare class Point {
233
260
  */
234
261
  hexGrid(inputs: Inputs.Point.HexGridCentersDto): Inputs.Base.Point3[];
235
262
  /**
236
- * Creates a pointy-top or flat-top hexagon grid, scaling hexagons to fit specified dimensions exactly.
237
- * Returns both center points and the vertices of each (potentially scaled) hexagon.
238
- * Hexagons are ordered column-first, then row-first.
263
+ * Creates hexagonal grid scaled to fit within specified width/height bounds (auto-calculates hex size).
264
+ * Returns center points and hex vertices. Supports pointy-top or flat-top orientation.
265
+ * Example: width=10, height=10, nrHexagonsInHeight=3 → hex grid filling 10×10 area with 3 rows
239
266
  * @param inputs Information about the desired grid dimensions and hexagon counts.
240
267
  * @returns An object containing the array of center points and an array of hexagon vertex arrays.
241
268
  * @group create
@@ -291,7 +318,8 @@ export declare class Point {
291
318
  */
292
319
  safestPointsMaxFilletHalfLine(inputs: Inputs.Point.PointsMaxFilletsHalfLineDto): number;
293
320
  /**
294
- * Removes consecutive duplicates from the point array with tolerance
321
+ * Removes consecutive duplicate points from array within tolerance.
322
+ * 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]]
295
323
  * @param inputs points, tolerance and check first and last
296
324
  * @returns Points in the array without consecutive duplicates
297
325
  * @group clean
@@ -300,7 +328,8 @@ export declare class Point {
300
328
  */
301
329
  removeConsecutiveDuplicates(inputs: Inputs.Point.RemoveConsecutiveDuplicatesDto): Inputs.Base.Point3[];
302
330
  /**
303
- * Creates a normal vector from 3 points
331
+ * Calculates normal vector from three points using cross product (perpendicular to plane).
332
+ * Example: p1=[0,0,0], p2=[1,0,0], p3=[0,1,0] → [0,0,1] (pointing up from XY plane)
304
333
  * @param inputs Three points and the reverse normal flag
305
334
  * @returns Normal vector
306
335
  * @group create
@@ -310,7 +339,8 @@ export declare class Point {
310
339
  normalFromThreePoints(inputs: Inputs.Point.ThreePointsNormalDto): Inputs.Base.Vector3;
311
340
  private closestPointFromPointData;
312
341
  /**
313
- * Checks if two points are almost equal
342
+ * Checks if two points are approximately equal within tolerance (distance-based comparison).
343
+ * Example: point1=[1.0000001, 2.0, 3.0], point2=[1.0, 2.0, 3.0], tolerance=1e-6 → true
314
344
  * @param inputs Two points and the tolerance
315
345
  * @returns true if the points are almost equal
316
346
  * @group measure
@@ -319,7 +349,8 @@ export declare class Point {
319
349
  */
320
350
  twoPointsAlmostEqual(inputs: Inputs.Point.TwoPointsToleranceDto): boolean;
321
351
  /**
322
- * Sorts points lexicographically (X, then Y, then Z)
352
+ * Sorts points lexicographically (by X, then Y, then Z coordinates).
353
+ * Example: [[5,0,0], [1,0,0], [3,0,0]] → [[1,0,0], [3,0,0], [5,0,0]]
323
354
  * @param inputs points
324
355
  * @returns sorted points
325
356
  * @group sort
@@ -11,7 +11,8 @@ export class Point {
11
11
  this.lists = lists;
12
12
  }
13
13
  /**
14
- * Transforms the single point
14
+ * Applies transformation matrix to a single point (rotates, scales, or translates).
15
+ * Example: point=[0,0,0] with translation [5,5,0] → [5,5,0]
15
16
  * @param inputs Contains a point and the transformations to apply
16
17
  * @returns Transformed point
17
18
  * @group transforms
@@ -25,7 +26,8 @@ export class Point {
25
26
  return transformedControlPoints[0];
26
27
  }
27
28
  /**
28
- * Transforms multiple points
29
+ * Applies same transformation matrix to multiple points (batch transform).
30
+ * Example: 5 points with rotation 90° → all 5 points rotated together
29
31
  * @param inputs Contains points and the transformations to apply
30
32
  * @returns Transformed points
31
33
  * @group transforms
@@ -36,7 +38,9 @@ export class Point {
36
38
  return this.geometryHelper.transformControlPoints(inputs.transformation, inputs.points);
37
39
  }
38
40
  /**
39
- * Transforms multiple points by multiple transformations
41
+ * Applies different transformation matrices to corresponding points (one transform per point).
42
+ * Arrays must have equal length.
43
+ * Example: 3 points with 3 different translations → each point moved independently
40
44
  * @param inputs Contains points and the transformations to apply
41
45
  * @returns Transformed points
42
46
  * @group transforms
@@ -52,7 +56,8 @@ export class Point {
52
56
  });
53
57
  }
54
58
  /**
55
- * Translate multiple points
59
+ * Moves multiple points by a translation vector (same offset for all points).
60
+ * Example: points=[[0,0,0], [1,0,0]], translation=[5,5,0] → [[5,5,0], [6,5,0]]
56
61
  * @param inputs Contains points and the translation vector
57
62
  * @returns Translated points
58
63
  * @group transforms
@@ -64,7 +69,9 @@ export class Point {
64
69
  return this.geometryHelper.transformControlPoints(translationTransform, inputs.points);
65
70
  }
66
71
  /**
67
- * Translate multiple points
72
+ * Moves multiple points by corresponding translation vectors (one vector per point).
73
+ * Arrays must have equal length.
74
+ * Example: 3 points with 3 different vectors → each point moved by its corresponding vector
68
75
  * @param inputs Contains points and the translation vector
69
76
  * @returns Translated points
70
77
  * @group transforms
@@ -81,7 +88,8 @@ export class Point {
81
88
  });
82
89
  }
83
90
  /**
84
- * Translate multiple points by x, y, z values provided
91
+ * Moves multiple points by separate X, Y, Z values (convenience method for translation).
92
+ * Example: points=[[0,0,0]], x=10, y=5, z=0 → [[10,5,0]]
85
93
  * @param inputs Contains points and the translation in x y and z
86
94
  * @returns Translated points
87
95
  * @group transforms
@@ -93,7 +101,8 @@ export class Point {
93
101
  return this.geometryHelper.transformControlPoints(translationTransform, inputs.points);
94
102
  }
95
103
  /**
96
- * Scale multiple points by providing center point and x, y, z scale factors
104
+ * Scales multiple points around a center point with different factors per axis.
105
+ * Example: points=[[10,0,0]], center=[5,0,0], scaleXyz=[2,1,1] → [[15,0,0]] (doubles X distance from center)
97
106
  * @param inputs Contains points, center point and scale factors
98
107
  * @returns Scaled points
99
108
  * @group transforms
@@ -105,7 +114,8 @@ export class Point {
105
114
  return this.geometryHelper.transformControlPoints(scaleTransforms, inputs.points);
106
115
  }
107
116
  /**
108
- * Stretch multiple points by providing center point, direction and uniform scale factor
117
+ * Stretches multiple points along a direction from a center point (directional scaling).
118
+ * Example: points=[[10,0,0]], center=[0,0,0], direction=[1,0,0], scale=2 → [[20,0,0]]
109
119
  * @param inputs Contains points, center point, direction and scale factor
110
120
  * @returns Stretched points
111
121
  * @group transforms
@@ -117,7 +127,8 @@ export class Point {
117
127
  return this.geometryHelper.transformControlPoints(stretchTransforms, inputs.points);
118
128
  }
119
129
  /**
120
- * Rotate multiple points by providing center point, axis and degrees of rotation
130
+ * Rotates multiple points around a center point along a custom axis.
131
+ * Example: points=[[10,0,0]], center=[0,0,0], axis=[0,1,0], angle=90° → [[0,0,-10]]
121
132
  * @param inputs Contains points, axis, center point and angle of rotation
122
133
  * @returns Rotated points
123
134
  * @group transforms
@@ -129,7 +140,8 @@ export class Point {
129
140
  return this.geometryHelper.transformControlPoints(rotationTransforms, inputs.points);
130
141
  }
131
142
  /**
132
- * Gets a bounding box of the points
143
+ * Calculates axis-aligned bounding box containing all points (min, max, center, width, height, length).
144
+ * Example: points=[[0,0,0], [10,5,3]] → {min:[0,0,0], max:[10,5,3], center:[5,2.5,1.5], width:10, height:5, length:3}
133
145
  * @param inputs Points
134
146
  * @returns Bounding box of points
135
147
  * @group extract
@@ -165,7 +177,8 @@ export class Point {
165
177
  };
166
178
  }
167
179
  /**
168
- * Measures the closest distance between a point and a collection of points
180
+ * Calculates distance to the nearest point in a collection.
181
+ * Example: point=[0,0,0], points=[[5,0,0], [10,0,0], [3,0,0]] → 3 (distance to [3,0,0])
169
182
  * @param inputs Point from which to measure and points to measure the distance against
170
183
  * @returns Distance to closest point
171
184
  * @group extract
@@ -176,7 +189,8 @@ export class Point {
176
189
  return this.closestPointFromPointData(inputs).distance;
177
190
  }
178
191
  /**
179
- * Finds the closest point index between a point and a collection of points. Caution, index is not 0 based, it starts with 1.
192
+ * Finds array index of the nearest point in a collection (1-based index, not 0-based).
193
+ * Example: point=[0,0,0], points=[[5,0,0], [10,0,0], [3,0,0]] → 3 (index of [3,0,0])
180
194
  * @param inputs Point from which to find the index in a collection of points
181
195
  * @returns Closest point index
182
196
  * @group extract
@@ -187,7 +201,8 @@ export class Point {
187
201
  return this.closestPointFromPointData(inputs).index;
188
202
  }
189
203
  /**
190
- * Finds the closest point in a collection
204
+ * Finds the nearest point in a collection to a reference point.
205
+ * Example: point=[0,0,0], points=[[5,0,0], [10,0,0], [3,0,0]] → [3,0,0]
191
206
  * @param inputs Point and points collection to find the closest point in
192
207
  * @returns Closest point
193
208
  * @group extract
@@ -198,7 +213,8 @@ export class Point {
198
213
  return this.closestPointFromPointData(inputs).point;
199
214
  }
200
215
  /**
201
- * Finds the distance between two points
216
+ * Calculates Euclidean distance between two points.
217
+ * Example: start=[0,0,0], end=[3,4,0] → 5 (using Pythagorean theorem: √(3²+4²))
202
218
  * @param inputs Coordinates of start and end points
203
219
  * @returns Distance
204
220
  * @group measure
@@ -212,7 +228,8 @@ export class Point {
212
228
  return Math.sqrt(x * x + y * y + z * z);
213
229
  }
214
230
  /**
215
- * Finds the distances between the start point and multiple end points
231
+ * Calculates distances from a start point to multiple end points.
232
+ * Example: start=[0,0,0], endPoints=[[3,0,0], [0,4,0], [5,0,0]] → [3, 4, 5]
216
233
  * @param inputs Coordinates of start and end points
217
234
  * @returns Distances
218
235
  * @group measure
@@ -225,7 +242,8 @@ export class Point {
225
242
  });
226
243
  }
227
244
  /**
228
- * Multiply point by a specified amount
245
+ * Duplicates a point N times (creates array with N copies of the same point).
246
+ * Example: point=[5,5,0], amountOfPoints=3 → [[5,5,0], [5,5,0], [5,5,0]]
229
247
  * @param inputs The point to be multiplied and the amount of points to create
230
248
  * @returns Distance
231
249
  * @group transforms
@@ -240,7 +258,8 @@ export class Point {
240
258
  return points;
241
259
  }
242
260
  /**
243
- * Get x coordinate of the point
261
+ * Extracts X coordinate from a point.
262
+ * Example: point=[5,10,3] → 5
244
263
  * @param inputs The point
245
264
  * @returns X coordinate
246
265
  * @group get
@@ -251,7 +270,8 @@ export class Point {
251
270
  return inputs.point[0];
252
271
  }
253
272
  /**
254
- * Get y coordinate of the point
273
+ * Extracts Y coordinate from a point.
274
+ * Example: point=[5,10,3] → 10
255
275
  * @param inputs The point
256
276
  * @returns Y coordinate
257
277
  * @group get
@@ -262,7 +282,8 @@ export class Point {
262
282
  return inputs.point[1];
263
283
  }
264
284
  /**
265
- * Get z coordinate of the point
285
+ * Extracts Z coordinate from a point.
286
+ * Example: point=[5,10,3] → 3
266
287
  * @param inputs The point
267
288
  * @returns Z coordinate
268
289
  * @group get
@@ -273,7 +294,8 @@ export class Point {
273
294
  return inputs.point[2];
274
295
  }
275
296
  /**
276
- * Get average point of points
297
+ * Calculates centroid (average position) of multiple points.
298
+ * Example: points=[[0,0,0], [10,0,0], [10,10,0]] → [6.67,3.33,0]
277
299
  * @param inputs The points
278
300
  * @returns point
279
301
  * @group extract
@@ -296,7 +318,8 @@ export class Point {
296
318
  ];
297
319
  }
298
320
  /**
299
- * Creates the xyz point
321
+ * Creates a 3D point from X, Y, Z coordinates.
322
+ * Example: x=10, y=5, z=3 → [10,5,3]
300
323
  * @param inputs xyz information
301
324
  * @returns point 3d
302
325
  * @group create
@@ -307,7 +330,8 @@ export class Point {
307
330
  return [inputs.x, inputs.y, inputs.z];
308
331
  }
309
332
  /**
310
- * Creates the xy point
333
+ * Creates a 2D point from X, Y coordinates.
334
+ * Example: x=10, y=5 → [10,5]
311
335
  * @param inputs xy information
312
336
  * @returns point 3d
313
337
  * @group create
@@ -318,7 +342,9 @@ export class Point {
318
342
  return [inputs.x, inputs.y];
319
343
  }
320
344
  /**
321
- * Creates the spiral out of multiple points
345
+ * Creates logarithmic spiral points using golden angle or custom widening factor.
346
+ * Generates natural spiral patterns common in nature (sunflower, nautilus shell).
347
+ * Example: numberPoints=100, radius=10, phi=1.618 → 100 points forming outward spiral
322
348
  * @param inputs Spiral information
323
349
  * @returns Specified number of points in the array along the spiral
324
350
  * @group create
@@ -339,8 +365,9 @@ export class Point {
339
365
  return spiral;
340
366
  }
341
367
  /**
342
- * Creates a flat point grid on XY plane. This grid contains center points for hexagons of the given radius.
343
- * Be aware that we control only the nr of hexagons to be made and not the length and width of the grid.
368
+ * Creates hexagonal grid center points on XY plane (honeycomb pattern).
369
+ * Grid size controlled by number of hexagons, not width/height.
370
+ * Example: radiusHexagon=1, nrHexagonsX=3, nrHexagonsY=3 → 9 hex centers in grid pattern
344
371
  * @param inputs Information about hexagon and the grid
345
372
  * @returns Points in the array on the grid
346
373
  * @group create
@@ -373,9 +400,9 @@ export class Point {
373
400
  return points;
374
401
  }
375
402
  /**
376
- * Creates a pointy-top or flat-top hexagon grid, scaling hexagons to fit specified dimensions exactly.
377
- * Returns both center points and the vertices of each (potentially scaled) hexagon.
378
- * Hexagons are ordered column-first, then row-first.
403
+ * Creates hexagonal grid scaled to fit within specified width/height bounds (auto-calculates hex size).
404
+ * Returns center points and hex vertices. Supports pointy-top or flat-top orientation.
405
+ * Example: width=10, height=10, nrHexagonsInHeight=3 → hex grid filling 10×10 area with 3 rows
379
406
  * @param inputs Information about the desired grid dimensions and hexagon counts.
380
407
  * @returns An object containing the array of center points and an array of hexagon vertex arrays.
381
408
  * @group create
@@ -846,7 +873,8 @@ export class Point {
846
873
  return Math.max(0, safestRadius);
847
874
  }
848
875
  /**
849
- * Removes consecutive duplicates from the point array with tolerance
876
+ * Removes consecutive duplicate points from array within tolerance.
877
+ * 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]]
850
878
  * @param inputs points, tolerance and check first and last
851
879
  * @returns Points in the array without consecutive duplicates
852
880
  * @group clean
@@ -857,7 +885,8 @@ export class Point {
857
885
  return this.geometryHelper.removeConsecutivePointDuplicates(inputs.points, inputs.checkFirstAndLast, inputs.tolerance);
858
886
  }
859
887
  /**
860
- * Creates a normal vector from 3 points
888
+ * Calculates normal vector from three points using cross product (perpendicular to plane).
889
+ * Example: p1=[0,0,0], p2=[1,0,0], p3=[0,1,0] → [0,0,1] (pointing up from XY plane)
861
890
  * @param inputs Three points and the reverse normal flag
862
891
  * @returns Normal vector
863
892
  * @group create
@@ -913,7 +942,8 @@ export class Point {
913
942
  return { index: closestPointIndex + 1, distance, point };
914
943
  }
915
944
  /**
916
- * Checks if two points are almost equal
945
+ * Checks if two points are approximately equal within tolerance (distance-based comparison).
946
+ * Example: point1=[1.0000001, 2.0, 3.0], point2=[1.0, 2.0, 3.0], tolerance=1e-6 → true
917
947
  * @param inputs Two points and the tolerance
918
948
  * @returns true if the points are almost equal
919
949
  * @group measure
@@ -927,7 +957,8 @@ export class Point {
927
957
  return dist < inputs.tolerance;
928
958
  }
929
959
  /**
930
- * Sorts points lexicographically (X, then Y, then Z)
960
+ * Sorts points lexicographically (by X, then Y, then Z coordinates).
961
+ * Example: [[5,0,0], [1,0,0], [3,0,0]] → [[1,0,0], [3,0,0], [5,0,0]]
931
962
  * @param inputs points
932
963
  * @returns sorted points
933
964
  * @group sort