curvy 2.0.0-alpha.16 → 2.0.0-alpha.18

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 (96) hide show
  1. package/dist/arc/arc.d.ts +277 -0
  2. package/dist/arc/arc.internal.d.ts +2 -0
  3. package/dist/arc/index.d.ts +2 -0
  4. package/dist/arc/index.mjs +165 -0
  5. package/dist/arc/index.mjs.map +1 -0
  6. package/dist/characteristic/index.mjs +1 -1
  7. package/dist/coordinates/coordinateSystem.d.ts +686 -0
  8. package/dist/coordinates/coordinateSystem.internal.d.ts +2 -0
  9. package/dist/coordinates/dimension.d.ts +346 -0
  10. package/dist/coordinates/dimension.internal.d.ts +2 -0
  11. package/dist/coordinates/index.d.ts +6 -0
  12. package/dist/coordinates/index.mjs +656 -0
  13. package/dist/coordinates/index.mjs.map +1 -0
  14. package/dist/curve/cubic2d.d.ts +46 -1
  15. package/dist/curve/curve2d.d.ts +8 -0
  16. package/dist/curve/index.mjs +2 -1
  17. package/dist/curve/linear2d.d.ts +15 -1
  18. package/dist/curve/quadratic2d.d.ts +15 -1
  19. package/dist/interval/index.mjs +2 -2
  20. package/dist/matrix/index.mjs +2 -2
  21. package/dist/number.d.ts +140 -1
  22. package/dist/number.mjs +154 -2
  23. package/dist/number.mjs.map +1 -1
  24. package/dist/path/cubic2d.d.ts +85 -0
  25. package/dist/path/index.mjs +4 -304
  26. package/dist/path/linear2d.d.ts +41 -0
  27. package/dist/path/path2d.d.ts +2 -0
  28. package/dist/path/quadratic2d.d.ts +42 -0
  29. package/dist/path/rationalCubic2d.d.ts +10 -6
  30. package/dist/piecewise/index.d.ts +4 -0
  31. package/dist/piecewise/index.mjs +410 -0
  32. package/dist/piecewise/index.mjs.map +1 -0
  33. package/dist/piecewise/piecewise.d.ts +388 -0
  34. package/dist/piecewise/piecewise.internal.d.ts +2 -0
  35. package/dist/piecewise/traits.d.ts +63 -0
  36. package/dist/polynomial/cubic.d.ts +14 -2
  37. package/dist/polynomial/index.mjs +2 -2
  38. package/dist/polynomial/linear.d.ts +14 -2
  39. package/dist/polynomial/polynomial.d.ts +47 -0
  40. package/dist/polynomial/quadratic.d.ts +14 -2
  41. package/dist/polynomial/traits.d.ts +11 -0
  42. package/dist/shared/{affine2d-Bpn5tc1u.mjs → affine2d-DUqbI9RP.mjs} +4 -4
  43. package/dist/shared/{affine2d-Bpn5tc1u.mjs.map → affine2d-DUqbI9RP.mjs.map} +1 -1
  44. package/dist/shared/arc.internal-DBLPlj56.mjs +138 -0
  45. package/dist/shared/arc.internal-DBLPlj56.mjs.map +1 -0
  46. package/dist/shared/{characteristic-DQNPi4wd.mjs → characteristic-OjEkAZBA.mjs} +3 -3
  47. package/dist/shared/{characteristic-DQNPi4wd.mjs.map → characteristic-OjEkAZBA.mjs.map} +1 -1
  48. package/dist/shared/{cubic-Bly8kxxo.mjs → cubic-CddsJ7ek.mjs} +62 -5
  49. package/dist/shared/cubic-CddsJ7ek.mjs.map +1 -0
  50. package/dist/shared/{rationalCubic2d-D9bMCQ8P.mjs → cubic2d-B6OVwHqs.mjs} +124 -424
  51. package/dist/shared/cubic2d-B6OVwHqs.mjs.map +1 -0
  52. package/dist/shared/{rationalCubic2d-D_TBd-3i.mjs → cubic2d-CnREttj6.mjs} +327 -945
  53. package/dist/shared/cubic2d-CnREttj6.mjs.map +1 -0
  54. package/dist/shared/{interval-Dv6eHXJH.mjs → interval-8-erxD4h.mjs} +2 -2
  55. package/dist/shared/{interval-Dv6eHXJH.mjs.map → interval-8-erxD4h.mjs.map} +1 -1
  56. package/dist/shared/{interval2d-B8wt0szh.mjs → interval2d-BCabpCmV.mjs} +3 -3
  57. package/dist/shared/{interval2d-B8wt0szh.mjs.map → interval2d-BCabpCmV.mjs.map} +1 -1
  58. package/dist/shared/linear2d-B01Cuo06.mjs +326 -0
  59. package/dist/shared/linear2d-B01Cuo06.mjs.map +1 -0
  60. package/dist/shared/{matrix3x3.internal-CFbYATcm.mjs → matrix3x3.internal-BW6BMirB.mjs} +4 -4
  61. package/dist/shared/{matrix3x3.internal-CFbYATcm.mjs.map → matrix3x3.internal-BW6BMirB.mjs.map} +1 -1
  62. package/dist/shared/{matrix4x4-DNcb1l5T.mjs → matrix4x4-Cq_UJZNO.mjs} +3 -3
  63. package/dist/shared/{matrix4x4-DNcb1l5T.mjs.map → matrix4x4-Cq_UJZNO.mjs.map} +1 -1
  64. package/dist/shared/{quadratic-BBQDu0at.mjs → quadratic-CvvVVM5r.mjs} +29 -3
  65. package/dist/shared/quadratic-CvvVVM5r.mjs.map +1 -0
  66. package/dist/shared/quadratic2d-CdwZ28Rg.mjs +326 -0
  67. package/dist/shared/quadratic2d-CdwZ28Rg.mjs.map +1 -0
  68. package/dist/shared/rationalCubic2d-A7ZkG9_r.mjs +103 -0
  69. package/dist/shared/rationalCubic2d-A7ZkG9_r.mjs.map +1 -0
  70. package/dist/shared/rationalCubic2d-CXTogOPX.mjs +723 -0
  71. package/dist/shared/rationalCubic2d-CXTogOPX.mjs.map +1 -0
  72. package/dist/shared/{solution-Cgq_KclT.mjs → solution-Bi6zCdQH.mjs} +3 -3
  73. package/dist/shared/{solution-Cgq_KclT.mjs.map → solution-Bi6zCdQH.mjs.map} +1 -1
  74. package/dist/shared/{vector2-CrUOYb3v.mjs → vector2-BzDphAEw.mjs} +9 -7
  75. package/dist/shared/vector2-BzDphAEw.mjs.map +1 -0
  76. package/dist/shared/{vector2.internal-rPnW0RCx.mjs → vector2.internal-B42hdbQr.mjs} +2 -2
  77. package/dist/shared/{vector2.internal-rPnW0RCx.mjs.map → vector2.internal-B42hdbQr.mjs.map} +1 -1
  78. package/dist/shared/{vector3-CFL7Yx16.mjs → vector3--DNTuqZ-.mjs} +7 -5
  79. package/dist/shared/vector3--DNTuqZ-.mjs.map +1 -0
  80. package/dist/shared/{vector3.internal-CfWHl9SG.mjs → vector3.internal-DRO121Di.mjs} +2 -2
  81. package/dist/shared/{vector3.internal-CfWHl9SG.mjs.map → vector3.internal-DRO121Di.mjs.map} +1 -1
  82. package/dist/solution/index.mjs +1 -1
  83. package/dist/splines/index.mjs +13 -10
  84. package/dist/splines/index.mjs.map +1 -1
  85. package/dist/transform/index.mjs +1 -1
  86. package/dist/vector/index.mjs +2 -2
  87. package/dist/vector/vector2.d.ts +7 -5
  88. package/dist/vector/vector3.d.ts +6 -4
  89. package/package.json +13 -1
  90. package/dist/path/index.mjs.map +0 -1
  91. package/dist/shared/cubic-Bly8kxxo.mjs.map +0 -1
  92. package/dist/shared/quadratic-BBQDu0at.mjs.map +0 -1
  93. package/dist/shared/rationalCubic2d-D9bMCQ8P.mjs.map +0 -1
  94. package/dist/shared/rationalCubic2d-D_TBd-3i.mjs.map +0 -1
  95. package/dist/shared/vector2-CrUOYb3v.mjs.map +0 -1
  96. package/dist/shared/vector3-CFL7Yx16.mjs.map +0 -1
