@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.
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,141 +3,228 @@ import * as Inputs from "../inputs";
3
3
  import { MathBitByBit } from "./math";
4
4
  import { Vector } from "./vector";
5
5
  /**
6
- * Transformations help to move, scale, rotate objects. You can combine multiple transformations
7
- * for object to be placed exactly into position and orientation that you want.
8
- * Contains various methods for transformations that represent 4x4 matrixes in flat 16 number arrays.
6
+ * Builds transformation matrices for moving, rotating, scaling and stretching geometry. A
7
+ * transformation is a 4x4 matrix as 16 numbers in column-major order; most methods return a short
8
+ * list of them that is applied in order, so a rotation about a point is a move to the origin, the
9
+ * rotation, and the move back. Angles are in degrees. Apply the result with the transform methods
10
+ * of `point`, `polyline`, `line` and the kernels.
9
11
  */
10
12
  export declare class Transforms {
11
13
  private readonly vector;
12
14
  private readonly math;
13
15
  constructor(vector: Vector, math: MathBitByBit);
14
16
  /**
15
- * Creates rotation transformations around a center point and custom axis.
16
- * Combines translation to origin, axis rotation, then translation back.
17
- * Example: center=[5,0,0], axis=[0,1,0], angle=90° → rotates around vertical axis through point [5,0,0]
18
- * @param inputs Rotation around center with an axis information
19
- * @returns array of transformations
17
+ * Builds a rotation about an axis that passes through a center point.
18
+ *
19
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
20
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
21
+ * you.
22
+ * Example: center [5,0,0], axis [0,1,0], angle 90 -> a quarter turn about the vertical line
23
+ * through [5,0,0]
24
+ * @param inputs - The axis direction, the center it passes through and the angle in degrees
25
+ * @returns The list of matrices to apply in order
20
26
  * @group rotation
21
27
  * @shortname center axis
22
28
  * @drawable false
29
+ * @example
30
+ * ```typescript
31
+ * const turn = bitbybit.transforms.rotationCenterAxis({ center: [5, 0, 0], axis: [0, 1, 0], angle: 90 });
32
+ * const points = bitbybit.point.transformPoints({ points: [[10, 0, 0]], transformation: turn });
33
+ * ```
23
34
  */
24
35
  rotationCenterAxis(inputs: Inputs.Transforms.RotationCenterAxisDto): Base.TransformMatrixes;
25
36
  /**
26
- * Creates rotation transformations around a center point along the X axis.
27
- * Example: center=[5,5,5], angle=90° → rotates 90° around X axis through point [5,5,5]
28
- * @param inputs Rotation around center with an X axis information
29
- * @returns array of transformations
37
+ * Builds a rotation about a line parallel to the X axis through a center point.
38
+ *
39
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
40
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
41
+ * you.
42
+ * Example: center [0,0,0], angle 90 -> a quarter turn about the X axis
43
+ * @param inputs - The center and the angle in degrees
44
+ * @returns The list of matrices to apply in order
30
45
  * @group rotation
31
46
  * @shortname center x
32
47
  * @drawable false
48
+ * @example
49
+ * ```typescript
50
+ * const turn = bitbybit.transforms.rotationCenterX({ center: [0, 0, 0], angle: 90 });
51
+ * ```
33
52
  */
34
53
  rotationCenterX(inputs: Inputs.Transforms.RotationCenterDto): Base.TransformMatrixes;
35
54
  /**
36
- * Creates rotation transformations around a center point along the Y axis.
37
- * Example: center=[0,0,0], angle=45° → rotates 45° around Y axis through origin
38
- * @param inputs Rotation around center with an Y axis information
39
- * @returns array of transformations
55
+ * Builds a rotation about a line parallel to the Y axis through a center point.
56
+ *
57
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
58
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
59
+ * you.
60
+ * Example: center [0,0,0], angle 90 -> a quarter turn about the Y axis
61
+ * @param inputs - The center and the angle in degrees
62
+ * @returns The list of matrices to apply in order
40
63
  * @group rotation
41
64
  * @shortname center y
42
65
  * @drawable false
66
+ * @example
67
+ * ```typescript
68
+ * const turn = bitbybit.transforms.rotationCenterY({ center: [0, 0, 0], angle: 90 });
69
+ * ```
43
70
  */
44
71
  rotationCenterY(inputs: Inputs.Transforms.RotationCenterDto): Base.TransformMatrixes;
45
72
  /**
46
- * Creates rotation transformations around a center point along the Z axis.
47
- * Example: center=[10,10,0], angle=180° → rotates 180° around Z axis through point [10,10,0]
48
- * @param inputs Rotation around center with an Z axis information
49
- * @returns array of transformations
73
+ * Builds a rotation about a line parallel to the Z axis through a center point.
74
+ *
75
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
76
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
77
+ * you.
78
+ * Example: center [0,0,0], angle 90 -> a quarter turn about the Z axis
79
+ * @param inputs - The center and the angle in degrees
80
+ * @returns The list of matrices to apply in order
50
81
  * @group rotation
51
82
  * @shortname center z
52
83
  * @drawable false
84
+ * @example
85
+ * ```typescript
86
+ * const turn = bitbybit.transforms.rotationCenterZ({ center: [0, 0, 0], angle: 90 });
87
+ * ```
53
88
  */
54
89
  rotationCenterZ(inputs: Inputs.Transforms.RotationCenterDto): Base.TransformMatrixes;
55
90
  /**
56
- * Creates rotation transformations using yaw-pitch-roll (Euler angles) around a center point.
57
- * Yaw → Y axis rotation, Pitch → X axis rotation, Roll → Z axis rotation.
58
- * Example: center=[0,0,0], yaw=90°, pitch=0°, roll=0° → rotates 90° around Y axis
59
- * @param inputs Yaw pitch roll rotation information
60
- * @returns array of transformations
91
+ * Builds a rotation from three angles about a center point: yaw turns about Y, pitch about X
92
+ * and roll about Z.
93
+ *
94
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
95
+ * back. Angles are in degrees.
96
+ * Example: yaw 90, pitch 0, roll 0 -> a quarter turn about the vertical axis
97
+ * @param inputs - The yaw, pitch and roll in degrees and the center
98
+ * @returns The list of matrices to apply in order
61
99
  * @group rotation
62
100
  * @shortname yaw pitch roll
63
101
  * @drawable false
102
+ * @example
103
+ * ```typescript
104
+ * const turn = bitbybit.transforms.rotationCenterYawPitchRoll({ yaw: 90, pitch: 0, roll: 0, center: [0, 0, 0] });
105
+ * ```
64
106
  */
65
107
  rotationCenterYawPitchRoll(inputs: Inputs.Transforms.RotationCenterYawPitchRollDto): Base.TransformMatrixes;
66
108
  /**
67
- * Creates non-uniform scale transformation around a center point (different scale per axis).
68
- * Example: center=[5,5,5], scaleXyz=[2,1,0.5] → doubles X, keeps Y, halves Z around point [5,5,5]
69
- * @param inputs Scale center xyz trnansformation
70
- * @returns array of transformations
109
+ * Builds a scale with its own factor per axis, measured from a center point that stays in
110
+ * place.
111
+ *
112
+ * The result is three matrices applied in order: move the center to the origin, scale, move
113
+ * back.
114
+ * Example: center [5,5,5], factors [2,1,0.5] -> doubles X, keeps Y, halves Z about [5,5,5]
115
+ * @param inputs - The center and the factor for each axis
116
+ * @returns The list of matrices to apply in order
71
117
  * @group scale
72
118
  * @shortname center xyz
73
119
  * @drawable false
120
+ * @example
121
+ * ```typescript
122
+ * const scale = bitbybit.transforms.scaleCenterXYZ({ center: [5, 5, 5], scaleXyz: [2, 1, 0.5] });
123
+ * ```
74
124
  */
75
125
  scaleCenterXYZ(inputs: Inputs.Transforms.ScaleCenterXYZDto): Base.TransformMatrixes;
76
126
  /**
77
- * Creates non-uniform scale transformation from origin (different scale per axis).
78
- * Example: scaleXyz=[2,3,1] → doubles X, triples Y, keeps Z unchanged
79
- * @param inputs Scale XYZ number array information
80
- * @returns transformation
127
+ * Builds a scale with its own factor per axis, measured from the origin.
128
+ *
129
+ * Example: factors [2,3,1] -> doubles X, triples Y, keeps Z
130
+ * @param inputs - The factor for each axis
131
+ * @returns A list with the one scale matrix
81
132
  * @group scale
82
133
  * @shortname xyz
83
134
  * @drawable false
135
+ * @example
136
+ * ```typescript
137
+ * const scale = bitbybit.transforms.scaleXYZ({ scaleXyz: [2, 3, 1] });
138
+ * ```
84
139
  */
85
140
  scaleXYZ(inputs: Inputs.Transforms.ScaleXYZDto): Base.TransformMatrixes;
86
141
  /**
87
- * Creates directional stretch transformation that scales along a specific direction from a center point.
88
- * Points move only along the direction vector; perpendicular plane remains unchanged.
89
- * Example: center=[0,0,0], direction=[1,0,0], scale=2 → stretches 2× along X axis only
90
- * @param inputs Defines the center, direction, and scale factor for the stretch.
91
- * @returns Array of transformations: [Translate To Origin, Stretch, Translate Back].
142
+ * Builds a stretch along one direction, measured from a center point; distances across that
143
+ * direction stay as they are.
144
+ *
145
+ * The result is three matrices applied in order: move the center to the origin, stretch, move
146
+ * back.
147
+ * Example: center [0,0,0], direction [1,0,0], scale 2 -> everything twice as far from the
148
+ * center along X
149
+ * @param inputs - The center, the direction and the factor
150
+ * @returns The list of matrices to apply in order
92
151
  * @group scale
93
152
  * @shortname stretch dir center
94
153
  * @drawable false
154
+ * @example
155
+ * ```typescript
156
+ * const stretch = bitbybit.transforms.stretchDirFromCenter({ center: [0, 0, 0], direction: [1, 0, 0], scale: 2 });
157
+ * ```
95
158
  */
96
159
  stretchDirFromCenter(inputs: Inputs.Transforms.StretchDirCenterDto): Base.TransformMatrixes;
97
160
  /**
98
- * Creates uniform scale transformation from origin (same scale on all axes).
99
- * Example: scale=2 → doubles size in all directions (X, Y, Z)
100
- * @param inputs Scale Dto
101
- * @returns transformation
161
+ * Builds a scale by the same factor on every axis, measured from the origin.
162
+ *
163
+ * Example: 2 -> everything twice as big and twice as far from the origin
164
+ * @param inputs - The factor
165
+ * @returns A list with the one scale matrix
102
166
  * @group scale
103
167
  * @shortname uniform
104
168
  * @drawable false
169
+ * @example
170
+ * ```typescript
171
+ * const scale = bitbybit.transforms.uniformScale({ scale: 2 });
172
+ * ```
105
173
  */
106
174
  uniformScale(inputs: Inputs.Transforms.UniformScaleDto): Base.TransformMatrixes;
107
175
  /**
108
- * Creates uniform scale transformation around a center point (same scale on all axes).
109
- * Example: center=[5,5,5], scale=0.5 → halves size in all directions around point [5,5,5]
110
- * @param inputs Scale Dto with center point information
111
- * @returns array of transformations
176
+ * Builds a scale by the same factor on every axis, measured from a center point that stays in
177
+ * place.
178
+ *
179
+ * The result is three matrices applied in order: move the center to the origin, scale, move
180
+ * back.
181
+ * Example: center [5,5,5], scale 0.5 -> everything half as big, shrinking toward [5,5,5]
182
+ * @param inputs - The factor and the center
183
+ * @returns The list of matrices to apply in order
112
184
  * @group scale
113
185
  * @shortname uniform from center
114
186
  * @drawable false
187
+ * @example
188
+ * ```typescript
189
+ * const scale = bitbybit.transforms.uniformScaleFromCenter({ center: [5, 5, 5], scale: 0.5 });
190
+ * ```
115
191
  */
116
192
  uniformScaleFromCenter(inputs: Inputs.Transforms.UniformScaleFromCenterDto): Base.TransformMatrixes;
117
193
  /**
118
- * Creates translation transformation (moves objects in space).
119
- * Example: translation=[10,5,0] → moves object 10 units in X, 5 in Y, 0 in Z
120
- * @param inputs Translation information
121
- * @returns transformation
194
+ * Builds a move by a vector.
195
+ *
196
+ * Example: [10,5,0] -> 10 along X, 5 along Y, nothing along Z
197
+ * @param inputs - The vector to move by
198
+ * @returns A list with the one translation matrix
122
199
  * @group translation
123
200
  * @shortname xyz
124
201
  * @drawable false
202
+ * @example
203
+ * ```typescript
204
+ * const move = bitbybit.transforms.translationXYZ({ translation: [10, 5, 0] });
205
+ * ```
125
206
  */
126
207
  translationXYZ(inputs: Inputs.Transforms.TranslationXYZDto): Base.TransformMatrixes;
127
208
  /**
128
- * Creates multiple translation transformations (batch move operations).
129
- * Example: translations=[[1,0,0], [0,2,0]] → generates two transforms: move +X, move +Y
130
- * @param inputs Translation information
131
- * @returns transformation
209
+ * Builds one move per vector, for transforming many points each by its own vector.
210
+ *
211
+ * Example: [[1,0,0], [0,2,0]] -> two transformations: one along X, one along Y
212
+ * @param inputs - The vectors to move by
213
+ * @returns One transformation per vector, in the same order
132
214
  * @group translations
133
215
  * @shortname xyz
134
216
  * @drawable false
135
- */
217
+ * @example
218
+ * ```typescript
219
+ * const moves = bitbybit.transforms.translationsXYZ({ translations: [[1, 0, 0], [0, 2, 0]] });
220
+ * ```
221
+ */
136
222
  translationsXYZ(inputs: Inputs.Transforms.TranslationsXYZDto): Base.TransformMatrixes[];
137
223
  /**
138
- * Creates identity transformation matrix (no transformation - leaves objects unchanged).
139
- * Returns 4×4 matrix: [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
140
- * @returns transformation
224
+ * Gives the matrix that changes nothing, as a starting point or a placeholder.
225
+ *
226
+ * Example: [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
227
+ * @returns The identity matrix
141
228
  * @group identity
142
229
  * @shortname identity
143
230
  * @drawable false
@@ -1,7 +1,9 @@
1
1
  /**
2
- * Transformations help to move, scale, rotate objects. You can combine multiple transformations
3
- * for object to be placed exactly into position and orientation that you want.
4
- * Contains various methods for transformations that represent 4x4 matrixes in flat 16 number arrays.
2
+ * Builds transformation matrices for moving, rotating, scaling and stretching geometry. A
3
+ * transformation is a 4x4 matrix as 16 numbers in column-major order; most methods return a short
4
+ * list of them that is applied in order, so a rotation about a point is a move to the origin, the
5
+ * rotation, and the move back. Angles are in degrees. Apply the result with the transform methods
6
+ * of `point`, `polyline`, `line` and the kernels.
5
7
  */
6
8
  export class Transforms {
7
9
  constructor(vector, math) {
@@ -9,14 +11,23 @@ export class Transforms {
9
11
  this.math = math;
10
12
  }
11
13
  /**
12
- * Creates rotation transformations around a center point and custom axis.
13
- * Combines translation to origin, axis rotation, then translation back.
14
- * Example: center=[5,0,0], axis=[0,1,0], angle=90° → rotates around vertical axis through point [5,0,0]
15
- * @param inputs Rotation around center with an axis information
16
- * @returns array of transformations
14
+ * Builds a rotation about an axis that passes through a center point.
15
+ *
16
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
17
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
18
+ * you.
19
+ * Example: center [5,0,0], axis [0,1,0], angle 90 -> a quarter turn about the vertical line
20
+ * through [5,0,0]
21
+ * @param inputs - The axis direction, the center it passes through and the angle in degrees
22
+ * @returns The list of matrices to apply in order
17
23
  * @group rotation
18
24
  * @shortname center axis
19
25
  * @drawable false
26
+ * @example
27
+ * ```typescript
28
+ * const turn = bitbybit.transforms.rotationCenterAxis({ center: [5, 0, 0], axis: [0, 1, 0], angle: 90 });
29
+ * const points = bitbybit.point.transformPoints({ points: [[10, 0, 0]], transformation: turn });
30
+ * ```
20
31
  */
21
32
  rotationCenterAxis(inputs) {
22
33
  return [
@@ -26,13 +37,21 @@ export class Transforms {
26
37
  ];
27
38
  }
28
39
  /**
29
- * Creates rotation transformations around a center point along the X axis.
30
- * Example: center=[5,5,5], angle=90° → rotates 90° around X axis through point [5,5,5]
31
- * @param inputs Rotation around center with an X axis information
32
- * @returns array of transformations
40
+ * Builds a rotation about a line parallel to the X axis through a center point.
41
+ *
42
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
43
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
44
+ * you.
45
+ * Example: center [0,0,0], angle 90 -> a quarter turn about the X axis
46
+ * @param inputs - The center and the angle in degrees
47
+ * @returns The list of matrices to apply in order
33
48
  * @group rotation
34
49
  * @shortname center x
35
50
  * @drawable false
51
+ * @example
52
+ * ```typescript
53
+ * const turn = bitbybit.transforms.rotationCenterX({ center: [0, 0, 0], angle: 90 });
54
+ * ```
36
55
  */
37
56
  rotationCenterX(inputs) {
38
57
  return [
@@ -42,13 +61,21 @@ export class Transforms {
42
61
  ];
43
62
  }
44
63
  /**
45
- * Creates rotation transformations around a center point along the Y axis.
46
- * Example: center=[0,0,0], angle=45° → rotates 45° around Y axis through origin
47
- * @param inputs Rotation around center with an Y axis information
48
- * @returns array of transformations
64
+ * Builds a rotation about a line parallel to the Y axis through a center point.
65
+ *
66
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
67
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
68
+ * you.
69
+ * Example: center [0,0,0], angle 90 -> a quarter turn about the Y axis
70
+ * @param inputs - The center and the angle in degrees
71
+ * @returns The list of matrices to apply in order
49
72
  * @group rotation
50
73
  * @shortname center y
51
74
  * @drawable false
75
+ * @example
76
+ * ```typescript
77
+ * const turn = bitbybit.transforms.rotationCenterY({ center: [0, 0, 0], angle: 90 });
78
+ * ```
52
79
  */
53
80
  rotationCenterY(inputs) {
54
81
  return [
@@ -58,13 +85,21 @@ export class Transforms {
58
85
  ];
59
86
  }
60
87
  /**
61
- * Creates rotation transformations around a center point along the Z axis.
62
- * Example: center=[10,10,0], angle=180° → rotates 180° around Z axis through point [10,10,0]
63
- * @param inputs Rotation around center with an Z axis information
64
- * @returns array of transformations
88
+ * Builds a rotation about a line parallel to the Z axis through a center point.
89
+ *
90
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
91
+ * back. The angle is in degrees; positive turns counter-clockwise when the axis points toward
92
+ * you.
93
+ * Example: center [0,0,0], angle 90 -> a quarter turn about the Z axis
94
+ * @param inputs - The center and the angle in degrees
95
+ * @returns The list of matrices to apply in order
65
96
  * @group rotation
66
97
  * @shortname center z
67
98
  * @drawable false
99
+ * @example
100
+ * ```typescript
101
+ * const turn = bitbybit.transforms.rotationCenterZ({ center: [0, 0, 0], angle: 90 });
102
+ * ```
68
103
  */
69
104
  rotationCenterZ(inputs) {
70
105
  return [
@@ -74,14 +109,21 @@ export class Transforms {
74
109
  ];
75
110
  }
76
111
  /**
77
- * Creates rotation transformations using yaw-pitch-roll (Euler angles) around a center point.
78
- * Yaw → Y axis rotation, Pitch → X axis rotation, Roll → Z axis rotation.
79
- * Example: center=[0,0,0], yaw=90°, pitch=0°, roll=0° → rotates 90° around Y axis
80
- * @param inputs Yaw pitch roll rotation information
81
- * @returns array of transformations
112
+ * Builds a rotation from three angles about a center point: yaw turns about Y, pitch about X
113
+ * and roll about Z.
114
+ *
115
+ * The result is three matrices applied in order: move the center to the origin, rotate, move
116
+ * back. Angles are in degrees.
117
+ * Example: yaw 90, pitch 0, roll 0 -> a quarter turn about the vertical axis
118
+ * @param inputs - The yaw, pitch and roll in degrees and the center
119
+ * @returns The list of matrices to apply in order
82
120
  * @group rotation
83
121
  * @shortname yaw pitch roll
84
122
  * @drawable false
123
+ * @example
124
+ * ```typescript
125
+ * const turn = bitbybit.transforms.rotationCenterYawPitchRoll({ yaw: 90, pitch: 0, roll: 0, center: [0, 0, 0] });
126
+ * ```
85
127
  */
86
128
  rotationCenterYawPitchRoll(inputs) {
87
129
  return [
@@ -91,13 +133,21 @@ export class Transforms {
91
133
  ];
92
134
  }
93
135
  /**
94
- * Creates non-uniform scale transformation around a center point (different scale per axis).
95
- * Example: center=[5,5,5], scaleXyz=[2,1,0.5] → doubles X, keeps Y, halves Z around point [5,5,5]
96
- * @param inputs Scale center xyz trnansformation
97
- * @returns array of transformations
136
+ * Builds a scale with its own factor per axis, measured from a center point that stays in
137
+ * place.
138
+ *
139
+ * The result is three matrices applied in order: move the center to the origin, scale, move
140
+ * back.
141
+ * Example: center [5,5,5], factors [2,1,0.5] -> doubles X, keeps Y, halves Z about [5,5,5]
142
+ * @param inputs - The center and the factor for each axis
143
+ * @returns The list of matrices to apply in order
98
144
  * @group scale
99
145
  * @shortname center xyz
100
146
  * @drawable false
147
+ * @example
148
+ * ```typescript
149
+ * const scale = bitbybit.transforms.scaleCenterXYZ({ center: [5, 5, 5], scaleXyz: [2, 1, 0.5] });
150
+ * ```
101
151
  */
102
152
  scaleCenterXYZ(inputs) {
103
153
  return [
@@ -107,26 +157,39 @@ export class Transforms {
107
157
  ];
108
158
  }
109
159
  /**
110
- * Creates non-uniform scale transformation from origin (different scale per axis).
111
- * Example: scaleXyz=[2,3,1] → doubles X, triples Y, keeps Z unchanged
112
- * @param inputs Scale XYZ number array information
113
- * @returns transformation
160
+ * Builds a scale with its own factor per axis, measured from the origin.
161
+ *
162
+ * Example: factors [2,3,1] -> doubles X, triples Y, keeps Z
163
+ * @param inputs - The factor for each axis
164
+ * @returns A list with the one scale matrix
114
165
  * @group scale
115
166
  * @shortname xyz
116
167
  * @drawable false
168
+ * @example
169
+ * ```typescript
170
+ * const scale = bitbybit.transforms.scaleXYZ({ scaleXyz: [2, 3, 1] });
171
+ * ```
117
172
  */
118
173
  scaleXYZ(inputs) {
119
174
  return [this.scaling(inputs.scaleXyz[0], inputs.scaleXyz[1], inputs.scaleXyz[2])];
120
175
  }
121
176
  /**
122
- * Creates directional stretch transformation that scales along a specific direction from a center point.
123
- * Points move only along the direction vector; perpendicular plane remains unchanged.
124
- * Example: center=[0,0,0], direction=[1,0,0], scale=2 → stretches 2× along X axis only
125
- * @param inputs Defines the center, direction, and scale factor for the stretch.
126
- * @returns Array of transformations: [Translate To Origin, Stretch, Translate Back].
177
+ * Builds a stretch along one direction, measured from a center point; distances across that
178
+ * direction stay as they are.
179
+ *
180
+ * The result is three matrices applied in order: move the center to the origin, stretch, move
181
+ * back.
182
+ * Example: center [0,0,0], direction [1,0,0], scale 2 -> everything twice as far from the
183
+ * center along X
184
+ * @param inputs - The center, the direction and the factor
185
+ * @returns The list of matrices to apply in order
127
186
  * @group scale
128
187
  * @shortname stretch dir center
129
188
  * @drawable false
189
+ * @example
190
+ * ```typescript
191
+ * const stretch = bitbybit.transforms.stretchDirFromCenter({ center: [0, 0, 0], direction: [1, 0, 0], scale: 2 });
192
+ * ```
130
193
  */
131
194
  stretchDirFromCenter(inputs) {
132
195
  const { center = [0, 0, 0], direction = [0, 0, 1], scale = 2 } = inputs;
@@ -137,25 +200,38 @@ export class Transforms {
137
200
  ];
138
201
  }
139
202
  /**
140
- * Creates uniform scale transformation from origin (same scale on all axes).
141
- * Example: scale=2 → doubles size in all directions (X, Y, Z)
142
- * @param inputs Scale Dto
143
- * @returns transformation
203
+ * Builds a scale by the same factor on every axis, measured from the origin.
204
+ *
205
+ * Example: 2 -> everything twice as big and twice as far from the origin
206
+ * @param inputs - The factor
207
+ * @returns A list with the one scale matrix
144
208
  * @group scale
145
209
  * @shortname uniform
146
210
  * @drawable false
211
+ * @example
212
+ * ```typescript
213
+ * const scale = bitbybit.transforms.uniformScale({ scale: 2 });
214
+ * ```
147
215
  */
148
216
  uniformScale(inputs) {
149
217
  return [this.scaling(inputs.scale, inputs.scale, inputs.scale)];
150
218
  }
151
219
  /**
152
- * Creates uniform scale transformation around a center point (same scale on all axes).
153
- * Example: center=[5,5,5], scale=0.5 → halves size in all directions around point [5,5,5]
154
- * @param inputs Scale Dto with center point information
155
- * @returns array of transformations
220
+ * Builds a scale by the same factor on every axis, measured from a center point that stays in
221
+ * place.
222
+ *
223
+ * The result is three matrices applied in order: move the center to the origin, scale, move
224
+ * back.
225
+ * Example: center [5,5,5], scale 0.5 -> everything half as big, shrinking toward [5,5,5]
226
+ * @param inputs - The factor and the center
227
+ * @returns The list of matrices to apply in order
156
228
  * @group scale
157
229
  * @shortname uniform from center
158
230
  * @drawable false
231
+ * @example
232
+ * ```typescript
233
+ * const scale = bitbybit.transforms.uniformScaleFromCenter({ center: [5, 5, 5], scale: 0.5 });
234
+ * ```
159
235
  */
160
236
  uniformScaleFromCenter(inputs) {
161
237
  return [
@@ -165,33 +241,44 @@ export class Transforms {
165
241
  ];
166
242
  }
167
243
  /**
168
- * Creates translation transformation (moves objects in space).
169
- * Example: translation=[10,5,0] → moves object 10 units in X, 5 in Y, 0 in Z
170
- * @param inputs Translation information
171
- * @returns transformation
244
+ * Builds a move by a vector.
245
+ *
246
+ * Example: [10,5,0] -> 10 along X, 5 along Y, nothing along Z
247
+ * @param inputs - The vector to move by
248
+ * @returns A list with the one translation matrix
172
249
  * @group translation
173
250
  * @shortname xyz
174
251
  * @drawable false
252
+ * @example
253
+ * ```typescript
254
+ * const move = bitbybit.transforms.translationXYZ({ translation: [10, 5, 0] });
255
+ * ```
175
256
  */
176
257
  translationXYZ(inputs) {
177
258
  return [this.translation(inputs.translation[0], inputs.translation[1], inputs.translation[2])];
178
259
  }
179
260
  /**
180
- * Creates multiple translation transformations (batch move operations).
181
- * Example: translations=[[1,0,0], [0,2,0]] → generates two transforms: move +X, move +Y
182
- * @param inputs Translation information
183
- * @returns transformation
261
+ * Builds one move per vector, for transforming many points each by its own vector.
262
+ *
263
+ * Example: [[1,0,0], [0,2,0]] -> two transformations: one along X, one along Y
264
+ * @param inputs - The vectors to move by
265
+ * @returns One transformation per vector, in the same order
184
266
  * @group translations
185
267
  * @shortname xyz
186
268
  * @drawable false
187
- */
269
+ * @example
270
+ * ```typescript
271
+ * const moves = bitbybit.transforms.translationsXYZ({ translations: [[1, 0, 0], [0, 2, 0]] });
272
+ * ```
273
+ */
188
274
  translationsXYZ(inputs) {
189
275
  return inputs.translations.map(translation => [this.translation(translation[0], translation[1], translation[2])]);
190
276
  }
191
277
  /**
192
- * Creates identity transformation matrix (no transformation - leaves objects unchanged).
193
- * Returns 4×4 matrix: [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
194
- * @returns transformation
278
+ * Gives the matrix that changes nothing, as a starting point or a placeholder.
279
+ *
280
+ * Example: [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
281
+ * @returns The identity matrix
195
282
  * @group identity
196
283
  * @shortname identity
197
284
  * @drawable false