figureone 0.15.10 → 1.0.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 (159) hide show
  1. package/figureone.min.js +1 -1
  2. package/index.js +79167 -0
  3. package/package.json +15 -1
  4. package/types/index.d.ts +132 -0
  5. package/types/js/figure/Animation/Animation.d.ts +36 -0
  6. package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
  7. package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
  8. package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
  9. package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
  10. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
  11. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
  12. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
  13. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
  14. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
  15. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
  16. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
  17. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
  18. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
  19. package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
  20. package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
  21. package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
  22. package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
  23. package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
  24. package/types/js/figure/DrawContext2D.d.ts +9 -0
  25. package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
  26. package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
  27. package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
  28. package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
  29. package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
  30. package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
  31. package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
  32. package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
  33. package/types/js/figure/Element.d.ts +1212 -0
  34. package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
  35. package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
  36. package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
  37. package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
  38. package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
  39. package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
  40. package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
  41. package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
  42. package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
  43. package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
  44. package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
  45. package/types/js/figure/Equation/Equation.d.ts +984 -0
  46. package/types/js/figure/Equation/EquationForm.d.ts +139 -0
  47. package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
  48. package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
  49. package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
  50. package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
  51. package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
  52. package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
  53. package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
  54. package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
  55. package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
  56. package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
  57. package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
  58. package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
  59. package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
  60. package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
  61. package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
  62. package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
  63. package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
  64. package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
  65. package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
  66. package/types/js/figure/Figure.d.ts +711 -0
  67. package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
  68. package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
  69. package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
  70. package/types/js/figure/FigureCollections/Button.d.ts +195 -0
  71. package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
  72. package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
  73. package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
  74. package/types/js/figure/FigureCollections/Line.d.ts +587 -0
  75. package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
  76. package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
  77. package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
  78. package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
  79. package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
  80. package/types/js/figure/FigureCollections/Text.d.ts +307 -0
  81. package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
  82. package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
  83. package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
  84. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
  85. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
  86. package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
  87. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
  88. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
  89. package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
  90. package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
  91. package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
  92. package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
  93. package/types/js/figure/FontManager.d.ts +113 -0
  94. package/types/js/figure/Gesture.d.ts +39 -0
  95. package/types/js/figure/Recorder/Recorder.d.ts +291 -0
  96. package/types/js/figure/Recorder/parseState.d.ts +3 -0
  97. package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
  98. package/types/js/figure/Recorder/state.d.ts +7 -0
  99. package/types/js/figure/SlideNavigator.d.ts +606 -0
  100. package/types/js/figure/TimeKeeper.d.ts +174 -0
  101. package/types/js/figure/geometries/arc.d.ts +18 -0
  102. package/types/js/figure/geometries/arrow.d.ts +215 -0
  103. package/types/js/figure/geometries/buffer.d.ts +4 -0
  104. package/types/js/figure/geometries/copy/copy.d.ts +178 -0
  105. package/types/js/figure/geometries/ellipse.d.ts +17 -0
  106. package/types/js/figure/geometries/line.d.ts +13 -0
  107. package/types/js/figure/geometries/lines/corners.d.ts +7 -0
  108. package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
  109. package/types/js/figure/geometries/lines/lines.d.ts +31 -0
  110. package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
  111. package/types/js/figure/geometries/rectangle.d.ts +19 -0
  112. package/types/js/figure/geometries/triangle.d.ts +27 -0
  113. package/types/js/figure/webgl/Atlas.d.ts +42 -0
  114. package/types/js/figure/webgl/shaders.d.ts +143 -0
  115. package/types/js/figure/webgl/target.d.ts +9 -0
  116. package/types/js/figure/webgl/webgl.d.ts +54 -0
  117. package/types/js/tools/FunctionMap.d.ts +69 -0
  118. package/types/js/tools/color.d.ts +11 -0
  119. package/types/js/tools/colorNames.d.ts +2 -0
  120. package/types/js/tools/d2/polygon.d.ts +60 -0
  121. package/types/js/tools/d2/triangles.d.ts +0 -0
  122. package/types/js/tools/d3/cone.d.ts +57 -0
  123. package/types/js/tools/d3/cube.d.ts +26 -0
  124. package/types/js/tools/d3/cylinder.d.ts +45 -0
  125. package/types/js/tools/d3/line3.d.ts +55 -0
  126. package/types/js/tools/d3/prism.d.ts +49 -0
  127. package/types/js/tools/d3/revolve.d.ts +87 -0
  128. package/types/js/tools/d3/sphere.d.ts +33 -0
  129. package/types/js/tools/d3/surface.d.ts +47 -0
  130. package/types/js/tools/g2.d.ts +242 -0
  131. package/types/js/tools/geometry/Bounds.d.ts +446 -0
  132. package/types/js/tools/geometry/Line.d.ts +314 -0
  133. package/types/js/tools/geometry/Path.d.ts +67 -0
  134. package/types/js/tools/geometry/Plane.d.ts +201 -0
  135. package/types/js/tools/geometry/Point.d.ts +359 -0
  136. package/types/js/tools/geometry/Rect.d.ts +115 -0
  137. package/types/js/tools/geometry/Transform.d.ts +623 -0
  138. package/types/js/tools/geometry/angle.d.ts +105 -0
  139. package/types/js/tools/geometry/common.d.ts +9 -0
  140. package/types/js/tools/geometry/coordinates.d.ts +30 -0
  141. package/types/js/tools/geometry/deceleration.d.ts +13 -0
  142. package/types/js/tools/geometry/polygon.d.ts +4 -0
  143. package/types/js/tools/geometry/quaternion.d.ts +15 -0
  144. package/types/js/tools/geometry/scene.d.ts +282 -0
  145. package/types/js/tools/geometry/tools.d.ts +8 -0
  146. package/types/js/tools/geometry/types.d.ts +2 -0
  147. package/types/js/tools/getCssColors.d.ts +1 -0
  148. package/types/js/tools/getCssVariables.d.ts +4 -0
  149. package/types/js/tools/getImageData.d.ts +1 -0
  150. package/types/js/tools/getScssColors.d.ts +2 -0
  151. package/types/js/tools/htmlGenerator.d.ts +85 -0
  152. package/types/js/tools/m2.d.ts +24 -0
  153. package/types/js/tools/m3.d.ts +71 -0
  154. package/types/js/tools/math.d.ts +112 -0
  155. package/types/js/tools/morph.d.ts +651 -0
  156. package/types/js/tools/styleSheets.d.ts +3 -0
  157. package/types/js/tools/tools.d.ts +281 -0
  158. package/types/js/tools/types.d.ts +305 -0
  159. package/figureone.worker.js +0 -1
