@bitbybit-dev/base 1.2.0-rc.2 → 1.3.0-rc.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 (55) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +13 -12
  3. package/lib/api/inputs/color-inputs.d.ts +97 -48
  4. package/lib/api/inputs/color-inputs.js +95 -46
  5. package/lib/api/inputs/dates-inputs.d.ts +67 -26
  6. package/lib/api/inputs/dates-inputs.js +57 -16
  7. package/lib/api/inputs/io-inputs.d.ts +13 -15
  8. package/lib/api/inputs/io-inputs.js +7 -8
  9. package/lib/api/inputs/line-inputs.d.ts +88 -33
  10. package/lib/api/inputs/line-inputs.js +61 -11
  11. package/lib/api/inputs/lists-inputs.d.ts +207 -96
  12. package/lib/api/inputs/lists-inputs.js +153 -45
  13. package/lib/api/inputs/logic-inputs.d.ts +52 -22
  14. package/lib/api/inputs/logic-inputs.js +41 -12
  15. package/lib/api/inputs/math-inputs.d.ts +113 -52
  16. package/lib/api/inputs/math-inputs.js +112 -51
  17. package/lib/api/inputs/mesh-inputs.d.ts +30 -11
  18. package/lib/api/inputs/mesh-inputs.js +21 -3
  19. package/lib/api/inputs/point-inputs.d.ts +240 -107
  20. package/lib/api/inputs/point-inputs.js +199 -73
  21. package/lib/api/inputs/polyline-inputs.d.ts +68 -28
  22. package/lib/api/inputs/polyline-inputs.js +48 -13
  23. package/lib/api/inputs/text-inputs.d.ts +117 -46
  24. package/lib/api/inputs/text-inputs.js +111 -41
  25. package/lib/api/inputs/transforms-inputs.d.ts +65 -23
  26. package/lib/api/inputs/transforms-inputs.js +64 -22
  27. package/lib/api/inputs/vector-inputs.d.ts +154 -76
  28. package/lib/api/inputs/vector-inputs.js +132 -57
  29. package/lib/api/models/point/hex-grid-data.d.ts +1 -1
  30. package/lib/api/models/point/hex-grid-data.js +1 -1
  31. package/lib/api/services/color.d.ts +149 -70
  32. package/lib/api/services/color.js +149 -70
  33. package/lib/api/services/dates.d.ts +313 -150
  34. package/lib/api/services/dates.js +313 -150
  35. package/lib/api/services/line.d.ts +138 -68
  36. package/lib/api/services/line.js +138 -68
  37. package/lib/api/services/lists.d.ts +357 -177
  38. package/lib/api/services/lists.js +357 -177
  39. package/lib/api/services/logic.d.ts +98 -45
  40. package/lib/api/services/logic.js +98 -45
  41. package/lib/api/services/math.d.ts +363 -211
  42. package/lib/api/services/math.js +363 -211
  43. package/lib/api/services/mesh.d.ts +73 -31
  44. package/lib/api/services/mesh.js +73 -31
  45. package/lib/api/services/point.d.ts +367 -147
  46. package/lib/api/services/point.js +367 -147
  47. package/lib/api/services/polyline.d.ts +146 -71
  48. package/lib/api/services/polyline.js +146 -71
  49. package/lib/api/services/text.d.ts +320 -165
  50. package/lib/api/services/text.js +320 -165
  51. package/lib/api/services/transforms.d.ts +145 -58
  52. package/lib/api/services/transforms.js +145 -58
  53. package/lib/api/services/vector.d.ts +381 -156
  54. package/lib/api/services/vector.js +381 -156
  55. package/package.json +1 -1
@@ -3,8 +3,10 @@ import * as Inputs from "../inputs";
3
3
  import { Point } from "./point";
4
4
  import { Vector } from "./vector";
5
5
  /**
6
- * Contains various methods for lines and segments. Line in bitbybit is a simple object that has start and
7
- * end point properties. { start: [ x, y, z ], end: [ x, y, z ] }
6
+ * Straight lines between two points, held as plain objects of the form `{ start, end }`, and the
7
+ * segment form `[start, end]` of the same thing. The methods here build lines, measure and
8
+ * transform them, convert between the two forms, place points along them and find where two lines
9
+ * cross. Lengths are in model units.
8
10
  */