@@ -0,0 +1,686 @@
1
+ import type { Bounds } from '../interval/interval.ts';
2
+ import type { CubicPath2d } from '../path/cubic2d.ts';
3
+ import type { RationalCubicPath2d } from '../path/rationalCubic2d.ts';
4
+ import type { Pipeable } from '../utils.ts';
5
+ import type { Vector2 } from '../vector/vector2.ts';
6
+ import type { CoordinateSystemTypeId } from './coordinateSystem.internal.ts';
7
+ import type { Cyclical, Dimension } from './dimension.ts';
8
+ /**
9
+ * A chart map from a two-axis chart space onto the cartesian plane:
10
+ * `Cartesian` is the identity, and `Polar` reads chart points as
11
+ * `(theta, r)` around a center. Layout code positions rectangles in chart
12
+ * space; the system converts points with `toCartesian`, constructs the
13
+ * exact cartesian images of chart-aligned shapes with `arc` and `sector`,
14
+ * and constructs tolerance-bounded images of arbitrary chart paths with
15
+ * `image`.
16
+ *
17
+ * The polar map is nonlinear, so it does not commute with control-point
18
+ * mapping: converting a curve's control points with `toCartesian` produces
19
+ * the wrong curve. Convert points pointwise, convert axis-aligned shapes
20
+ * with the exact constructors, and convert arbitrary paths with `image`.
21
+ *
22
+ * Operations stay total over the union wherever both kinds have an honest
23
+ * reading — `Cartesian` answers the shape constructors with the chart
24
+ * shapes themselves. Where only a polar system gives a question meaning,
25
+ * like the scalar maps `mapAngle` and `mapRadius`, the operation narrows
26
+ * its parameter to `Polar` instead of inventing a cartesian answer.
27
+ *
28
+ * @since 2.0.0
29
+ */
30
+ export type CoordinateSystem = Cartesian | Polar;
31
+ /**
32
+ * The on-screen rotation direction of increasing chart angle in an SVG
33
+ * viewport, where the y axis points down. `'clockwise'` means increasing
34
+ * theta rotates `+x` toward `+y` — the CSS and SVG positive-angle
35
+ * convention, and the same numbers `Vector2.fromPolar` produces.
36
+ * `'counterclockwise'` negates the angle.
37
+ *
38
+ * @since 2.0.0
39
+ */
40
+ export type Winding = 'clockwise' | 'counterclockwise';
41
+ /**
42
+ * The identity chart map: chart space is the cartesian plane itself. Its
43
+ * shape constructors still work — `arc` is a horizontal segment, `ray` a
44
+ * vertical one, and `sector` an axis-aligned rectangle — so code driving
45
+ * a `CoordinateSystem` through the shared operations never branches on
46
+ * kind. Only the polar-specific scalar maps require narrowing first.
47
+ *
48
+ * @since 2.0.0
49
+ */
50
+ export interface Cartesian extends Pipeable {
51
+ readonly [CoordinateSystemTypeId]: CoordinateSystemTypeId;
52
+ readonly kind: 'cartesian';
53
+ }
54
+ /**
55
+ * A polar chart map. Chart points are `(theta, r)`: `x` is the angular
56
+ * coordinate on the `theta` axis, `y` is the radial coordinate through the
57
+ * `radius` map. The mapped point is
58
+ * `center + mappedRadius * (cos(angle), sin(angle))`.
59
+ *
60
+ * @since 2.0.0
61
+ */
62
+ export interface Polar extends Pipeable {
63
+ readonly [CoordinateSystemTypeId]: CoordinateSystemTypeId;
64
+ readonly kind: 'polar';
65
+ /**
66
+ * The cartesian point where mapped radius `0` sits.
67
+ */
68
+ readonly center: Vector2;
69
+ /**
70
+ * The angular axis. Its period is the angular unit: one full turn of
71
+ * chart angle. See the `Dimension.radians`, `Dimension.degrees`, and
72
+ * `Dimension.turns` constants.
73
+ */
74
+ readonly theta: Cyclical;
75
+ /**
76
+ * The on-screen direction of increasing chart angle.
77
+ */
78
+ readonly winding: Winding;
79
+ /**
80
+ * The radial axis map. Today this is always a `Linear` dimension —
81
+ * mapped radius is `r * scale + offset`, and an offset shifts chart
82
+ * radius `0` outward, which puts an inner hole under a chart that
83
+ * starts at `r = 0`.
84
+ *
85
+ * The field is typed as the full `Dimension` union so future radial-map
86
+ * kinds can arrive without breaking readers. Apply the map with
87
+ * `mapRadius` rather than reading `scale` and `offset` off the field.
88
+ */
89
+ readonly radius: Dimension;
90
+ /**
91
+ * Where chart angle `0` points, as a rotation from the `+x` direction
92
+ * measured in the angular unit, positive rotating `+x` toward `+y`.
93
+ * Anchored on screen independent of `winding`, so `-90` on a degrees
94
+ * axis is 12 o'clock whichever way the system sweeps.
95
+ */
96
+ readonly thetaOrigin: number;
97
+ }
98
+ /**
99
+ * Configuration for `polar`. Every field is optional; the defaults give a
100
+ * radians-based polar system centered on the origin.
101
+ *
102
+ * @since 2.0.0
103
+ */
104
+ export interface PolarConfig {
105
+ /**
106
+ * The cartesian point where mapped radius `0` sits. Defaults to the
107
+ * origin.
108
+ */
109
+ readonly center?: Vector2;
110
+ /**
111
+ * The angular axis, whose period is the angular unit. Defaults to
112
+ * `Dimension.radians`.
113
+ */
114
+ readonly theta?: Cyclical;
115
+ /**
116
+ * The on-screen direction of increasing chart angle. Defaults to
117
+ * `'clockwise'`.
118
+ */
119
+ readonly winding?: Winding;
120
+ /**
121
+ * The radial axis map applied to chart radii. Must be a `Linear`
122
+ * dimension — the union type reserves room for future radial-map
123
+ * kinds, and `polar` rejects a `Cyclical` radius. Defaults to
124
+ * `Dimension.identity`.
125
+ */
126
+ readonly radius?: Dimension;
127
+ /**
128
+ * Where chart angle `0` points, as a rotation from the `+x` direction
129
+ * measured in the angular unit, positive rotating `+x` toward `+y` and
130
+ * independent of `winding`. Defaults to `0` (3 o'clock on screen).
131
+ */
132
+ readonly thetaOrigin?: number;
133
+ }
134
+ /**
135
+ * Checks if a value is a `CoordinateSystem`.
136
+ *
137
+ * @param v - The value to check.
138
+ * @returns `true` if the value is a `CoordinateSystem`, `false` otherwise.
139
+ * @since 2.0.0
140
+ */
141
+ export declare const isCoordinateSystem: (v: unknown) => v is CoordinateSystem;
142
+ /**
143
+ * Checks if a `CoordinateSystem` is `Cartesian`.
144
+ *
145
+ * @param s - The system to check.
146
+ * @returns `true` if the system is `Cartesian`, `false` otherwise.
147
+ * @since 2.0.0
148
+ */
149
+ export declare const isCartesian: (s: CoordinateSystem) => s is Cartesian;
150
+ /**
151
+ * Checks if a `CoordinateSystem` is `Polar`.
152
+ *
153
+ * @param s - The system to check.
154
+ * @returns `true` if the system is `Polar`, `false` otherwise.
155
+ * @since 2.0.0
156
+ */
157
+ export declare const isPolar: (s: CoordinateSystem) => s is Polar;
158
+ /**
159
+ * The identity system: chart space is the cartesian plane.
160
+ *
161
+ * @since 2.0.0
162
+ */
163
+ export declare const cartesian: Cartesian;
164
+ /**
165
+ * Creates a `Polar` system.
166
+ *
167
+ * @param config - Center, angular axis, winding, radial map, and angular
168
+ * origin. All optional; see `PolarConfig` for the defaults.
169
+ * @returns A new `Polar` system.
170
+ * @throws `Error` when `thetaOrigin` is not finite, or when `radius` is
171
+ * not a `Linear` dimension.
172
+ * @since 2.0.0
173
+ * @example
174
+ * ```ts
175
+ * // Degrees around (200, 200), chart zero at 12 o'clock, with a 40px
176
+ * // hole under chart radius 0:
177
+ * const system = CoordinateSystem.polar({
178
+ * center: Vector2.make(200, 200),
179
+ * theta: Dimension.degrees,
180
+ * thetaOrigin: -90,
181
+ * radius: Dimension.linear(1, 40),
182
+ * })
183
+ * ```
184
+ */
185
+ export declare const polar: (config?: PolarConfig) => Polar;
186
+ export declare const equals: {
187
+ /**
188
+ * Checks two `CoordinateSystem` values for equality: the kinds match,
189
+ * and for polar systems the centers, windings, angular axes, and radial
190
+ * maps agree. Numeric fields compare within the tolerance of
191
+ * `coincident` from `curvy/number`.
192
+ *
193
+ * @param a - The first system.
194
+ * @param b - The second system.
195
+ * @returns `true` if the systems are equal, `false` otherwise.
196
+ * @since 2.0.0
197
+ */
198
+ (a: CoordinateSystem, b: CoordinateSystem): boolean;
199
+ /**
200
+ * Checks two `CoordinateSystem` values for equality.
201
+ *
202
+ * @param b - The system to compare against.
203
+ * @returns A function that takes a system and returns whether the two
204
+ * are equal.
205
+ * @since 2.0.0
206
+ */
207
+ (b: CoordinateSystem): (a: CoordinateSystem) => boolean;
208
+ };
209
+ export declare const toCartesian: {
210
+ /**
211
+ * Maps a chart-space point onto the cartesian plane. On a polar system
212
+ * the point is read as `(theta, r)` — `point.x` on the angular axis,
213
+ * `point.y` through the radial map — and lands at
214
+ * `center + mappedRadius * (cos(angle), sin(angle))`. A negative mapped
215
+ * radius reflects through the center, the standard polar convention. On
216
+ * a cartesian system the point is returned unchanged.
217
+ *
218
+ * The arithmetic is exact IEEE 754 trig with no rounding or snapping;
219
+ * see `PRECISION.md`.
220
+ *
221
+ * @param s - The coordinate system.
222
+ * @param point - The chart-space point.
223
+ * @returns The cartesian image of the point.
224
+ * @since 2.0.0
225
+ */
226
+ (s: CoordinateSystem, point: Vector2): Vector2;
227
+ /**
228
+ * Maps a chart-space point onto the cartesian plane.
229
+ *
230
+ * @param point - The chart-space point.
231
+ * @returns A function that takes a system and returns the cartesian
232
+ * image.
233
+ * @since 2.0.0
234
+ */
235
+ (point: Vector2): (s: CoordinateSystem) => Vector2;
236
+ };
237
+ export declare const fromCartesian: {
238
+ /**
239
+ * Maps a cartesian point back into chart space. On a polar system the
240
+ * result packs `(theta, r)` into `(x, y)`, with `theta` wrapped to
241
+ * `[0, period)` and `r` sent back through the inverse radial map. At the
242
+ * exact center the angle is `0`. On a cartesian system the point is
243
+ * returned unchanged.
244
+ *
245
+ * Round-trips with `toCartesian` up to angle wrapping: a chart angle
246
+ * comes back as its canonical representative, and a negative chart
247
+ * radius comes back positive with the angle turned half a period.
248
+ *
249
+ * @param s - The coordinate system.
250
+ * @param point - The cartesian point.
251
+ * @returns The chart-space point `(theta, r)`.
252
+ * @since 2.0.0
253
+ */
254
+ (s: CoordinateSystem, point: Vector2): Vector2;
255
+ /**
256
+ * Maps a cartesian point back into chart space.
257
+ *
258
+ * @param point - The cartesian point.
259
+ * @returns A function that takes a system and returns the chart-space
260
+ * point.
261
+ * @since 2.0.0
262
+ */
263
+ (point: Vector2): (s: CoordinateSystem) => Vector2;
264
+ };
265
+ export declare const mapAngle: {
266
+ /**
267
+ * Maps a chart-space angular coordinate to its on-screen angle in
268
+ * radians, positive rotating `+x` toward `+y`. This is the angular half
269
+ * of `toCartesian`: `(thetaOrigin + sign * theta) * (2*pi / period)`,
270
+ * where `sign` is `+1` for a `'clockwise'` winding and `-1` for
271
+ * `'counterclockwise'`.
272
+ *
273
+ * The result is not wrapped. A chart angle past one period keeps
274
+ * accumulating turns, so differences of mapped angles are mapped
275
+ * sweeps.
276
+ *
277
+ * Only a polar system has an angular axis, so the parameter narrows to
278
+ * `Polar`; refine with `isPolar` first when holding the union.
279
+ *
280
+ * @param s - The polar system whose angular map to apply.
281
+ * @param theta - The chart-space angular coordinate, in the unit of the
282
+ * system's `theta` axis.
283
+ * @returns The on-screen angle in radians.
284
+ * @since 2.0.0
285
+ * @example
286
+ * ```ts
287
+ * // Rotate a tick label to its angular position (SVG rotate() wants
288
+ * // degrees):
289
+ * const angle = CoordinateSystem.mapAngle(system, 45)
290
+ * const transform = `rotate(${(180 / Math.PI) * angle})`
291
+ * ```
292
+ */
293
+ (s: Polar, theta: number): number;
294
+ /**
295
+ * Maps a chart-space angular coordinate to its on-screen angle in
296
+ * radians.
297
+ *
298
+ * @param theta - The chart-space angular coordinate, in the unit of the
299
+ * system's `theta` axis.
300
+ * @returns A function that takes a polar system and returns the
301
+ * on-screen angle in radians.
302
+ * @since 2.0.0
303
+ */
304
+ (theta: number): (s: Polar) => number;
305
+ };
306
+ export declare const mapRadius: {
307
+ /**
308
+ * Maps a chart-space radial coordinate to its on-screen distance from
309
+ * the center. This is the radial half of `toCartesian`:
310
+ * `r * scale + offset` under today's always-linear radial axis.
311
+ *
312
+ * The result can be negative when the map sends the chart radius below
313
+ * zero. Point-mapping operations read a negative mapped radius as a
314
+ * reflection through the center; shape constructors like `arc` and
315
+ * `sector` reject it.
316
+ *
317
+ * Only a polar system has a radial axis, so the parameter narrows to
318
+ * `Polar`; refine with `isPolar` first when holding the union.
319
+ *
320
+ * @param s - The polar system whose radial map to apply.
321
+ * @param r - The chart-space radial coordinate.
322
+ * @returns The signed on-screen distance from the center.
323
+ * @since 2.0.0
324
+ * @example
325
+ * ```ts
326
+ * // mapRadius maps positions, not lengths. A chart-space length maps
327
+ * // through the difference, where the offset cancels:
328
+ * const bandWidth =
329
+ * CoordinateSystem.mapRadius(system, 3.5) -
330
+ * CoordinateSystem.mapRadius(system, 3)
331
+ * ```
332
+ */
333
+ (s: Polar, r: number): number;
334
+ /**
335
+ * Maps a chart-space radial coordinate to its on-screen distance from
336
+ * the center.
337
+ *
338
+ * @param r - The chart-space radial coordinate.
339
+ * @returns A function that takes a polar system and returns the signed
340
+ * on-screen distance.
341
+ * @since 2.0.0
342
+ */
343
+ (r: number): (s: Polar) => number;
344
+ };
345
+ export declare const arc: {
346
+ /**
347
+ * Constructs the exact cartesian image of the chart-space segment that
348
+ * holds `r` fixed and runs `theta` from `theta.start` to `theta.end`.
349
+ * On a polar system that image is a circular arc, built from rational
350
+ * cubic segments of at most a quarter turn each, exact up to IEEE 754
351
+ * rounding. On a cartesian system it is a single straight segment.
352
+ *
353
+ * `theta` is a structural bounds value, and direction matters:
354
+ * `start > end` sweeps the other way. A sweep past one full period keeps
355
+ * going around, tracing the circle more than once.
356
+ *
357
+ * @param s - The coordinate system.
358
+ * @param theta - The angular span, in either order.
359
+ * @param r - The fixed radial coordinate.
360
+ * @returns The image as a `RationalCubicPath2d`.
361
+ * @throws `Error` when an input is not finite, or when the mapped radius
362
+ * is negative.
363
+ * @since 2.0.0
364
+ * @example
365
+ * ```ts
366
+ * // A quarter circle of radius 100 from 3 o'clock to 6 o'clock:
367
+ * const path = CoordinateSystem.arc(
368
+ * CoordinateSystem.polar({ theta: Dimension.degrees }),
369
+ * { start: 0, end: 90 },
370
+ * 100,
371
+ * )
372
+ * ```
373
+ */
374
+ (s: CoordinateSystem, theta: Bounds, r: number): RationalCubicPath2d;
375
+ /**
376
+ * Constructs the exact cartesian image of a fixed-radius angular span.
377
+ *
378
+ * @param theta - The angular span, in either order.
379
+ * @param r - The fixed radial coordinate.
380
+ * @returns A function that takes a system and returns the image path.
381
+ * @since 2.0.0
382
+ */
383
+ (theta: Bounds, r: number): (s: CoordinateSystem) => RationalCubicPath2d;
384
+ };
385
+ export declare const ray: {
386
+ /**
387
+ * Constructs the exact cartesian image of the chart-space segment that
388
+ * holds `theta` fixed and runs `r` from `r.start` to `r.end`. On a polar
389
+ * system that image is a straight segment along the fixed direction —
390
+ * the radial map is affine, so the image is exact, a single rational
391
+ * line segment. On a cartesian system it is the vertical segment at
392
+ * `x = theta`.
393
+ *
394
+ * Unlike `arc` and `sector`, negative mapped radii are allowed: a
395
+ * negative mapped radius reflects through the center, the same
396
+ * convention `toCartesian` applies, and a radial span whose mapped
397
+ * radii change sign stays one straight segment passing through the
398
+ * center. A zero-length span is constructible and degenerates to a
399
+ * point segment.
400
+ *
401
+ * @param s - The coordinate system.
402
+ * @param theta - The fixed angular coordinate.
403
+ * @param r - The radial span, traced from `start` to `end`.
404
+ * @returns The image as a `RationalCubicPath2d` of one segment.
405
+ * @throws `Error` when an input is not finite.
406
+ * @since 2.0.0
407
+ * @example
408
+ * ```ts
409
+ * // A radial gridline from the hole to the rim at 3 o'clock:
410
+ * const gridline = CoordinateSystem.ray(
411
+ * CoordinateSystem.polar({ theta: Dimension.degrees }),
412
+ * 0,
413
+ * { start: 80, end: 120 },
414
+ * )
415
+ * ```
416
+ */
417
+ (s: CoordinateSystem, theta: number, r: Bounds): RationalCubicPath2d;
418
+ /**
419
+ * Constructs the exact cartesian image of a fixed-angle radial span.
420
+ *
421
+ * @param theta - The fixed angular coordinate.
422
+ * @param r - The radial span, traced from `start` to `end`.
423
+ * @returns A function that takes a system and returns the image path.
424
+ * @since 2.0.0
425
+ */
426
+ (theta: number, r: Bounds): (s: CoordinateSystem) => RationalCubicPath2d;
427
+ };
428
+ export declare const sector: {
429
+ /**
430
+ * Constructs the exact cartesian image of the axis-aligned chart
431
+ * rectangle `theta x r` as a single closed path. On a polar system that
432
+ * image is an annular sector: the outer arc, a radial edge inward, the
433
+ * inner arc swept back, and a radial edge out. On a cartesian system it
434
+ * is the rectangle.
435
+ *
436
+ * Radii are normalized so the smaller mapped radius is the inner one.
437
+ * Sweeps past one full period clamp to a full turn. Degenerate inputs
438
+ * stay constructible: a zero sweep or zero radial width produces a slit
439
+ * path, an inner radius of `0` produces a pie slice with no inner arc,
440
+ * and a full-turn sweep produces a ring whose two radial edges coincide.
441
+ * For SVG output of a full-turn ring use `sectorPathData`, which emits a
442
+ * clean two-subpath annulus instead.
443
+ *
444
+ * @param s - The coordinate system.
445
+ * @param theta - The angular span, in either order.
446
+ * @param r - The radial span, in either order.
447
+ * @returns The closed image as a `RationalCubicPath2d`.
448
+ * @throws `Error` when an input is not finite, or when a mapped radius
449
+ * is negative.
450
+ * @since 2.0.0
451
+ * @example
452
+ * ```ts
453
+ * // The image of a layout rect spanning 30..90 degrees, 80..120px:
454
+ * const ring = CoordinateSystem.sector(
455
+ * CoordinateSystem.polar({ theta: Dimension.degrees }),
456
+ * { start: 30, end: 90 },
457
+ * { start: 80, end: 120 },
458
+ * )
459
+ * ```
460
+ */
461
+ (s: CoordinateSystem, theta: Bounds, r: Bounds): RationalCubicPath2d;
462
+ /**
463
+ * Constructs the exact cartesian image of an axis-aligned chart
464
+ * rectangle.
465
+ *
466
+ * @param theta - The angular span, in either order.
467
+ * @param r - The radial span, in either order.
468
+ * @returns A function that takes a system and returns the closed image
469
+ * path.
470
+ * @since 2.0.0
471
+ */
472
+ (theta: Bounds, r: Bounds): (s: CoordinateSystem) => RationalCubicPath2d;
473
+ };
474
+ export declare const containsPoint: {
475
+ /**
476
+ * Checks whether a cartesian point lies inside the image of the
477
+ * axis-aligned chart rectangle `theta x r` — the same region `sector`
478
+ * constructs. The point is converted with `fromCartesian` and tested
479
+ * per axis: the angular test follows `Dimension.containsApprox`
480
+ * (directed sweep, band `EPSILON * period`), and the radial and
481
+ * cartesian-rectangle tests treat a coordinate coincident with an edge
482
+ * as inside, so boundary verdicts hold at any data magnitude.
483
+ *
484
+ * At the exact center the angle is degenerate and the radial test alone
485
+ * decides: the center belongs to a sector exactly when the sector
486
+ * reaches mapped radius `0`.
487
+ *
488
+ * @param s - The coordinate system.
489
+ * @param theta - The angular span, directed like `sector`'s.
490
+ * @param r - The radial span, in either order.
491
+ * @param point - The cartesian point to test.
492
+ * @returns `true` if the point is inside the sector, `false` otherwise.
493
+ * @throws `Error` when a bound is not finite.
494
+ * @since 2.0.0
495
+ * @example
496
+ * ```ts
497
+ * // Pointer hit-testing a ring segment:
498
+ * CoordinateSystem.containsPoint(
499
+ * system,
500
+ * { start: 30, end: 90 },
501
+ * { start: 80, end: 120 },
502
+ * Vector2.make(pointerX, pointerY),
503
+ * )
504
+ * ```
505
+ */
506
+ (s: CoordinateSystem, theta: Bounds, r: Bounds, point: Vector2): boolean;
507
+ /**
508
+ * Checks whether a cartesian point lies inside the image of an
509
+ * axis-aligned chart rectangle.
510
+ *
511
+ * @param theta - The angular span, directed like `sector`'s.
512
+ * @param r - The radial span, in either order.
513
+ * @param point - The cartesian point to test.
514
+ * @returns A function that takes a system and returns whether the point
515
+ * is inside.
516
+ * @since 2.0.0
517
+ */
518
+ (theta: Bounds, r: Bounds, point: Vector2): (s: CoordinateSystem) => boolean;
519
+ };
520
+ export declare const image: {
521
+ /**
522
+ * Constructs the cartesian image of an arbitrary chart-space path,
523
+ * accurate to within `tolerance`. On a polar system the map is nonlinear
524
+ * and the true image is transcendental — a straight chart segment images
525
+ * to an Archimedean spiral — so no cubic path equals it exactly. The
526
+ * result is certified to a symmetric Hausdorff bound: every point of the
527
+ * true image lies within `tolerance` of the output, and every point of
528
+ * the output lies within `tolerance` of the true image, verified by
529
+ * subdivision enclosures rather than point samples (see `PRECISION.md`).
530
+ * On a cartesian system the path is returned unchanged.
531
+ *
532
+ * The path is read pointwise like `toCartesian`: each point `(x, y)` as
533
+ * `(theta, r)`, a negative mapped radius reflecting through the center.
534
+ * A path crossing mapped radius `0` images straight through the center;
535
+ * the bound holds there at the cost of more segments nearby. Sweeps past
536
+ * one full period keep going around, like `arc`. Emitted segments start
537
+ * and end exactly on the true image, so a continuous input's output
538
+ * junctions close; reassert the brand with `CubicPath2d.asContinuous`
539
+ * where needed.
540
+ *
541
+ * For axis-aligned chart shapes prefer `arc` and `sector`, whose images
542
+ * are exact. For SVG output pass the result to `CubicPath2d.toPathData`.
543
+ * Certification cost grows roughly with the ratio of the image's size to
544
+ * `tolerance`, so pixel-scale tolerances for screen output are the
545
+ * intended regime; vanishingly small tolerances get expensive before
546
+ * they get wrong.
547
+ *
548
+ * @param s - The coordinate system.
549
+ * @param path - The chart-space path, each point read as `(theta, r)`.
550
+ * @param tolerance - Maximum allowed Hausdorff distance, in cartesian
551
+ * output units. Must be positive.
552
+ * @returns The image as a `CubicPath2d` within `tolerance` of the true
553
+ * image.
554
+ * @throws `Error` when `tolerance` is not a positive finite number.
555
+ * @since 2.0.0
556
+ * @example
557
+ * ```ts
558
+ * // The polar image of a rising chart-space line is an Archimedean
559
+ * // spiral; approximate to a quarter pixel and emit SVG:
560
+ * const system = CoordinateSystem.polar({ theta: Dimension.turns })
561
+ * const chartPath = Bezier2d.toPath(Bezier2d.make(
562
+ * Vector2.make(0, 0),
563
+ * Vector2.make(1, 40),
564
+ * Vector2.make(2, 80),
565
+ * Vector2.make(3, 120),
566
+ * ))
567
+ * const d = CubicPath2d.toPathData(
568
+ * CoordinateSystem.image(system, chartPath, 0.25),
569
+ * )
570
+ * ```
571
+ */
572
+ (s: CoordinateSystem, path: CubicPath2d, tolerance: number): CubicPath2d;
573
+ /**
574
+ * Constructs the cartesian image of an arbitrary chart-space path.
575
+ *
576
+ * @param path - The chart-space path, each point read as `(theta, r)`.
577
+ * @param tolerance - Maximum allowed Hausdorff distance, in cartesian
578
+ * output units. Must be positive.
579
+ * @returns A function that takes a system and returns the image path.
580
+ * @since 2.0.0
581
+ */
582
+ (path: CubicPath2d, tolerance: number): (s: CoordinateSystem) => CubicPath2d;
583
+ };
584
+ export declare const arcPathData: {
585
+ /**
586
+ * Emits exact SVG path data for the same shape `arc` constructs, using
587
+ * `A` commands computed from the chart description. Pieces stay at or
588
+ * under a half turn, so the large-arc flag is always `0`; the sweep flag
589
+ * is `1` for a positive mapped sweep, which renders clockwise in an SVG
590
+ * viewport's y-down coordinates.
591
+ *
592
+ * Degenerate contracts:
593
+ * - zero sweep, or mapped radius `0`: an `M` command alone, which
594
+ * renders nothing
595
+ * - a full-period sweep: the circle as two half-turn `A` commands,
596
+ * closing on the exact starting coordinates
597
+ * - a sweep past one period: clamped to one full circle
598
+ *
599
+ * @param s - The coordinate system.
600
+ * @param theta - The angular span, in either order.
601
+ * @param r - The fixed radial coordinate.
602
+ * @returns The SVG path data string.
603
+ * @throws `Error` when an input is not finite, or when the mapped radius
604
+ * is negative.
605
+ * @since 2.0.0
606
+ */
607
+ (s: CoordinateSystem, theta: Bounds, r: number): string;
608
+ /**
609
+ * Emits exact SVG path data for a fixed-radius angular span.
610
+ *
611
+ * @param theta - The angular span, in either order.
612
+ * @param r - The fixed radial coordinate.
613
+ * @returns A function that takes a system and returns the path data.
614
+ * @since 2.0.0
615
+ */
616
+ (theta: Bounds, r: number): (s: CoordinateSystem) => string;
617
+ };
618
+ export declare const rayPathData: {
619
+ /**
620
+ * Emits exact SVG path data for the same segment `ray` constructs: an
621
+ * `M` to the mapped start of the radial span and an `L` to its mapped
622
+ * end. Negative mapped radii follow `ray`'s reflection convention.
623
+ *
624
+ * Degenerate contract: a zero-length radial span (`r.start === r.end`)
625
+ * emits an `M` command alone, which renders nothing.
626
+ *
627
+ * @param s - The coordinate system.
628
+ * @param theta - The fixed angular coordinate.
629
+ * @param r - The radial span, traced from `start` to `end`.
630
+ * @returns The SVG path data string.
631
+ * @throws `Error` when an input is not finite.
632
+ * @since 2.0.0
633
+ */
634
+ (s: CoordinateSystem, theta: number, r: Bounds): string;
635
+ /**
636
+ * Emits exact SVG path data for a fixed-angle radial span.
637
+ *
638
+ * @param theta - The fixed angular coordinate.
639
+ * @param r - The radial span, traced from `start` to `end`.
640
+ * @returns A function that takes a system and returns the path data.
641
+ * @since 2.0.0
642
+ */
643
+ (theta: number, r: Bounds): (s: CoordinateSystem) => string;
644
+ };
645
+ export declare const sectorPathData: {
646
+ /**
647
+ * Emits exact SVG path data for the same shape `sector` constructs,
648
+ * using `A` commands computed from the chart description.
649
+ *
650
+ * Degenerate contracts:
651
+ * - zero sweep: a radial slit, `M`, `L`, `Z`
652
+ * - zero radial width: the arc followed by `Z`
653
+ * - inner radius `0`: a pie slice closed through the center
654
+ * - a full-period sweep: an annulus as two opposite-winding subpaths,
655
+ * which fills with a hole under both the `nonzero` default and
656
+ * `evenodd`; with inner radius `0` it collapses to one disc subpath
657
+ * - a sweep past one period: clamped to a full turn
658
+ *
659
+ * @param s - The coordinate system.
660
+ * @param theta - The angular span, in either order.
661
+ * @param r - The radial span, in either order.
662
+ * @returns The SVG path data string.
663
+ * @throws `Error` when an input is not finite, or when a mapped radius
664
+ * is negative.
665
+ * @since 2.0.0
666
+ * @example
667
+ * ```ts
668
+ * // d attribute for a ring segment, ready for <path d={...}>:
669
+ * const d = CoordinateSystem.sectorPathData(
670
+ * CoordinateSystem.polar({ theta: Dimension.turns }),
671
+ * { start: 0, end: 0.25 },
672
+ * { start: 80, end: 120 },
673
+ * )
674
+ * ```
675
+ */
676
+ (s: CoordinateSystem, theta: Bounds, r: Bounds): string;
677
+ /**
678
+ * Emits exact SVG path data for an axis-aligned chart rectangle.
679
+ *
680
+ * @param theta - The angular span, in either order.
681
+ * @param r - The radial span, in either order.
682
+ * @returns A function that takes a system and returns the path data.
683
+ * @since 2.0.0
684
+ */
685
+ (theta: Bounds, r: Bounds): (s: CoordinateSystem) => string;
686
+ };
@@ -0,0 +1,2 @@
1
+ export declare const CoordinateSystemTypeId: unique symbol;
2
+ export type CoordinateSystemTypeId = typeof CoordinateSystemTypeId;