@@ -0,0 +1,314 @@
1
+ import { Point } from './Point';
2
+ import type { TypeParsablePoint } from './Point';
3
+ /**
4
+ * Line definition object.
5
+ *
6
+ * Combinations that can be used are:
7
+ * - p1, p2, ends
8
+ * - p1, length, angle, ends (for 2D lines)
9
+ * - p1, length, phi, theta, ends (for 3D lines)
10
+ * - p1, length, direction, ends
11
+ *
12
+ * @property {TypeParsablePoint} [p1] first point of line
13
+ * @property {TypeParsablePoint} [p2] second point of line
14
+ * @property {number} [length] length of line
15
+ * @property {number} [theta] theta (elevation) angle of line in spherical
16
+ * coordinates
17
+ * @property {number} [phi] phi (azimuth) angle of line in spherical coordinates
18
+ * @property {number} [angle] angle of line in 2D definition
19
+ * @property {TypeParsablePoint | number} [direction] direction vector of line
20
+ * from p1
21
+ * @property {0 | 1 | 2} [ends]
22
+ * @interface
23
+ * @group Misc Shapes
24
+ */
25
+ export type OBJ_LineDefinition = {
26
+ p1?: TypeParsablePoint;
27
+ p2?: TypeParsablePoint;
28
+ length?: number;
29
+ theta?: number;
30
+ angle?: number;
31
+ phi?: number;
32
+ direction?: TypeParsablePoint | number;
33
+ ends?: 0 | 1 | 2;
34
+ };
35
+ /**
36
+ * Recorder state definition of a {@link Line} that represents the two end
37
+ * points of the line and the number of finite ends.
38
+ *
39
+ * `{ f1Type: 'l', state: [[number, number, number], [number, number, number], 2 | 1 | 0] }`
40
+ * @group Misc Geometry
41
+ */
42
+ type TypeF1DefLine = {
43
+ f1Type: 'l';
44
+ state: [[number, number, number], [number, number, number], 2 | 1 | 0];
45
+ };
46
+ /**
47
+ * Line intersect result.
48
+ *
49
+ * @property {Point} [intersect] the intersection point. Will be undefined if
50
+ * there is no intersection
51
+ * @property {boolean} collinear `true` if the lines are collinear
52
+ * @property {boolean} onLines `true` if the intersection point is on both lines
53
+ * @interface
54
+ * @group Misc Geometry
55
+ */
56
+ export type OBJ_LineIntersect = {
57
+ intersect?: Point;
58
+ collinear: boolean;
59
+ onLines: boolean;
60
+ };
61
+ /**
62
+ * A {@link Line} is defined with either:
63
+ * - an instantiated {@link Line}
64
+ * - two points [{@link TypeParsablePoint}, {@link TypeParsablePoint}]
65
+ * - two points and the number of ends
66
+ * [{@link TypeParsablePoint}, {@link TypeParsablePoint}, `1 | 2 | 0`]
67
+ * - a line definition object {@link OBJ_LineDefinition}
68
+ * - A recorder state definition {@link TypeF1DefLine}
69
+ * - A string representation of all options except the first
70
+ *
71
+ * The `ends` defines whether a line is finite (a line segment between two
72
+ * points - `ends = 2`), a ray (a line extending to infinity in one direction
73
+ * from a point - `ends = 1`), or a infinite line (a line extending to infinity
74
+ * in both directions - `ends = 0`).
75
+ *
76
+ * @example
77
+ * // l1, l2, l3, l4, l5, and l6 are all the same
78
+ * l1 = new Fig.Line([0, 0], [2, 0]);
79
+ * l2 = Fig.getLine([[0, 0], [2, 0]]);
80
+ * l3 = Fig.getLine({ p1: [0, 0], length: 2, direction: [1, 0] });
81
+ * l4 = Fig.getLine({ p1: [0, 0], length: 2, angle: 0 });
82
+ * l5 = Fig.getLine({ p1: [0, 0], length: 2, theta: Math.PI / 2, phi: 0 });
83
+ * l6 = Fig.getLine({ p1: [0, 0], p2: [2, 0] });
84
+ * @group Geometry
85
+ */
86
+ export type TypeParsableLine = [TypeParsablePoint, TypeParsablePoint, 2 | 1 | 0] | [TypeParsablePoint, TypeParsablePoint] | OBJ_LineDefinition | TypeF1DefLine | Line;
87
+ /**
88
+ * Convert a parsable line definition to a {@link Line}.
89
+ * @param {TypeParsableLine} l parsable line definition
90
+ * @return {Line} `Line` object
91
+ * @group Misc Geometry
92
+ */
93
+ declare function getLine(l: TypeParsableLine): Line;
94
+ /**
95
+ * Object representing a Line.
96
+ *
97
+ * Contains methods that makes it conventient to use lines in calculations.
98
+ *
99
+ * @example
100
+ * // get Line from Fig
101
+ * const { Line } = Fig;
102
+ *
103
+ * // define a line from [0, 0] to [1, 0]
104
+ * const l = new Line([0, 0], [1, 0]);
105
+ *
106
+ * // find the length of the line
107
+ * const len = l.length();
108
+ *
109
+ * // get the point at length 0.2 along the line
110
+ * const p = l.pointAtLength(0.2);
111
+ *
112
+ * // find the intersect with another line
113
+ * const i = l.intersectsWith([[0.5, 0.5], [0.5, -0.5]]);
114
+ * @group Geometry
115
+ */
116
+ declare class Line {
117
+ p1: Point;
118
+ p2: Point;
119
+ ends: 2 | 1 | 0;
120
+ /**
121
+ * @param {0 | 1 | 2} ends number of ends the line has. `2` ends is a finite
122
+ * line. `1` end is an infinite line that terminates at the first point, and
123
+ * goes through the second point to infinity. `0` ends is an infinite line
124
+ * that goes through both first and second points to infinity.
125
+ */
126
+ constructor(p1OrOptions: TypeParsablePoint | OBJ_LineDefinition, p2?: TypeParsablePoint, ends?: 2 | 1 | 0);
127
+ _state(options: {
128
+ precision: number;
129
+ }): TypeF1DefLine;
130
+ /**
131
+ * Return the spherical theta angle of p2 relative to p1.
132
+ */
133
+ theta(): number;
134
+ /**
135
+ * Return the spherical phi angle of p2 relative to p1.
136
+ */
137
+ phi(): number;
138
+ _dup(): Line;
139
+ /**
140
+ * Change p1 of the line
141
+ */
142
+ setP1(p1: TypeParsablePoint): void;
143
+ /**
144
+ * Change p2 of the line
145
+ */
146
+ setP2(p2: TypeParsablePoint): void;
147
+ /**
148
+ * Get the unit vector of the line ((p2 - p1) / length).
149
+ */
150
+ unitVector(): Point;
151
+ /**
152
+ * Get the vector of the line (p2 - p1).
153
+ */
154
+ vector(): Point;
155
+ /**
156
+ * Get p1 or p2
157
+ * @return {Point}
158
+ */
159
+ getPoint(index?: 1 | 2): Point;
160
+ /**
161
+ * Return a line with swapped p1 and p2.
162
+ */
163
+ reverse(): Line;
164
+ /**
165
+ * Get the 2D angle of the line from p1 to p2
166
+ * @return {number}
167
+ */
168
+ angle(): number;
169
+ /**
170
+ * Return a duplicate line with values rounded to `precision`
171
+ * @return {Line}
172
+ */
173
+ round(precision?: number): Line;
174
+ /**
175
+ * Return the distance between p1 and p2. Note, for infinite lines
176
+ * this will still return the distance between p1 and p2 that defines
177
+ * the line.
178
+ * @return {number}
179
+ */
180
+ length(): number;
181
+ /**
182
+ * Return the midpoint between p1 and p2.
183
+ * @return {Point}
184
+ */
185
+ midPoint(): Point;
186
+ /**
187
+ * Return the point along some percent of the distance between p1 and p2.
188
+ * @return {Point}
189
+ */
190
+ pointAtPercent(percent: number): Point;
191
+ /**
192
+ * Return the point along the line at some length from p1
193
+ * @return {Point}
194
+ */
195
+ pointAtLength(length: number): Point;
196
+ /**
197
+ * `true` if `point` is along the line extended to infinity on both ends
198
+ * @return {boolean}
199
+ */
200
+ hasPointAlong(point: TypeParsablePoint, precision?: number): boolean;
201
+ /**
202
+ * `true` if `point` is on the line.
203
+ * If the line has 2 or 1 finite ends, point must be on or between the
204
+ * defined ends.
205
+ * @return {boolean}
206
+ */
207
+ hasPointOn(point: TypeParsablePoint, precision?: number): boolean;
208
+ /**
209
+ * Perpendicular distance from `point` to line
210
+ * @return {number}
211
+ */
212
+ distanceToPoint(point: TypeParsablePoint): number;
213
+ /**
214
+ * `true` if `line` is parrallel to this line.
215
+ * @return {boolean}
216
+ */
217
+ isParallelTo(line: TypeParsableLine, precision?: number): boolean;
218
+ /**
219
+ * `true` if two lines are equal to within some rounding `precision`.
220
+ * @return {boolean}
221
+ */
222
+ isEqualTo(line2: TypeParsableLine, precision?: number, delta?: boolean): boolean;
223
+ /**
224
+ * `true` if this line is within `line2`
225
+ * @return {boolean}
226
+ */
227
+ hasLineWithin(line: TypeParsableLine, precision?: number): boolean;
228
+ /**
229
+ * `true` if this line is along the infinite length of `line2`
230
+ * @return {boolean}
231
+ */
232
+ isAlongLine(line: TypeParsableLine, precision?: number): boolean;
233
+ isCollinearTo(line: TypeParsableLine, precision?: number): boolean;
234
+ isWithinLine(line: TypeParsableLine, precision?: number): boolean;
235
+ /**
236
+ * Create a line that is offset by some distance from this line.
237
+ *
238
+ * `'left'`, `'right'`, `'top'` and `'bottom'` are relative to cartesian
239
+ * coordinates.
240
+ *
241
+ * `'positive'` to the right of a vertical line defined from bottom to top and
242
+ * above a horizontal line defined from right to left. Another way to think of
243
+ * it is if lines are used to create a polygon in the positive rotation
244
+ * direction (CCW), the the `'positive'` side will be on the outside of the
245
+ * polygon.
246
+ *
247
+ * `'negative'` is then the inside of the same polygon.
248
+ * @return {Line}
249
+ */
250
+ offset(direction: TypeParsablePoint | 'left' | 'right' | 'top' | 'bottom' | 'positive' | 'negative', dist?: number | null, perpendicular?: boolean): Line;
251
+ /**
252
+ * Create a line that is offset by some distance from this line.
253
+ *
254
+ * `'left'`, `'right'`, `'top'` and `'bottom'` are relative to cartesian
255
+ * coordinates.
256
+ *
257
+ * `'positive'` to the right of a vertical line defined from bottom to top and
258
+ * above a horizontal line defined from right to left. Another way to think of
259
+ * it is if lines are used to create a polygon in the positive rotation
260
+ * direction (CCW), the the `'positive'` side will be on the outside of the
261
+ * polygon.
262
+ *
263
+ * `'negative'` is then the inside of the same polygon.
264
+ * @return {Line}
265
+ */
266
+ offset2D(direction: 'left' | 'right' | 'top' | 'bottom' | 'positive' | 'negative', dist: number): Line;
267
+ /**
268
+ * Perpendicular distance between two lines extended to infinity
269
+ */
270
+ distanceToLine(line: TypeParsableLine, precision?: number): number;
271
+ /**
272
+ * Return the point projected onto the line by some point off the line.
273
+ * The line from the projected point to the offline point will be
274
+ * perpendicular to the line.
275
+ */
276
+ pointProjection(p: TypeParsablePoint): Point;
277
+ /**
278
+ * The intersection between this line and `line2`.
279
+ *
280
+ * The returned result is an {@link Intersect} object with the keys
281
+ * `intersect`, `offLine` and `colinear`.
282
+ *
283
+ * If no intersect exists, then `intersect` will be undefined.
284
+ *
285
+ * If an intersect exists, and the intersect is within both lines, then
286
+ * `offLine` will be `true`. If at least one of the lines needs to be extended
287
+ * to reach the intersect point, then `offLine` will be `false`.
288
+ *
289
+ * If the lines are collinear but do not overlap, then the intersect point
290
+ * will be the midpoint between the two closest ends. `offLine` will be `true`
291
+ * and `collinear` will be `true`.
292
+ *
293
+ * If the lines are collinear and overlap fully (or are equal), then the
294
+ * intersect will be p1 of the calling line, `offLine` will be `false` and
295
+ * `collinear` will be `true`.
296
+ *
297
+ * If either line has zero length, then an exception will be thrown.
298
+ * @return {Intersect}
299
+ */
300
+ intersectsWith(line: TypeParsableLine, precision?: number): OBJ_LineIntersect;
301
+ /**
302
+ * Clip a point to be on a line.
303
+ *
304
+ * If point is not along line, then it will be projected onto it.
305
+ *
306
+ * If point is not on line, then the closest line end will be returned.
307
+ *
308
+ * @param {TypeParsablePoint} point point to clip
309
+ * @param {number} precision precision to clip to (`8`)
310
+ * @return {Point} clipped point
311
+ */
312
+ clipPoint(point: TypeParsablePoint, precision?: number): Point;
313
+ }
314
+ export { Line, getLine, };
@@ -0,0 +1,67 @@
1
+ import { Point } from './Point';
2
+ import type { TypeParsablePoint } from './Point';
3
+ declare function linearPath(start: Point, delta: Point, percent: number): Point;
4
+ /**
5
+ * Curved translation path options, that defineds the control
6
+ * point of a quadratic bezier curve.
7
+ *
8
+ * Use `controlPoint` to define the control point directly. This
9
+ * will override all other properties.
10
+ *
11
+ * Otherwise `direction`, `magnitude` and `offset` can be used
12
+ * to calculate the control point based on the start and end
13
+ * points of the curve.
14
+ *
15
+ * The control point is calculated by:
16
+ * - Define a line from start to target - it will have length `d`
17
+ * - Define a point `P` on the line
18
+ * - Define a control line from point `P` with length `d` and some
19
+ * angle delta from the original line.
20
+ *
21
+ * The properties then customize this calculation:
22
+ * - `magnitude` will scale the distance d
23
+ * - `offset` will define where on the line point `P` is where `0.5` is
24
+ * the midpoint and `0.1` is 10% along the line from the start location
25
+ * - `direction` will define which side of the line the control line should be
26
+ * drawn
27
+ * - `angle` defines the angle delta between the line and the control line - by
28
+ * default this a right angle (Math.PI / 2)
29
+ *
30
+ * The directions `'up'`, `'down'`, `'left'`, `'right'` all reference the side
31
+ * of the line. The `'positive'`
32
+ * direction is the side of the line that the line would move toward when
33
+ * rotated in the positive direction around the start point. The
34
+ * '`negative`' side of the line is then the opposite side.
35
+ *
36
+ * These directions only work when the `angle` is between `0` and `Math.PI`.
37
+ *
38
+ * @property {TypeParsablePoint | null} controlPoint
39
+ * @property {number} magnitude
40
+ * @property {number} offset
41
+ * @property {number} angle (`Math.PI / 2`)
42
+ * @property {'positive' | 'negative' | 'up' | 'left' | 'down' | 'right'} direction
43
+ * @interface
44
+ * @group Misc Geometry
45
+ */
46
+ export type OBJ_QuadraticBezier = {
47
+ controlPoint: TypeParsablePoint | null;
48
+ angle: number;
49
+ magnitude: number;
50
+ offset: number;
51
+ direction: 'up' | 'left' | 'down' | 'right' | 'positive' | 'negative';
52
+ };
53
+ /**
54
+ * Translation path options object
55
+ */
56
+ export type OBJ_TranslationPath = {
57
+ style?: 'curve' | 'linear' | 'curved';
58
+ angle?: number;
59
+ magnitude?: number;
60
+ offset?: number;
61
+ controlPoint?: TypeParsablePoint | null;
62
+ direction?: 'positive' | 'negative' | 'up' | 'down' | 'left' | 'right';
63
+ };
64
+ declare function curvedPath(start: Point, delta: Point, percent: number, options: OBJ_TranslationPath): Point;
65
+ declare function translationPath(pathType: "linear" | "curved" | "curve" | undefined, start: Point, delta: Point, percent: number, options: OBJ_TranslationPath): Point;
66
+ declare function toDelta(start: Point, delta: Point, percent: number, translationStyle?: 'linear' | 'curved' | 'curve', translationOptions?: OBJ_TranslationPath): Point;
67
+ export { curvedPath, linearPath, translationPath, toDelta, };
@@ -0,0 +1,201 @@
1
+ import { Line } from './Line';
2
+ import { Point } from './Point';
3
+ import type { TypeParsablePoint } from './Point';
4
+ import type { TypeParsableLine } from './Line';
5
+ /**
6
+ * Recorder state definition of a {@link Plane} that represents a position
7
+ * and normal vector
8
+ *
9
+ * ```
10
+ * {
11
+ * f1Type: 'pl',
12
+ * state: [[number, number, number], [number, number, number]],
13
+ * }
14
+ * ```
15
+ * @group Misc Geometry
16
+ */
17
+ export type TypeF1DefPlane = {
18
+ f1Type: 'pl';
19
+ state: [[number, number, number], [number, number, number]];
20
+ };
21
+ /**
22
+ * A {@link Plane} is defined with either:
23
+ * - an instantiated {@link Plane}
24
+ * - a position and normal vector
25
+ * [{@link TypeParsablePoint}, {@link TypeParsablePoint}]
26
+ * - three points [{@link TypeParsablePoint}, {@link TypeParsablePoint},
27
+ * {@link TypeParsablePoint}]
28
+ * - A recorder state definition {@link TypeF1DefPlane}
29
+ * - A string representation of all options except the first
30
+ *
31
+ * When defining 3 points p1, p2 and p3, the normal will be in the direction of
32
+ * the cross product of p12 with p13.
33
+ *
34
+ *
35
+ * @example
36
+ * // p1, p2, and p3 are all equal planes
37
+ * p1 = new Fig.Plane([0, 0, 0], [0, 1, 0]);
38
+ * p2 = Fig.getPlane([[0, 0, 0], [0, 1, 0]]);
39
+ * p3 = Fig.getPlane([[0, 0, 0], [1, 0, 0], [0, 0, 1]]);
40
+ * @group Geometry
41
+ */
42
+ export type TypeParsablePlane = [TypeParsablePoint, TypeParsablePoint] | [TypeParsablePoint, TypeParsablePoint, TypeParsablePoint] | Plane | string;
43
+ /**
44
+ * Chech if input parameter can be parsed as a {@link Plane}.
45
+ * @return {boolean}
46
+ * @group Misc Geometry
47
+ */
48
+ declare function isParsablePlane(pIn: any): boolean;
49
+ /**
50
+ * Parse a {@link TypeParsablePoint} and return a {@link Point}.
51
+ * @return {Point}
52
+ * @group Misc Geometry
53
+ */
54
+ declare function getPlane(p: TypeParsablePlane): Plane;
55
+ /**
56
+ * Object representing a plane.
57
+ *
58
+ * Contains methods that makes it convenient to operate on planes,
59
+ * points and lines.
60
+ *
61
+ * A plane can either be created with:
62
+ * - a point on the plane and a normal
63
+ * - 3 points on the plane
64
+ *
65
+ * If defined with 3 points P1, P2, and P3, then the normal will be in the
66
+ * direction of the cross product of vectors P1P2 and P1P3.
67
+ *
68
+ * @example
69
+ * // define a plane at the origin in the XZ plane
70
+ * const p = new Plane([0, 0, 0], [0, 1, 0]);
71
+ *
72
+ * // see if a point is on the plane
73
+ * const result = p.hasPointOn([1, 0, 1]);
74
+ *
75
+ * // find the intersect with a line
76
+ * const i = lineIntersect([[0, -0.5, 0], [0, 0.5, 0]])
77
+ * @group Geometry
78
+ */
79
+ declare class Plane {
80
+ p: Point;
81
+ n: Point;
82
+ /**
83
+ * @return {Plane} a XY plane through the origin
84
+ */
85
+ static xy(): Plane;
86
+ /**
87
+ * @return {Plane} a XZ plane through the origin
88
+ */
89
+ static xz(): Plane;
90
+ /**
91
+ * @return {Plane} a YZ plane through the origin
92
+ */
93
+ static yz(): Plane;
94
+ /**
95
+ * @param {TypeParsablePlane | TypeParsablePoint} p1OrDef position of plane
96
+ * or parsable plane definition
97
+ * @param {TypeParsablePoint | null} normalOrP2 if `p1OrDef` is a point and
98
+ * `p3` is `null`, then
99
+ * this parameter will define the plane normal (`null`)
100
+ * @param {TypeParsablePoint | null} p3 if defined, then `p1OrDef` and
101
+ * `normalOrP2` will define the first two points of a three point plane
102
+ * definition
103
+ */
104
+ constructor(p1OrDef?: TypeParsablePlane | TypeParsablePoint, normalOrP2?: null | TypeParsablePoint, p3?: null | TypeParsablePoint);
105
+ _dup(): Plane;
106
+ _state(options: {
107
+ precision: number;
108
+ }): {
109
+ f1Type: string;
110
+ state: number[][];
111
+ };
112
+ /**
113
+ * Return a plane with all values rounded to a precision.
114
+ * @param {number} precision
115
+ * @return {Plane}
116
+ */
117
+ round(precision?: number): Plane;
118
+ /**
119
+ * `true` if point p lies on plane
120
+ * @param {TypeParsablePoint} p
121
+ * @param {number} precision
122
+ * @return {boolean}
123
+ */
124
+ hasPointOn(p: TypeParsablePoint, precision?: number): boolean;
125
+ /**
126
+ * Two planes are considered equal if they are parallel, and the same
127
+ * point exists on both planes.
128
+ *
129
+ * If the plane normal direction also needs to be compared, then use `includeNormal = true`.
130
+ *
131
+ * @param {TypeParsablePlane} plane
132
+ * @param {boolean} includeNormal
133
+ * @param {number} precision
134
+ * @return {boolean}
135
+ */
136
+ isEqualTo(plane: TypeParsablePlane, includeNormal?: boolean, precision?: number): boolean;
137
+ /**
138
+ * `true` if two planes are parallel to each other.
139
+ * @param {TypeParsablePlane} plane
140
+ * @param {number} precision
141
+ * @return {boolean}
142
+ */
143
+ isParallelTo(plane: TypeParsablePlane, precision?: number): boolean;
144
+ /**
145
+ * Returns intersect line of two planes. Returns `null` if planes are parallel
146
+ * and have no intersect.
147
+ *
148
+ * @param {TypeParsablePlane} plane
149
+ * @param {number} precision
150
+ * @return {null | Line} intersect line
151
+ */
152
+ intersectsWith(plane: TypeParsablePlane, precision?: number): Line | null;
153
+ /**
154
+ * `true` if line is parallel to plane.
155
+ *
156
+ * @param {TypeParsableLine} line
157
+ * @param {number} precision
158
+ * @return {boolean}
159
+ */
160
+ isParallelToLine(line: TypeParsableLine, precision?: number): boolean;
161
+ /**
162
+ * Returns the intersect point for a line (extended to infinity) with a plane.
163
+ * @param {TypeParsableLine} line
164
+ * @param {number} precision
165
+ * @return {Point | null} intersect point. `null` if the line does not
166
+ * intersect
167
+ */
168
+ lineIntersect(line: TypeParsableLine, precision?: number): Point | null;
169
+ /**
170
+ * `true` if a line lies within the plane
171
+ * @param {TypeParsableLine} line
172
+ * @param {number} precision
173
+ * @return {Point | null} intersect point. `null` if the line does not
174
+ * intersect
175
+ */
176
+ hasLineOn(line: TypeParsableLine, precision?: number): boolean;
177
+ /**
178
+ * Project a point onto the plane
179
+ * @param {TypeParsablePoint} p
180
+ * @return {Point}
181
+ */
182
+ pointProjection(p: TypeParsablePoint): Point;
183
+ /**
184
+ * Distance between plane and point
185
+ * @param {TypeParsablePoint} p
186
+ * @return {number}
187
+ */
188
+ distanceToPoint(p: TypeParsablePoint): number;
189
+ reflect(vector: TypeParsablePoint): Point;
190
+ }
191
+ /**
192
+ * Get plane created with three points.
193
+ *
194
+ * Normal is in the direction of the cross product of p12 and p13
195
+ * @param {TypeParsablePoint | [TypeParsablePoint, TypeParsablePoint, TypeParsablePoint]} p1OrPoints
196
+ * @param {TypeParsablePoint} p2
197
+ * @param {TypeParsablePoint} p3
198
+ * @group Misc Geometry
199
+ */
200
+ declare function getNormal(p1OrPoints: TypeParsablePoint | [TypeParsablePoint, TypeParsablePoint, TypeParsablePoint], p2?: null | TypeParsablePoint, p3?: null | TypeParsablePoint): Point;
201
+ export { isParsablePlane, Plane, getPlane, getNormal, };