9
11
  export declare class Line {
10
12
  private readonly vector;
@@ -12,165 +14,233 @@ export declare class Line {
12
14
  private readonly geometryHelper;
13
15
  constructor(vector: Vector, point: Point, geometryHelper: GeometryHelper);
14
16
  /**
15
- * Extracts start point from a line.
16
- * Example: line={start:[0,0,0], end:[10,5,0]} → [0,0,0]
17
- * @param inputs a line
18
- * @returns start point
17
+ * Reads the start point of a line.
18
+ *
19
+ * Example: { start: [0,0,0], end: [10,5,0] } -> [0,0,0]
20
+ * @param inputs - The line
21
+ * @returns The start point
19
22
  * @group get
20
23
  * @shortname line start point
21
24
  * @drawable true
22
25
  */
23
26
  getStartPoint(inputs: Inputs.Line.LineDto): Inputs.Base.Point3;
24
27
  /**
25
- * Extracts end point from a line.
26
- * Example: line={start:[0,0,0], end:[10,5,0]} → [10,5,0]
27
- * @param inputs a line
28
- * @returns end point
28
+ * Reads the end point of a line.
29
+ *
30
+ * Example: { start: [0,0,0], end: [10,5,0] } -> [10,5,0]
31
+ * @param inputs - The line
32
+ * @returns The end point
29
33
  * @group get
30
34
  * @shortname line end point
31
35
  * @drawable true
32
36
  */
33
37
  getEndPoint(inputs: Inputs.Line.LineDto): Inputs.Base.Point3;
34
38
  /**
35
- * Calculates length (distance) of a line segment.
36
- * Example: line={start:[0,0,0], end:[3,4,0]} → 5 (using Pythagorean theorem)
37
- * @param inputs a line
38
- * @returns line length
39
+ * Measures the straight distance from the start of a line to its end.
40
+ *
41
+ * Example: { start: [0,0,0], end: [3,4,0] } -> 5
42
+ * @param inputs - The line
43
+ * @returns The length in model units
39
44
  * @group get
40
45
  * @shortname line length
41
46
  * @drawable false
42
47
  */
43
48
  length(inputs: Inputs.Line.LineDto): number;
44
49
  /**
45
- * Reverses line direction by swapping start and end points.
46
- * Example: line={start:[0,0,0], end:[10,5,0]} → {start:[10,5,0], end:[0,0,0]}
47
- * @param inputs a line
48
- * @returns reversed line
50
+ * Swaps the start and end of a line, so it runs the other way.
51
+ *
52
+ * Example: { start: [0,0,0], end: [10,5,0] } -> { start: [10,5,0], end: [0,0,0] }
53
+ * @param inputs - The line
54
+ * @returns A new line running the other way
49
55
  * @group operations
50
56
  * @shortname reversed line
51
57
  * @drawable true
52
58
  */
53
59
  reverse(inputs: Inputs.Line.LineDto): Inputs.Base.Line3;
54
60
  /**
55
- * Applies transformation matrix to line (rotates, scales, or translates both endpoints).
56
- * Example: line={start:[0,0,0], end:[10,0,0]} with translation [5,5,0] → {start:[5,5,0], end:[15,5,0]}
57
- * @param inputs a line
58
- * @returns transformed line
61
+ * Applies a transformation matrix, or a list of them in order, to both ends of a line.
62
+ *
63
+ * Example: { start: [0,0,0], end: [10,0,0] } moved by [5,5,0] -> { start: [5,5,0], end:
64
+ * [15,5,0] }
65
+ * @param inputs - The line and the transformation
66
+ * @returns A new line with the transformed ends
59
67
  * @group transforms
60
68
  * @shortname transform line
61
69
  * @drawable true
70
+ * @example
71
+ * ```typescript
72
+ * const moved = bitbybit.line.transformLine({
73
+ * line: { start: [0, 0, 0], end: [10, 0, 0] },
74
+ * transformation: bitbybit.transforms.translationXYZ({ translation: [5, 5, 0] }),
75
+ * });
76
+ * ```
62
77
  */
63
78
  transformLine(inputs: Inputs.Line.TransformLineDto): Inputs.Base.Line3;
64
79
  /**
65
- * Applies multiple transformations to multiple lines (one transform per line).
66
- * Example: 3 lines with 3 different translation matrices → each line moved independently
67
- * @param inputs lines
68
- * @returns transformed lines
80
+ * Applies a different transformation to each line: the first transformation to the first line,
81
+ * and so on.
82
+ *
83
+ * Example: three lines with three translations -> each line moved by its own translation
84
+ * @param inputs - The lines and one transformation per line
85
+ * @returns The transformed lines, in the same order
69
86
  * @group transforms
70
87
  * @shortname transform lines
71
88
  * @drawable true
89
+ * @example
90
+ * ```typescript
91
+ * const placed = bitbybit.line.transformsForLines({
92
+ * lines: [{ start: [0, 0, 0], end: [1, 0, 0] }, { start: [0, 0, 0], end: [0, 1, 0] }],
93
+ * transformation: bitbybit.transforms.translationsXYZ({ translations: [[0, 1, 0], [0, 2, 0]] }),
94
+ * });
95
+ * ```
72
96
  */
73
97
  transformsForLines(inputs: Inputs.Line.TransformsLinesDto): Inputs.Base.Line3[];
74
98
  /**
75
- * Creates a line from two points (line object with start and end properties).
76
- * Example: start=[0,0,0], end=[10,5,0] → {start:[0,0,0], end:[10,5,0]}
77
- * @param inputs start and end points of the line
78
- * @returns line
99
+ * Builds a line object from a start and an end point.
100
+ *
101
+ * Example: start [0,0,0], end [10,5,0] -> { start: [0,0,0], end: [10,5,0] }
102
+ * @param inputs - The start and end points
103
+ * @returns The line object
79
104
  * @group create
80
105
  * @shortname line
81
106
  * @drawable true
107
+ * @example
108
+ * ```typescript
109
+ * const line = bitbybit.line.create({ start: [0, 0, 0], end: [10, 5, 0] });
110
+ * ```
82
111
  */
83
112
  create(inputs: Inputs.Line.LinePointsDto): Inputs.Base.Line3;
84
113
  /**
85
- * Creates a segment from two points (array format: [start, end]).
86
- * Example: start=[0,0,0], end=[10,5,0] → [[0,0,0], [10,5,0]]
87
- * @param inputs start and end points of the segment
88
- * @returns segment
114
+ * Builds a segment, the pair-of-points form of a line, from a start and an end point.
115
+ *
116
+ * Example: start [0,0,0], end [10,5,0] -> [[0,0,0], [10,5,0]]
117
+ * @param inputs - The start and end points
118
+ * @returns The segment as `[start, end]`
89
119
  * @group create
90
120
  * @shortname segment
91
121
  * @drawable true
122
+ * @example
123
+ * ```typescript
124
+ * const segment = bitbybit.line.createSegment({ start: [0, 0, 0], end: [10, 5, 0] });
125
+ * ```
92
126
  */
93
127
  createSegment(inputs: Inputs.Line.LinePointsDto): Inputs.Base.Segment3;
94
128
  /**
95
- * Calculates point at parameter t along line segment (0=start, 1=end, linear interpolation).
96
- * Example: line={start:[0,0,0], end:[10,0,0]}, param=0.5 → [5,0,0] (midpoint)
97
- * @param inputs line
98
- * @returns point on line
129
+ * Finds the point a fraction of the way along a line: 0 gives the start, 1 the end, 0.5 the
130
+ * middle.
131
+ *
132
+ * A fraction outside 0 to 1 continues past the ends.
133
+ * Example: { start: [0,0,0], end: [10,0,0] } at 0.5 -> [5,0,0]
134
+ * @param inputs - The line and the fraction along it
135
+ * @returns The point on the line
99
136
  * @group get
100
137
  * @shortname point on line
101
138
  * @drawable true
139
+ * @example
140
+ * ```typescript
141
+ * const middle = bitbybit.line.getPointOnLine({ line: { start: [0, 0, 0], end: [10, 0, 0] }, param: 0.5 });
142
+ * ```
102
143
  */
103
144
  getPointOnLine(inputs: Inputs.Line.PointOnLineDto): Inputs.Base.Point3;
104
145
  /**
105
- * Creates line segments connecting consecutive points in a list (forms a polyline path).
106
- * Example: points=[[0,0,0], [5,0,0], [5,5,0]] → 2 lines: [0→5] and [5→5,5]
107
- * @param inputs points
108
- * @returns lines
146
+ * Joins each point to the next with a line, so a list of points becomes a chain of lines.
147
+ *
148
+ * Example: [[0,0,0], [5,0,0], [5,5,0]] -> two lines, [0,0,0] to [5,0,0] and [5,0,0] to [5,5,0]
149
+ * @param inputs - The points, in order
150
+ * @returns One line per pair of neighboring points
109
151
  * @group create
110
152
  * @shortname lines between points
111
153
  * @drawable true
154
+ * @example
155
+ * ```typescript
156
+ * const chain = bitbybit.line.linesBetweenPoints({ points: [[0, 0, 0], [5, 0, 0], [5, 5, 0]] });
157
+ * ```
112
158
  */
113
159
  linesBetweenPoints(inputs: Inputs.Line.PointsLinesDto): Inputs.Base.Line3[];
114
160
  /**
115
- * Creates lines by pairing corresponding start and end points from two arrays.
116
- * Filters out zero-length lines.
117
- * Example: starts=[[0,0,0], [5,0,0]], ends=[[0,5,0], [5,5,0]] → 2 lines connecting paired points
118
- * @param inputs start points and end points
119
- * @returns lines
161
+ * Pairs each start point with the end point at the same position and joins them with a line.
162
+ *
163
+ * A pair whose two points coincide makes no line and is left out.
164
+ * Example: starts [[0,0,0], [5,0,0]] and ends [[0,5,0], [5,5,0]] -> two lines
165
+ * @param inputs - The start points and the end points, in matching order
166
+ * @returns One line per pair, skipping pairs of length 0
120
167
  * @group create
121
168
  * @shortname start and end points to lines
122
169
  * @drawable true
170
+ * @example
171
+ * ```typescript
172
+ * const rungs = bitbybit.line.linesBetweenStartAndEndPoints({
173
+ * startPoints: [[0, 0, 0], [5, 0, 0]],
174
+ * endPoints: [[0, 5, 0], [5, 5, 0]],
175
+ * });
176
+ * ```
123
177
  */
124
178
  linesBetweenStartAndEndPoints(inputs: Inputs.Line.LineStartEndPointsDto): Inputs.Base.Line3[];
125
179
  /**
126
- * Converts line object to segment array format.
127
- * Example: {start:[0,0,0], end:[10,5,0]} → [[0,0,0], [10,5,0]]
128
- * @param inputs line
129
- * @returns segment
180
+ * Turns a line object into its segment form, the pair `[start, end]`.
181
+ *
182
+ * Example: { start: [0,0,0], end: [10,5,0] } -> [[0,0,0], [10,5,0]]
183
+ * @param inputs - The line
184
+ * @returns The segment
130
185
  * @group convert
131
186
  * @shortname line to segment
132
187
  * @drawable false
133
188
  */
134
189
  lineToSegment(inputs: Inputs.Line.LineDto): Inputs.Base.Segment3;
135
190
  /**
136
- * Converts multiple line objects to segment array format (batch conversion).
137
- * Example: 3 line objects → 3 segment arrays [[start1, end1], [start2, end2], ...]
138
- * @param inputs lines
139
- * @returns segments
191
+ * Turns each line object into its segment form, the pair `[start, end]`.
192
+ *
193
+ * Example: three lines -> three segments, in the same order
194
+ * @param inputs - The lines
195
+ * @returns One segment per line
140
196
  * @group convert
141
197
  * @shortname lines to segments
142
198
  * @drawable false
143
199
  */
144
200
  linesToSegments(inputs: Inputs.Line.LinesDto): Inputs.Base.Segment3[];
145
201
  /**
146
- * Converts segment array to line object format.
147
- * Example: [[0,0,0], [10,5,0]] → {start:[0,0,0], end:[10,5,0]}
148
- * @param inputs segment
149
- * @returns line
202
+ * Turns a segment, the pair `[start, end]`, into a line object.
203
+ *
204
+ * Example: [[0,0,0], [10,5,0]] -> { start: [0,0,0], end: [10,5,0] }
205
+ * @param inputs - The segment
206
+ * @returns The line
150
207
  * @group convert
151
208
  * @shortname segment to line
152
209
  * @drawable true
153
210
  */
154
211
  segmentToLine(inputs: Inputs.Line.SegmentDto): Inputs.Base.Line3;
155
212
  /**
156
- * Converts multiple segment arrays to line object format (batch conversion).
157
- * Example: 3 segment arrays → 3 line objects with start/end properties
158
- * @param inputs segments
159
- * @returns lines
213
+ * Turns each segment, a pair `[start, end]`, into a line object.
214
+ *
215
+ * Example: three segments -> three lines, in the same order
216
+ * @param inputs - The segments
217
+ * @returns One line per segment
160
218
  * @group convert
161
219
  * @shortname segments to lines
162
220
  * @drawable true
163
221
  */
164
222
  segmentsToLines(inputs: Inputs.Line.SegmentsDto): Inputs.Base.Line3[];
165
223
  /**
166
- * Calculates intersection point of two lines (or segments if checkSegmentsOnly=true).
167
- * Returns undefined if lines are parallel, skew, or segments don't overlap.
168
- * Example: line1={start:[0,0,0], end:[10,0,0]}, line2={start:[5,-5,0], end:[5,5,0]} → [5,0,0]
169
- * @param inputs line1 and line2
170
- * @returns intersection point or undefined if no intersection
224
+ * Finds the point where two lines cross.
225
+ *
226
+ * With `checkSegmentsOnly` on, the crossing must lie within both segments; off, the lines
227
+ * extend without end. Parallel lines, lines that pass each other without meeting, and segments
228
+ * that do not reach each other give undefined. The tolerance says how close counts as meeting.
229
+ * Example: [0,0,0] to [10,0,0] and [5,-5,0] to [5,5,0] -> [5,0,0]
230
+ * @param inputs - The two lines, whether to stay within the segments, and the tolerance
231
+ * @returns The crossing point, or undefined when there is none
171
232
  * @group intersection
172
233
  * @shortname line-line int
173
234
  * @drawable true
235
+ * @example
236
+ * ```typescript
237
+ * const crossing = bitbybit.line.lineLineIntersection({
238
+ * line1: { start: [0, 0, 0], end: [10, 0, 0] },
239
+ * line2: { start: [5, -5, 0], end: [5, 5, 0] },
240
+ * checkSegmentsOnly: true,
241
+ * tolerance: 1e-6,
242
+ * });
243
+ * ```
174
244
  */
175
245
  lineLineIntersection(inputs: Inputs.Line.LineLineIntersectionDto): Inputs.Base.Point3 | undefined;
176
246
  }
@@ -1,6 +1,8 @@
1
1
  /**
2
- * Contains various methods for lines and segments. Line in bitbybit is a simple object that has start and
3
- * end point properties. { start: [ x, y, z ], end: [ x, y, z ] }
2
+ * Straight lines between two points, held as plain objects of the form `{ start, end }`, and the
3
+ * segment form `[start, end]` of the same thing. The methods here build lines, measure and
4
+ * transform them, convert between the two forms, place points along them and find where two lines
5
+ * cross. Lengths are in model units.
4
6
  */
5
7
  export class Line {
6
8
  constructor(vector, point, geometryHelper) {
@@ -9,10 +11,11 @@ export class Line {
9
11
  this.geometryHelper = geometryHelper;
10
12
  }
11
13
  /**
12
- * Extracts start point from a line.
13
- * Example: line={start:[0,0,0], end:[10,5,0]} → [0,0,0]
14
- * @param inputs a line
15
- * @returns start point
14
+ * Reads the start point of a line.
15
+ *
16
+ * Example: { start: [0,0,0], end: [10,5,0] } -> [0,0,0]
17
+ * @param inputs - The line
18
+ * @returns The start point
16
19
  * @group get
17
20
  * @shortname line start point
18
21
  * @drawable true
@@ -21,10 +24,11 @@ export class Line {
21
24
  return inputs.line.start;
22
25
  }
23
26
  /**
24
- * Extracts end point from a line.
25
- * Example: line={start:[0,0,0], end:[10,5,0]} → [10,5,0]
26
- * @param inputs a line
27
- * @returns end point
27
+ * Reads the end point of a line.
28
+ *
29
+ * Example: { start: [0,0,0], end: [10,5,0] } -> [10,5,0]
30
+ * @param inputs - The line
31
+ * @returns The end point
28
32
  * @group get
29
33
  * @shortname line end point
30
34
  * @drawable true
@@ -33,10 +37,11 @@ export class Line {
33
37
  return inputs.line.end;
34
38
  }
35
39
  /**
36
- * Calculates length (distance) of a line segment.
37
- * Example: line={start:[0,0,0], end:[3,4,0]} → 5 (using Pythagorean theorem)
38
- * @param inputs a line
39
- * @returns line length
40
+ * Measures the straight distance from the start of a line to its end.
41
+ *
42
+ * Example: { start: [0,0,0], end: [3,4,0] } -> 5
43
+ * @param inputs - The line
44
+ * @returns The length in model units
40
45
  * @group get
41
46
  * @shortname line length
42
47
  * @drawable false
@@ -45,10 +50,11 @@ export class Line {
45
50
  return this.point.distance({ startPoint: inputs.line.start, endPoint: inputs.line.end });
46
51
  }
47
52
  /**
48
- * Reverses line direction by swapping start and end points.
49
- * Example: line={start:[0,0,0], end:[10,5,0]} → {start:[10,5,0], end:[0,0,0]}
50
- * @param inputs a line
51
- * @returns reversed line
53
+ * Swaps the start and end of a line, so it runs the other way.
54
+ *
55
+ * Example: { start: [0,0,0], end: [10,5,0] } -> { start: [10,5,0], end: [0,0,0] }
56
+ * @param inputs - The line
57
+ * @returns A new line running the other way
52
58
  * @group operations
53
59
  * @shortname reversed line
54
60
  * @drawable true
@@ -57,13 +63,22 @@ export class Line {
57
63
  return { start: inputs.line.end, end: inputs.line.start };
58
64
  }
59
65
  /**
60
- * Applies transformation matrix to line (rotates, scales, or translates both endpoints).
61
- * Example: line={start:[0,0,0], end:[10,0,0]} with translation [5,5,0] → {start:[5,5,0], end:[15,5,0]}
62
- * @param inputs a line
63
- * @returns transformed line
66
+ * Applies a transformation matrix, or a list of them in order, to both ends of a line.
67
+ *
68
+ * Example: { start: [0,0,0], end: [10,0,0] } moved by [5,5,0] -> { start: [5,5,0], end:
69
+ * [15,5,0] }
70
+ * @param inputs - The line and the transformation
71
+ * @returns A new line with the transformed ends
64
72
  * @group transforms
65
73
  * @shortname transform line
66
74
  * @drawable true
75
+ * @example
76
+ * ```typescript
77
+ * const moved = bitbybit.line.transformLine({
78
+ * line: { start: [0, 0, 0], end: [10, 0, 0] },
79
+ * transformation: bitbybit.transforms.translationXYZ({ translation: [5, 5, 0] }),
80
+ * });
81
+ * ```
67
82
  */
68
83
  transformLine(inputs) {
69
84
  const transformation = inputs.transformation;
@@ -75,13 +90,22 @@ export class Line {
75
90
  };
76
91
  }
77
92
  /**
78
- * Applies multiple transformations to multiple lines (one transform per line).
79
- * Example: 3 lines with 3 different translation matrices → each line moved independently
80
- * @param inputs lines
81
- * @returns transformed lines
93
+ * Applies a different transformation to each line: the first transformation to the first line,
94
+ * and so on.
95
+ *
96
+ * Example: three lines with three translations -> each line moved by its own translation
97
+ * @param inputs - The lines and one transformation per line
98
+ * @returns The transformed lines, in the same order
82
99
  * @group transforms
83
100
  * @shortname transform lines
84
101
  * @drawable true
102
+ * @example
103
+ * ```typescript
104
+ * const placed = bitbybit.line.transformsForLines({
105
+ * lines: [{ start: [0, 0, 0], end: [1, 0, 0] }, { start: [0, 0, 0], end: [0, 1, 0] }],
106
+ * transformation: bitbybit.transforms.translationsXYZ({ translations: [[0, 1, 0], [0, 2, 0]] }),
107
+ * });
108
+ * ```
85
109
  */
86
110
  transformsForLines(inputs) {
87
111
  return inputs.lines.map((line, index) => {
@@ -95,13 +119,18 @@ export class Line {
95
119
  });
96
120
  }
97
121
  /**
98
- * Creates a line from two points (line object with start and end properties).
99
- * Example: start=[0,0,0], end=[10,5,0] → {start:[0,0,0], end:[10,5,0]}
100
- * @param inputs start and end points of the line
101
- * @returns line
122
+ * Builds a line object from a start and an end point.
123
+ *
124
+ * Example: start [0,0,0], end [10,5,0] -> { start: [0,0,0], end: [10,5,0] }
125
+ * @param inputs - The start and end points
126
+ * @returns The line object
102
127
  * @group create
103
128
  * @shortname line
104
129
  * @drawable true
130
+ * @example
131
+ * ```typescript
132
+ * const line = bitbybit.line.create({ start: [0, 0, 0], end: [10, 5, 0] });
133
+ * ```
105
134
  */
106
135
  create(inputs) {
107
136
  return {
@@ -110,13 +139,18 @@ export class Line {
110
139
  };
111
140
  }
112
141
  /**
113
- * Creates a segment from two points (array format: [start, end]).
114
- * Example: start=[0,0,0], end=[10,5,0] → [[0,0,0], [10,5,0]]
115
- * @param inputs start and end points of the segment
116
- * @returns segment
142
+ * Builds a segment, the pair-of-points form of a line, from a start and an end point.
143
+ *
144
+ * Example: start [0,0,0], end [10,5,0] -> [[0,0,0], [10,5,0]]
145
+ * @param inputs - The start and end points
146
+ * @returns The segment as `[start, end]`
117
147
  * @group create
118
148
  * @shortname segment
119
149
  * @drawable true
150
+ * @example
151
+ * ```typescript
152
+ * const segment = bitbybit.line.createSegment({ start: [0, 0, 0], end: [10, 5, 0] });
153
+ * ```
120
154
  */
121
155
  createSegment(inputs) {
122
156
  return [
@@ -125,13 +159,20 @@ export class Line {
125
159
  ];
126
160
  }
127
161
  /**
128
- * Calculates point at parameter t along line segment (0=start, 1=end, linear interpolation).
129
- * Example: line={start:[0,0,0], end:[10,0,0]}, param=0.5 → [5,0,0] (midpoint)
130
- * @param inputs line
131
- * @returns point on line
162
+ * Finds the point a fraction of the way along a line: 0 gives the start, 1 the end, 0.5 the
163
+ * middle.
164
+ *
165
+ * A fraction outside 0 to 1 continues past the ends.
166
+ * Example: { start: [0,0,0], end: [10,0,0] } at 0.5 -> [5,0,0]
167
+ * @param inputs - The line and the fraction along it
168
+ * @returns The point on the line
132
169
  * @group get
133
170
  * @shortname point on line
134
171
  * @drawable true
172
+ * @example
173
+ * ```typescript
174
+ * const middle = bitbybit.line.getPointOnLine({ line: { start: [0, 0, 0], end: [10, 0, 0] }, param: 0.5 });
175
+ * ```
135
176
  */
136
177
  getPointOnLine(inputs) {
137
178
  var _a;
@@ -143,13 +184,18 @@ export class Line {
143
184
  return point;
144
185
  }
145
186
  /**
146
- * Creates line segments connecting consecutive points in a list (forms a polyline path).
147
- * Example: points=[[0,0,0], [5,0,0], [5,5,0]] → 2 lines: [0→5] and [5→5,5]
148
- * @param inputs points
149
- * @returns lines
187
+ * Joins each point to the next with a line, so a list of points becomes a chain of lines.
188
+ *
189
+ * Example: [[0,0,0], [5,0,0], [5,5,0]] -> two lines, [0,0,0] to [5,0,0] and [5,0,0] to [5,5,0]
190
+ * @param inputs - The points, in order
191
+ * @returns One line per pair of neighboring points
150
192
  * @group create
151
193
  * @shortname lines between points
152
194
  * @drawable true
195
+ * @example
196
+ * ```typescript
197
+ * const chain = bitbybit.line.linesBetweenPoints({ points: [[0, 0, 0], [5, 0, 0], [5, 5, 0]] });
198
+ * ```
153
199
  */
154
200
  linesBetweenPoints(inputs) {
155
201
  const lines = [];
@@ -161,14 +207,22 @@ export class Line {
161
207
  return lines;
162
208
  }
163
209
  /**
164
- * Creates lines by pairing corresponding start and end points from two arrays.
165
- * Filters out zero-length lines.
166
- * Example: starts=[[0,0,0], [5,0,0]], ends=[[0,5,0], [5,5,0]] → 2 lines connecting paired points
167
- * @param inputs start points and end points
168
- * @returns lines
210
+ * Pairs each start point with the end point at the same position and joins them with a line.
211
+ *
212
+ * A pair whose two points coincide makes no line and is left out.
213
+ * Example: starts [[0,0,0], [5,0,0]] and ends [[0,5,0], [5,5,0]] -> two lines
214
+ * @param inputs - The start points and the end points, in matching order
215
+ * @returns One line per pair, skipping pairs of length 0
169
216
  * @group create
170
217
  * @shortname start and end points to lines
171
218
  * @drawable true
219
+ * @example
220
+ * ```typescript
221
+ * const rungs = bitbybit.line.linesBetweenStartAndEndPoints({
222
+ * startPoints: [[0, 0, 0], [5, 0, 0]],
223
+ * endPoints: [[0, 5, 0], [5, 5, 0]],
224
+ * });
225
+ * ```
172
226
  */
173
227
  linesBetweenStartAndEndPoints(inputs) {
174
228
  return inputs.startPoints
@@ -176,10 +230,11 @@ export class Line {
176
230
  .filter(line => this.point.distance({ startPoint: line.start, endPoint: line.end }) !== 0);
177
231
  }
178
232
  /**
179
- * Converts line object to segment array format.
180
- * Example: {start:[0,0,0], end:[10,5,0]} → [[0,0,0], [10,5,0]]
181
- * @param inputs line
182
- * @returns segment
233
+ * Turns a line object into its segment form, the pair `[start, end]`.
234
+ *
235
+ * Example: { start: [0,0,0], end: [10,5,0] } -> [[0,0,0], [10,5,0]]
236
+ * @param inputs - The line
237
+ * @returns The segment
183
238
  * @group convert
184
239
  * @shortname line to segment
185
240
  * @drawable false
@@ -188,10 +243,11 @@ export class Line {
188
243
  return [inputs.line.start, inputs.line.end];
189
244
  }
190
245
  /**
191
- * Converts multiple line objects to segment array format (batch conversion).
192
- * Example: 3 line objects → 3 segment arrays [[start1, end1], [start2, end2], ...]
193
- * @param inputs lines
194
- * @returns segments
246
+ * Turns each line object into its segment form, the pair `[start, end]`.
247
+ *
248
+ * Example: three lines -> three segments, in the same order
249
+ * @param inputs - The lines
250
+ * @returns One segment per line
195
251
  * @group convert
196
252
  * @shortname lines to segments
197
253
  * @drawable false
@@ -200,10 +256,11 @@ export class Line {
200
256
  return inputs.lines.map(line => [line.start, line.end]);
201
257
  }
202
258
  /**
203
- * Converts segment array to line object format.
204
- * Example: [[0,0,0], [10,5,0]] → {start:[0,0,0], end:[10,5,0]}
205
- * @param inputs segment
206
- * @returns line
259
+ * Turns a segment, the pair `[start, end]`, into a line object.
260
+ *
261
+ * Example: [[0,0,0], [10,5,0]] -> { start: [0,0,0], end: [10,5,0] }
262
+ * @param inputs - The segment
263
+ * @returns The line
207
264
  * @group convert
208
265
  * @shortname segment to line
209
266
  * @drawable true
@@ -212,10 +269,11 @@ export class Line {
212
269
  return { start: inputs.segment[0], end: inputs.segment[1] };
213
270
  }
214
271
  /**
215
- * Converts multiple segment arrays to line object format (batch conversion).
216
- * Example: 3 segment arrays → 3 line objects with start/end properties
217
- * @param inputs segments
218
- * @returns lines
272
+ * Turns each segment, a pair `[start, end]`, into a line object.
273
+ *
274
+ * Example: three segments -> three lines, in the same order
275
+ * @param inputs - The segments
276
+ * @returns One line per segment
219
277
  * @group convert
220
278
  * @shortname segments to lines
221
279
  * @drawable true
@@ -224,14 +282,26 @@ export class Line {
224
282
  return inputs.segments.map(segment => ({ start: segment[0], end: segment[1] }));
225
283
  }
226
284
  /**
227
- * Calculates intersection point of two lines (or segments if checkSegmentsOnly=true).
228
- * Returns undefined if lines are parallel, skew, or segments don't overlap.
229
- * Example: line1={start:[0,0,0], end:[10,0,0]}, line2={start:[5,-5,0], end:[5,5,0]} → [5,0,0]
230
- * @param inputs line1 and line2
231
- * @returns intersection point or undefined if no intersection
285
+ * Finds the point where two lines cross.
286
+ *
287
+ * With `checkSegmentsOnly` on, the crossing must lie within both segments; off, the lines
288
+ * extend without end. Parallel lines, lines that pass each other without meeting, and segments
289
+ * that do not reach each other give undefined. The tolerance says how close counts as meeting.
290
+ * Example: [0,0,0] to [10,0,0] and [5,-5,0] to [5,5,0] -> [5,0,0]
291
+ * @param inputs - The two lines, whether to stay within the segments, and the tolerance
292
+ * @returns The crossing point, or undefined when there is none
232
293
  * @group intersection
233
294
  * @shortname line-line int
234
295
  * @drawable true
296
+ * @example
297
+ * ```typescript
298
+ * const crossing = bitbybit.line.lineLineIntersection({
299
+ * line1: { start: [0, 0, 0], end: [10, 0, 0] },
300
+ * line2: { start: [5, -5, 0], end: [5, 5, 0] },
301
+ * checkSegmentsOnly: true,
302
+ * tolerance: 1e-6,
303
+ * });
304
+ * ```
235
305
  */
236
306
  lineLineIntersection(inputs) {
237
307
  const epsilon = inputs.tolerance || 1e-6;