@ac-kit/math-geometry 0.2.2 → 0.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.
- package/CHANGELOG.md +228 -0
- package/README.md +323 -52
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_ear-clipping.d.ts +20 -0
- package/dist/_ear-clipping.d.ts.map +1 -0
- package/dist/_ear-clipping.js +360 -0
- package/dist/_ear-clipping.js.map +1 -0
- package/dist/_ray3-intersect.d.ts +19 -0
- package/dist/_ray3-intersect.d.ts.map +1 -0
- package/dist/_ray3-intersect.js +122 -0
- package/dist/_ray3-intersect.js.map +1 -0
- package/dist/box2-array-boundary.d.ts +50 -0
- package/dist/box2-array-boundary.d.ts.map +1 -0
- package/dist/box2-array-boundary.js +97 -0
- package/dist/box2-array-boundary.js.map +1 -0
- package/dist/box2-array.d.ts +42 -0
- package/dist/box2-array.d.ts.map +1 -0
- package/dist/box2-array.js +134 -0
- package/dist/box2-array.js.map +1 -0
- package/dist/box2-componentwise.d.ts +110 -0
- package/dist/box2-componentwise.d.ts.map +1 -0
- package/dist/box2-componentwise.js +325 -0
- package/dist/box2-componentwise.js.map +1 -0
- package/dist/box2-grid-index.d.ts +67 -0
- package/dist/box2-grid-index.d.ts.map +1 -0
- package/dist/box2-grid-index.js +198 -0
- package/dist/box2-grid-index.js.map +1 -0
- package/dist/box2-record.d.ts +83 -0
- package/dist/box2-record.d.ts.map +1 -0
- package/dist/box2-record.js +124 -0
- package/dist/box2-record.js.map +1 -0
- package/dist/box2.d.ts +38 -0
- package/dist/box2.d.ts.map +1 -0
- package/dist/box2.js +97 -0
- package/dist/box2.js.map +1 -0
- package/dist/box3-array-boundary.d.ts +50 -0
- package/dist/box3-array-boundary.d.ts.map +1 -0
- package/dist/box3-array-boundary.js +107 -0
- package/dist/box3-array-boundary.js.map +1 -0
- package/dist/box3-componentwise.d.ts +110 -0
- package/dist/box3-componentwise.d.ts.map +1 -0
- package/dist/box3-componentwise.js +392 -0
- package/dist/box3-componentwise.js.map +1 -0
- package/dist/box3-record.d.ts +92 -0
- package/dist/box3-record.d.ts.map +1 -0
- package/dist/box3-record.js +147 -0
- package/dist/box3-record.js.map +1 -0
- package/dist/box3.d.ts +19 -16
- package/dist/box3.d.ts.map +1 -1
- package/dist/box3.js +73 -76
- package/dist/box3.js.map +1 -1
- package/dist/box4-array-boundary.d.ts +50 -0
- package/dist/box4-array-boundary.d.ts.map +1 -0
- package/dist/box4-array-boundary.js +117 -0
- package/dist/box4-array-boundary.js.map +1 -0
- package/dist/box4-componentwise.d.ts +110 -0
- package/dist/box4-componentwise.d.ts.map +1 -0
- package/dist/box4-componentwise.js +459 -0
- package/dist/box4-componentwise.js.map +1 -0
- package/dist/box4-record.d.ts +96 -0
- package/dist/box4-record.d.ts.map +1 -0
- package/dist/box4-record.js +167 -0
- package/dist/box4-record.js.map +1 -0
- package/dist/box4.d.ts +13 -8
- package/dist/box4.d.ts.map +1 -1
- package/dist/box4.js +27 -5
- package/dist/box4.js.map +1 -1
- package/dist/circle2-array-boundary.d.ts +51 -0
- package/dist/circle2-array-boundary.d.ts.map +1 -0
- package/dist/circle2-array-boundary.js +93 -0
- package/dist/circle2-array-boundary.js.map +1 -0
- package/dist/circle2-array.d.ts +17 -0
- package/dist/circle2-array.d.ts.map +1 -0
- package/dist/circle2-array.js +44 -0
- package/dist/circle2-array.js.map +1 -0
- package/dist/circle2-record.d.ts +81 -0
- package/dist/circle2-record.d.ts.map +1 -0
- package/dist/circle2-record.js +114 -0
- package/dist/circle2-record.js.map +1 -0
- package/dist/circle2.d.ts +27 -82
- package/dist/circle2.d.ts.map +1 -1
- package/dist/circle2.js +59 -104
- package/dist/circle2.js.map +1 -1
- package/dist/coordinates/cylindrical-record.d.ts +86 -0
- package/dist/coordinates/cylindrical-record.d.ts.map +1 -0
- package/dist/coordinates/cylindrical-record.js +114 -0
- package/dist/coordinates/cylindrical-record.js.map +1 -0
- package/dist/coordinates/horizontal-record.d.ts +86 -0
- package/dist/coordinates/horizontal-record.d.ts.map +1 -0
- package/dist/coordinates/horizontal-record.js +114 -0
- package/dist/coordinates/horizontal-record.js.map +1 -0
- package/dist/coordinates/horizontal.d.ts +48 -0
- package/dist/coordinates/horizontal.d.ts.map +1 -0
- package/dist/coordinates/horizontal.js +100 -0
- package/dist/coordinates/horizontal.js.map +1 -0
- package/dist/coordinates/index.d.ts +10 -0
- package/dist/coordinates/index.d.ts.map +1 -0
- package/dist/coordinates/index.js +10 -0
- package/dist/coordinates/index.js.map +1 -0
- package/dist/coordinates/longitude-latitude-record.d.ts +81 -0
- package/dist/coordinates/longitude-latitude-record.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude-record.js +104 -0
- package/dist/coordinates/longitude-latitude-record.js.map +1 -0
- package/dist/coordinates/longitude-latitude.d.ts +33 -0
- package/dist/coordinates/longitude-latitude.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude.js +78 -0
- package/dist/coordinates/longitude-latitude.js.map +1 -0
- package/dist/coordinates/polar-record.d.ts +77 -0
- package/dist/coordinates/polar-record.d.ts.map +1 -0
- package/dist/coordinates/polar-record.js +104 -0
- package/dist/coordinates/polar-record.js.map +1 -0
- package/dist/coordinates/polar.d.ts +28 -0
- package/dist/coordinates/polar.d.ts.map +1 -0
- package/dist/coordinates/polar.js +68 -0
- package/dist/coordinates/polar.js.map +1 -0
- package/dist/coordinates/spherical-cylindrical.d.ts +49 -0
- package/dist/coordinates/spherical-cylindrical.d.ts.map +1 -0
- package/dist/coordinates/spherical-cylindrical.js +110 -0
- package/dist/coordinates/spherical-cylindrical.js.map +1 -0
- package/dist/coordinates/spherical-record.d.ts +86 -0
- package/dist/coordinates/spherical-record.d.ts.map +1 -0
- package/dist/coordinates/spherical-record.js +114 -0
- package/dist/coordinates/spherical-record.js.map +1 -0
- package/dist/frustum3-record.d.ts +132 -0
- package/dist/frustum3-record.d.ts.map +1 -0
- package/dist/frustum3-record.js +333 -0
- package/dist/frustum3-record.js.map +1 -0
- package/dist/frustum3.d.ts +60 -0
- package/dist/frustum3.d.ts.map +1 -0
- package/dist/frustum3.js +186 -0
- package/dist/frustum3.js.map +1 -0
- package/dist/index.d.ts +36 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/line2-record.d.ts +87 -0
- package/dist/line2-record.d.ts.map +1 -0
- package/dist/line2-record.js +123 -0
- package/dist/line2-record.js.map +1 -0
- package/dist/line2.d.ts +20 -33
- package/dist/line2.d.ts.map +1 -1
- package/dist/line2.js +56 -51
- package/dist/line2.js.map +1 -1
- package/dist/line3-record.d.ts +91 -0
- package/dist/line3-record.d.ts.map +1 -0
- package/dist/line3-record.js +146 -0
- package/dist/line3-record.js.map +1 -0
- package/dist/line3.d.ts +11 -24
- package/dist/line3.d.ts.map +1 -1
- package/dist/line3.js +32 -36
- package/dist/line3.js.map +1 -1
- package/dist/mesh/_generator-kit.d.ts +14 -0
- package/dist/mesh/_generator-kit.d.ts.map +1 -0
- package/dist/mesh/_generator-kit.js +39 -0
- package/dist/mesh/_generator-kit.js.map +1 -0
- package/dist/mesh/_index-kernels-u16.d.ts +43 -0
- package/dist/mesh/_index-kernels-u16.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u16.js +264 -0
- package/dist/mesh/_index-kernels-u16.js.map +1 -0
- package/dist/mesh/_index-kernels-u32.d.ts +43 -0
- package/dist/mesh/_index-kernels-u32.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u32.js +264 -0
- package/dist/mesh/_index-kernels-u32.js.map +1 -0
- package/dist/mesh/generate-box.d.ts +16 -0
- package/dist/mesh/generate-box.d.ts.map +1 -0
- package/dist/mesh/generate-box.js +79 -0
- package/dist/mesh/generate-box.js.map +1 -0
- package/dist/mesh/generate-cylinder.d.ts +25 -0
- package/dist/mesh/generate-cylinder.d.ts.map +1 -0
- package/dist/mesh/generate-cylinder.js +117 -0
- package/dist/mesh/generate-cylinder.js.map +1 -0
- package/dist/mesh/generate-heightfield.d.ts +24 -0
- package/dist/mesh/generate-heightfield.d.ts.map +1 -0
- package/dist/mesh/generate-heightfield.js +48 -0
- package/dist/mesh/generate-heightfield.js.map +1 -0
- package/dist/mesh/generate-plane.d.ts +18 -0
- package/dist/mesh/generate-plane.d.ts.map +1 -0
- package/dist/mesh/generate-plane.js +39 -0
- package/dist/mesh/generate-plane.js.map +1 -0
- package/dist/mesh/generate-sphere.d.ts +50 -0
- package/dist/mesh/generate-sphere.d.ts.map +1 -0
- package/dist/mesh/generate-sphere.js +244 -0
- package/dist/mesh/generate-sphere.js.map +1 -0
- package/dist/mesh/index.d.ts +8 -0
- package/dist/mesh/index.d.ts.map +1 -0
- package/dist/mesh/index.js +8 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/mesh3-kernels.d.ts +82 -0
- package/dist/mesh/mesh3-kernels.d.ts.map +1 -0
- package/dist/mesh/mesh3-kernels.js +180 -0
- package/dist/mesh/mesh3-kernels.js.map +1 -0
- package/dist/mesh/mesh3.d.ts +66 -0
- package/dist/mesh/mesh3.d.ts.map +1 -0
- package/dist/mesh/mesh3.js +128 -0
- package/dist/mesh/mesh3.js.map +1 -0
- package/dist/plane3-record.d.ts +88 -0
- package/dist/plane3-record.d.ts.map +1 -0
- package/dist/plane3-record.js +123 -0
- package/dist/plane3-record.js.map +1 -0
- package/dist/plane3.d.ts +42 -28
- package/dist/plane3.d.ts.map +1 -1
- package/dist/plane3.js +166 -48
- package/dist/plane3.js.map +1 -1
- package/dist/polygon2.d.ts +82 -29
- package/dist/polygon2.d.ts.map +1 -1
- package/dist/polygon2.js +236 -93
- package/dist/polygon2.js.map +1 -1
- package/dist/polygon3.d.ts +40 -21
- package/dist/polygon3.d.ts.map +1 -1
- package/dist/polygon3.js +215 -91
- package/dist/polygon3.js.map +1 -1
- package/dist/polyline2.d.ts +37 -0
- package/dist/polyline2.d.ts.map +1 -0
- package/dist/polyline2.js +146 -0
- package/dist/polyline2.js.map +1 -0
- package/dist/polyline3.d.ts +35 -0
- package/dist/polyline3.d.ts.map +1 -0
- package/dist/polyline3.js +159 -0
- package/dist/polyline3.js.map +1 -0
- package/dist/quadtree.d.ts +238 -0
- package/dist/quadtree.d.ts.map +1 -0
- package/dist/quadtree.js +1019 -0
- package/dist/quadtree.js.map +1 -0
- package/dist/ray2-record.d.ts +86 -0
- package/dist/ray2-record.d.ts.map +1 -0
- package/dist/ray2-record.js +123 -0
- package/dist/ray2-record.js.map +1 -0
- package/dist/ray2.d.ts +38 -13
- package/dist/ray2.d.ts.map +1 -1
- package/dist/ray2.js +85 -22
- package/dist/ray2.js.map +1 -1
- package/dist/ray3-array.d.ts +27 -0
- package/dist/ray3-array.d.ts.map +1 -0
- package/dist/ray3-array.js +89 -0
- package/dist/ray3-array.js.map +1 -0
- package/dist/ray3-record.d.ts +90 -0
- package/dist/ray3-record.d.ts.map +1 -0
- package/dist/ray3-record.js +146 -0
- package/dist/ray3-record.js.map +1 -0
- package/dist/ray3.d.ts +72 -25
- package/dist/ray3.d.ts.map +1 -1
- package/dist/ray3.js +233 -64
- package/dist/ray3.js.map +1 -1
- package/dist/segment2-record.d.ts +80 -0
- package/dist/segment2-record.d.ts.map +1 -0
- package/dist/segment2-record.js +122 -0
- package/dist/segment2-record.js.map +1 -0
- package/dist/segment2.d.ts +34 -19
- package/dist/segment2.d.ts.map +1 -1
- package/dist/segment2.js +88 -42
- package/dist/segment2.js.map +1 -1
- package/dist/segment3-record.d.ts +90 -0
- package/dist/segment3-record.d.ts.map +1 -0
- package/dist/segment3-record.js +146 -0
- package/dist/segment3-record.js.map +1 -0
- package/dist/segment3.d.ts +24 -12
- package/dist/segment3.d.ts.map +1 -1
- package/dist/segment3.js +67 -30
- package/dist/segment3.js.map +1 -1
- package/dist/size.d.ts +40 -0
- package/dist/size.d.ts.map +1 -0
- package/dist/size.js +72 -0
- package/dist/size.js.map +1 -0
- package/dist/sphere3-array-boundary.d.ts +51 -0
- package/dist/sphere3-array-boundary.d.ts.map +1 -0
- package/dist/sphere3-array-boundary.js +98 -0
- package/dist/sphere3-array-boundary.js.map +1 -0
- package/dist/sphere3-record.d.ts +88 -0
- package/dist/sphere3-record.d.ts.map +1 -0
- package/dist/sphere3-record.js +123 -0
- package/dist/sphere3-record.js.map +1 -0
- package/dist/sphere3.d.ts +55 -12
- package/dist/sphere3.d.ts.map +1 -1
- package/dist/sphere3.js +233 -24
- package/dist/sphere3.js.map +1 -1
- package/dist/spherical/cap.d.ts +56 -0
- package/dist/spherical/cap.d.ts.map +1 -0
- package/dist/spherical/cap.js +363 -0
- package/dist/spherical/cap.js.map +1 -0
- package/dist/spherical/great-circle.d.ts +39 -0
- package/dist/spherical/great-circle.d.ts.map +1 -0
- package/dist/spherical/great-circle.js +158 -0
- package/dist/spherical/great-circle.js.map +1 -0
- package/dist/spherical/index.d.ts +3 -0
- package/dist/spherical/index.d.ts.map +1 -0
- package/dist/spherical/index.js +3 -0
- package/dist/spherical/index.js.map +1 -0
- package/dist/triangle2-record.d.ts +91 -0
- package/dist/triangle2-record.d.ts.map +1 -0
- package/dist/triangle2-record.js +146 -0
- package/dist/triangle2-record.js.map +1 -0
- package/dist/triangle2.d.ts +29 -14
- package/dist/triangle2.d.ts.map +1 -1
- package/dist/triangle2.js +86 -22
- package/dist/triangle2.js.map +1 -1
- package/dist/triangle3-record.d.ts +97 -0
- package/dist/triangle3-record.d.ts.map +1 -0
- package/dist/triangle3-record.js +178 -0
- package/dist/triangle3-record.js.map +1 -0
- package/dist/triangle3.d.ts +41 -17
- package/dist/triangle3.d.ts.map +1 -1
- package/dist/triangle3.js +267 -38
- package/dist/triangle3.js.map +1 -1
- package/package.json +15 -8
- package/dist/angles.d.ts +0 -31
- package/dist/angles.d.ts.map +0 -1
- package/dist/angles.js +0 -53
- package/dist/angles.js.map +0 -1
- package/dist/coordinate-spaces.d.ts +0 -39
- package/dist/coordinate-spaces.d.ts.map +0 -1
- package/dist/coordinate-spaces.js +0 -52
- package/dist/coordinate-spaces.js.map +0 -1
- package/dist/coordinates-vec2.d.ts +0 -7
- package/dist/coordinates-vec2.d.ts.map +0 -1
- package/dist/coordinates-vec2.js +0 -35
- package/dist/coordinates-vec2.js.map +0 -1
- package/dist/coordinates-vec3.d.ts +0 -11
- package/dist/coordinates-vec3.d.ts.map +0 -1
- package/dist/coordinates-vec3.js +0 -61
- package/dist/coordinates-vec3.js.map +0 -1
- package/dist/coordinates.d.ts +0 -54
- package/dist/coordinates.d.ts.map +0 -1
- package/dist/coordinates.js +0 -2
- package/dist/coordinates.js.map +0 -1
- package/dist/euler-angles-quaternion.d.ts +0 -7
- package/dist/euler-angles-quaternion.d.ts.map +0 -1
- package/dist/euler-angles-quaternion.js +0 -100
- package/dist/euler-angles-quaternion.js.map +0 -1
- package/dist/euler-angles.d.ts +0 -33
- package/dist/euler-angles.d.ts.map +0 -1
- package/dist/euler-angles.js +0 -35
- package/dist/euler-angles.js.map +0 -1
- package/dist/geometry-vectors.d.ts +0 -11
- package/dist/geometry-vectors.d.ts.map +0 -1
- package/dist/geometry-vectors.js +0 -19
- package/dist/geometry-vectors.js.map +0 -1
- package/dist/mesh3.d.ts +0 -32
- package/dist/mesh3.d.ts.map +0 -1
- package/dist/mesh3.js +0 -142
- package/dist/mesh3.js.map +0 -1
- package/dist/point2.d.ts +0 -41
- package/dist/point2.d.ts.map +0 -1
- package/dist/point2.js +0 -92
- package/dist/point2.js.map +0 -1
- package/dist/point3.d.ts +0 -43
- package/dist/point3.d.ts.map +0 -1
- package/dist/point3.js +0 -103
- package/dist/point3.js.map +0 -1
- package/dist/point4.d.ts +0 -12
- package/dist/point4.d.ts.map +0 -1
- package/dist/point4.js +0 -28
- package/dist/point4.js.map +0 -1
- package/dist/rect2.d.ts +0 -54
- package/dist/rect2.d.ts.map +0 -1
- package/dist/rect2.js +0 -149
- package/dist/rect2.js.map +0 -1
- package/dist/size2.d.ts +0 -33
- package/dist/size2.d.ts.map +0 -1
- package/dist/size2.js +0 -81
- package/dist/size2.js.map +0 -1
- package/dist/size3.d.ts +0 -21
- package/dist/size3.d.ts.map +0 -1
- package/dist/size3.js +0 -59
- package/dist/size3.js.map +0 -1
- package/dist/size4.d.ts +0 -10
- package/dist/size4.d.ts.map +0 -1
- package/dist/size4.js +0 -16
- package/dist/size4.js.map +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Generated from scripts/templates/record.liquid by scripts/generate-records.ts. Do not edit.
|
|
2
|
+
import { isCloseAbsolute, numberAtOrNaN } from "@ac-kit/core";
|
|
3
|
+
import { geometryConfig } from "./globals.js";
|
|
4
|
+
/**
|
|
5
|
+
* Every creator copies this array, which holds non-integer doubles and is never
|
|
6
|
+
* exposed: nothing a caller does can change the element kind it copies.
|
|
7
|
+
*/
|
|
8
|
+
const TEMPLATE_ = [0.5, 0.5, 0.5];
|
|
9
|
+
/**
|
|
10
|
+
* Creates the circle of radius 0 at the origin.
|
|
11
|
+
*
|
|
12
|
+
* Allocates; keep it out of hot loops.
|
|
13
|
+
*/
|
|
14
|
+
export function circle2Create() {
|
|
15
|
+
const out = TEMPLATE_.slice();
|
|
16
|
+
out[0] = 0;
|
|
17
|
+
out[1] = 0;
|
|
18
|
+
out[2] = 0;
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates the circle with the components `centerX, centerY, radius`, in storage
|
|
23
|
+
* order.
|
|
24
|
+
*
|
|
25
|
+
* Allocates; keep it out of hot loops.
|
|
26
|
+
*/
|
|
27
|
+
export function circle2Of(centerX, centerY, radius) {
|
|
28
|
+
const out = TEMPLATE_.slice();
|
|
29
|
+
out[0] = centerX;
|
|
30
|
+
out[1] = centerY;
|
|
31
|
+
out[2] = radius;
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
36
|
+
*
|
|
37
|
+
* Allocates; keep it out of hot loops.
|
|
38
|
+
*/
|
|
39
|
+
export function circle2Clone(a) {
|
|
40
|
+
const out = TEMPLATE_.slice();
|
|
41
|
+
out[0] = a[0];
|
|
42
|
+
out[1] = a[1];
|
|
43
|
+
out[2] = a[2];
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
/** Writes the components, in storage order, into `out`. */
|
|
47
|
+
export function circle2Set(out, centerX, centerY, radius) {
|
|
48
|
+
out[0] = centerX;
|
|
49
|
+
out[1] = centerY;
|
|
50
|
+
out[2] = radius;
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
54
|
+
export function circle2Copy(out, a) {
|
|
55
|
+
out[0] = a[0];
|
|
56
|
+
out[1] = a[1];
|
|
57
|
+
out[2] = a[2];
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
62
|
+
* included, and an infinity equals itself. See {@link circle2IsClose} for a
|
|
63
|
+
* tolerant test.
|
|
64
|
+
*/
|
|
65
|
+
export function circle2Equals(a, b) {
|
|
66
|
+
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
70
|
+
* `tolerance`, an absolute bound in the caller's units, and an infinity is
|
|
71
|
+
* close only to itself. Not transitive, so never a basis for ordering or a
|
|
72
|
+
* container key: use {@link circle2Equals} there.
|
|
73
|
+
*
|
|
74
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
75
|
+
*/
|
|
76
|
+
export function circle2IsClose(a, b, tolerance = geometryConfig.defaultLinearTolerance) {
|
|
77
|
+
return (isCloseAbsolute(a[0], b[0], tolerance) &&
|
|
78
|
+
isCloseAbsolute(a[1], b[1], tolerance) &&
|
|
79
|
+
isCloseAbsolute(a[2], b[2], tolerance));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
83
|
+
* origin): `source[offset … offset + 3)` copied into `out`, each element that
|
|
84
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
85
|
+
* `out` never holds a non-number. A cold path: buffers use {@link circle2Load}.
|
|
86
|
+
* O(1).
|
|
87
|
+
*
|
|
88
|
+
* `source` may be `out` itself: the 3 elements are read before the first write.
|
|
89
|
+
*
|
|
90
|
+
* @param out The circle to fill.
|
|
91
|
+
* @param source The array to read, of any length and any content.
|
|
92
|
+
* @param offset The index of the first component in `source`.
|
|
93
|
+
* @returns `out`.
|
|
94
|
+
*/
|
|
95
|
+
export function circle2FromArray(out, source, offset = 0) {
|
|
96
|
+
const value0 = numberAtOrNaN(source, offset);
|
|
97
|
+
const value1 = numberAtOrNaN(source, offset + 1);
|
|
98
|
+
const value2 = numberAtOrNaN(source, offset + 2);
|
|
99
|
+
out[0] = value0;
|
|
100
|
+
out[1] = value1;
|
|
101
|
+
out[2] = value2;
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
106
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
107
|
+
* that is not a number at all counts as not finite.
|
|
108
|
+
*/
|
|
109
|
+
export function circle2IsFinite(value) {
|
|
110
|
+
return (Number.isFinite(value[0]) &&
|
|
111
|
+
Number.isFinite(value[1]) &&
|
|
112
|
+
Number.isFinite(value[2]));
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=circle2-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle2-record.js","sourceRoot":"","sources":["../src/circle2-record.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,cAAc,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a,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAsB;IACrD,OAAO,CACN,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;AACH,CAAC"}
|
package/dist/circle2.d.ts
CHANGED
|
@@ -1,95 +1,40 @@
|
|
|
1
|
-
import { Vec2 } from "@ac-kit/math-linear";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { ReadonlyVec2, Vec2 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { Box2, ReadonlyBox2 } from "./box2-record.js";
|
|
3
|
+
import type { Circle2, ReadonlyCircle2 } from "./circle2-record.js";
|
|
4
|
+
/** The area, `π r²`; `0` for a negative radius (an empty circle). */
|
|
5
|
+
export declare function circle2Area(circle: ReadonlyCircle2): number;
|
|
6
|
+
/** The circumference, `2 π r`; `0` for a negative radius. */
|
|
7
|
+
export declare function circle2Circumference(circle: ReadonlyCircle2): number;
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param c - Circle to calculate area for.
|
|
11
|
-
* @returns Area of the circle.
|
|
9
|
+
* Whether `point` lies in the disc, boundary included: exact, `(dx² + dy²) ≤
|
|
10
|
+
* r²`. A negative radius contains nothing. For slack, grow the radius.
|
|
12
11
|
*/
|
|
13
|
-
export declare function
|
|
12
|
+
export declare function circle2ContainsPoint(circle: ReadonlyCircle2, point: ReadonlyVec2): boolean;
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param c - Circle to calculate circumference for.
|
|
18
|
-
* @returns Circumference of the circle.
|
|
14
|
+
* {@link circle2ContainsPoint} with the components as arguments, for pointer
|
|
15
|
+
* events.
|
|
19
16
|
*/
|
|
20
|
-
export declare function
|
|
17
|
+
export declare function circle2ContainsXy(circle: ReadonlyCircle2, x: number, y: number): boolean;
|
|
21
18
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Exact: the boundary is measure-zero, so a tolerance would only move it by an
|
|
25
|
-
* arbitrary amount. For deliberate slack, inflate `c.radius` — a length, unlike
|
|
26
|
-
* an epsilon on the squared distance compared here.
|
|
27
|
-
*
|
|
28
|
-
* @param c - Circle to check against.
|
|
29
|
-
* @param p - Point to check.
|
|
30
|
-
* @returns True if the point is inside or on the boundary of the circle, false
|
|
31
|
-
* otherwise.
|
|
19
|
+
* Whether the two discs share a point, boundaries included. A negative radius
|
|
20
|
+
* intersects nothing.
|
|
32
21
|
*/
|
|
33
|
-
export declare function
|
|
22
|
+
export declare function circle2IntersectsCircle2(a: ReadonlyCircle2, b: ReadonlyCircle2): boolean;
|
|
34
23
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param a - First circle to compare.
|
|
39
|
-
* @param b - Second circle to compare.
|
|
40
|
-
* @returns True if the circles are equal, false otherwise.
|
|
24
|
+
* Whether the disc and the box share a point, boundaries included. An empty box
|
|
25
|
+
* or a negative radius intersects nothing.
|
|
41
26
|
*/
|
|
42
|
-
export declare function
|
|
27
|
+
export declare function circle2IntersectsBox2(circle: ReadonlyCircle2, box: ReadonlyBox2): boolean;
|
|
43
28
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* Not transitive, so never a basis for ordering or for a set or map key — use
|
|
48
|
-
* {@link circle2Equals} there.
|
|
49
|
-
*
|
|
50
|
-
* @param a - First circle to compare.
|
|
51
|
-
* @param b - Second circle to compare.
|
|
52
|
-
* @param tolerance - Distance, in the caller's own units.
|
|
53
|
-
* @returns True if the circles are close, false otherwise.
|
|
29
|
+
* Writes the point of the circle at `angle` from +x into `out`:
|
|
30
|
+
* counter-clockwise in a y-up frame, clockwise on a y-down screen.
|
|
54
31
|
*/
|
|
55
|
-
export declare function
|
|
32
|
+
export declare function circle2PointAt(out: Vec2, circle: ReadonlyCircle2, angle: number): Vec2;
|
|
33
|
+
/** Writes `circle` moved by `offset` into `out`. `out` may be `circle`. */
|
|
34
|
+
export declare function circle2Translate(out: Circle2, circle: ReadonlyCircle2, offset: ReadonlyVec2): Circle2;
|
|
56
35
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* up, as everywhere in this package. In a y-down frame such as SVG's or a
|
|
60
|
-
* canvas's, the same angle runs clockwise.
|
|
61
|
-
*
|
|
62
|
-
* Any finite angle; whole turns wrap.
|
|
63
|
-
*
|
|
64
|
-
* O(1) time, O(1) memory.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* circle2PointAt({ center: { x: 1, y: 2 }, radius: 3 }, 0); // { x: 4, y: 2 }
|
|
69
|
-
* ```;
|
|
70
|
-
*
|
|
71
|
-
* @param c - The circle.
|
|
72
|
-
* @param angle - Radians from the positive x axis.
|
|
73
|
-
* @returns The point on the boundary.
|
|
74
|
-
* @see {@link polarToVec2} for the same point relative to the centre.
|
|
36
|
+
* Writes the smallest box holding the circle into `out`; a negative radius
|
|
37
|
+
* gives an empty box.
|
|
75
38
|
*/
|
|
76
|
-
export declare function
|
|
77
|
-
/**
|
|
78
|
-
* Determines whether two 2D circles intersect.
|
|
79
|
-
*
|
|
80
|
-
* Exact, for the same reason as {@link circle2ContainsPoint}.
|
|
81
|
-
*
|
|
82
|
-
* @param a - First circle to check for intersection.
|
|
83
|
-
* @param b - Second circle to check for intersection.
|
|
84
|
-
* @returns True if the circles intersect, false otherwise.
|
|
85
|
-
*/
|
|
86
|
-
export declare function circle2Intersects(a: Circle2, b: Circle2): boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Translates a 2D circle by a given vector.
|
|
89
|
-
*
|
|
90
|
-
* @param c - Circle to translate.
|
|
91
|
-
* @param v - Vector by which to translate the circle.
|
|
92
|
-
* @returns A new Circle2 object representing the translated circle.
|
|
93
|
-
*/
|
|
94
|
-
export declare function circle2Translate(c: Circle2, v: Vec2): Circle2;
|
|
39
|
+
export declare function circle2BoundingBox(out: Box2, circle: ReadonlyCircle2): Box2;
|
|
95
40
|
//# sourceMappingURL=circle2.d.ts.map
|
package/dist/circle2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle2.d.ts","sourceRoot":"","sources":["../src/circle2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"circle2.d.ts","sourceRoot":"","sources":["../src/circle2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEpE,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAG3D;AAED,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAGpE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,YAAY,GACjB,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,eAAe,EACvB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACP,OAAO,CAKT;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACvC,CAAC,EAAE,eAAe,EAClB,CAAC,EAAE,eAAe,GAChB,OAAO,CAKT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,YAAY,GACf,OAAO,CAUT;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACX,IAAI,CAIN;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,YAAY,GAClB,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAO3E"}
|
package/dist/circle2.js
CHANGED
|
@@ -1,125 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { geometryConfig } from "./globals.js";
|
|
6
|
-
import { point2IsClose } from "./point2.js";
|
|
7
|
-
/**
|
|
8
|
-
* Calculates the area of a 2D circle.
|
|
9
|
-
*
|
|
10
|
-
* @param c - Circle to calculate area for.
|
|
11
|
-
* @returns Area of the circle.
|
|
12
|
-
*/
|
|
13
|
-
export function circle2Area(c) {
|
|
14
|
-
return Math.PI * c.radius * c.radius;
|
|
1
|
+
/** The area, `π r²`; `0` for a negative radius (an empty circle). */
|
|
2
|
+
export function circle2Area(circle) {
|
|
3
|
+
const radius = circle[2];
|
|
4
|
+
return radius < 0 ? 0 : Math.PI * radius * radius;
|
|
15
5
|
}
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* @returns Circumference of the circle.
|
|
21
|
-
*/
|
|
22
|
-
export function circle2Circumference(c) {
|
|
23
|
-
return TWO_PI * c.radius;
|
|
6
|
+
/** The circumference, `2 π r`; `0` for a negative radius. */
|
|
7
|
+
export function circle2Circumference(circle) {
|
|
8
|
+
const radius = circle[2];
|
|
9
|
+
return radius < 0 ? 0 : 2 * Math.PI * radius;
|
|
24
10
|
}
|
|
25
11
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* Exact: the boundary is measure-zero, so a tolerance would only move it by an
|
|
29
|
-
* arbitrary amount. For deliberate slack, inflate `c.radius` — a length, unlike
|
|
30
|
-
* an epsilon on the squared distance compared here.
|
|
31
|
-
*
|
|
32
|
-
* @param c - Circle to check against.
|
|
33
|
-
* @param p - Point to check.
|
|
34
|
-
* @returns True if the point is inside or on the boundary of the circle, false
|
|
35
|
-
* otherwise.
|
|
12
|
+
* Whether `point` lies in the disc, boundary included: exact, `(dx² + dy²) ≤
|
|
13
|
+
* r²`. A negative radius contains nothing. For slack, grow the radius.
|
|
36
14
|
*/
|
|
37
|
-
export function circle2ContainsPoint(
|
|
38
|
-
|
|
39
|
-
const radSq = c.radius * c.radius;
|
|
40
|
-
return distSq <= radSq;
|
|
15
|
+
export function circle2ContainsPoint(circle, point) {
|
|
16
|
+
return circle2ContainsXy(circle, point[0], point[1]);
|
|
41
17
|
}
|
|
42
18
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @param a - First circle to compare.
|
|
47
|
-
* @param b - Second circle to compare.
|
|
48
|
-
* @returns True if the circles are equal, false otherwise.
|
|
19
|
+
* {@link circle2ContainsPoint} with the components as arguments, for pointer
|
|
20
|
+
* events.
|
|
49
21
|
*/
|
|
50
|
-
export function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
22
|
+
export function circle2ContainsXy(circle, x, y) {
|
|
23
|
+
const dx = x - circle[0];
|
|
24
|
+
const dy = y - circle[1];
|
|
25
|
+
const radius = circle[2];
|
|
26
|
+
return radius >= 0 && dx * dx + dy * dy <= radius * radius;
|
|
54
27
|
}
|
|
55
28
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* Not transitive, so never a basis for ordering or for a set or map key — use
|
|
60
|
-
* {@link circle2Equals} there.
|
|
61
|
-
*
|
|
62
|
-
* @param a - First circle to compare.
|
|
63
|
-
* @param b - Second circle to compare.
|
|
64
|
-
* @param tolerance - Distance, in the caller's own units.
|
|
65
|
-
* @returns True if the circles are close, false otherwise.
|
|
29
|
+
* Whether the two discs share a point, boundaries included. A negative radius
|
|
30
|
+
* intersects nothing.
|
|
66
31
|
*/
|
|
67
|
-
export function
|
|
68
|
-
|
|
69
|
-
|
|
32
|
+
export function circle2IntersectsCircle2(a, b) {
|
|
33
|
+
const dx = a[0] - b[0];
|
|
34
|
+
const dy = a[1] - b[1];
|
|
35
|
+
const sum = a[2] + b[2];
|
|
36
|
+
return a[2] >= 0 && b[2] >= 0 && dx * dx + dy * dy <= sum * sum;
|
|
70
37
|
}
|
|
71
38
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* up, as everywhere in this package. In a y-down frame such as SVG's or a
|
|
75
|
-
* canvas's, the same angle runs clockwise.
|
|
76
|
-
*
|
|
77
|
-
* Any finite angle; whole turns wrap.
|
|
78
|
-
*
|
|
79
|
-
* O(1) time, O(1) memory.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```ts
|
|
83
|
-
* circle2PointAt({ center: { x: 1, y: 2 }, radius: 3 }, 0); // { x: 4, y: 2 }
|
|
84
|
-
* ```;
|
|
85
|
-
*
|
|
86
|
-
* @param c - The circle.
|
|
87
|
-
* @param angle - Radians from the positive x axis.
|
|
88
|
-
* @returns The point on the boundary.
|
|
89
|
-
* @see {@link polarToVec2} for the same point relative to the centre.
|
|
39
|
+
* Whether the disc and the box share a point, boundaries included. An empty box
|
|
40
|
+
* or a negative radius intersects nothing.
|
|
90
41
|
*/
|
|
91
|
-
export function
|
|
92
|
-
const
|
|
93
|
-
|
|
42
|
+
export function circle2IntersectsBox2(circle, box) {
|
|
43
|
+
const dx = Math.max(box[0] - circle[0], 0, circle[0] - box[2]);
|
|
44
|
+
const dy = Math.max(box[1] - circle[1], 0, circle[1] - box[3]);
|
|
45
|
+
const radius = circle[2];
|
|
46
|
+
return (radius >= 0 &&
|
|
47
|
+
box[0] <= box[2] &&
|
|
48
|
+
box[1] <= box[3] &&
|
|
49
|
+
dx * dx + dy * dy <= radius * radius);
|
|
94
50
|
}
|
|
95
51
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* Exact, for the same reason as {@link circle2ContainsPoint}.
|
|
99
|
-
*
|
|
100
|
-
* @param a - First circle to check for intersection.
|
|
101
|
-
* @param b - Second circle to check for intersection.
|
|
102
|
-
* @returns True if the circles intersect, false otherwise.
|
|
52
|
+
* Writes the point of the circle at `angle` from +x into `out`:
|
|
53
|
+
* counter-clockwise in a y-up frame, clockwise on a y-down screen.
|
|
103
54
|
*/
|
|
104
|
-
export function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
55
|
+
export function circle2PointAt(out, circle, angle) {
|
|
56
|
+
out[0] = circle[0] + circle[2] * Math.cos(angle);
|
|
57
|
+
out[1] = circle[1] + circle[2] * Math.sin(angle);
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/** Writes `circle` moved by `offset` into `out`. `out` may be `circle`. */
|
|
61
|
+
export function circle2Translate(out, circle, offset) {
|
|
62
|
+
const radius = circle[2];
|
|
63
|
+
out[0] = circle[0] + offset[0];
|
|
64
|
+
out[1] = circle[1] + offset[1];
|
|
65
|
+
out[2] = radius;
|
|
66
|
+
return out;
|
|
111
67
|
}
|
|
112
68
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* @param c - Circle to translate.
|
|
116
|
-
* @param v - Vector by which to translate the circle.
|
|
117
|
-
* @returns A new Circle2 object representing the translated circle.
|
|
69
|
+
* Writes the smallest box holding the circle into `out`; a negative radius
|
|
70
|
+
* gives an empty box.
|
|
118
71
|
*/
|
|
119
|
-
export function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
72
|
+
export function circle2BoundingBox(out, circle) {
|
|
73
|
+
const radius = circle[2];
|
|
74
|
+
out[0] = circle[0] - radius;
|
|
75
|
+
out[1] = circle[1] - radius;
|
|
76
|
+
out[2] = circle[0] + radius;
|
|
77
|
+
out[3] = circle[1] + radius;
|
|
78
|
+
return out;
|
|
124
79
|
}
|
|
125
80
|
//# sourceMappingURL=circle2.js.map
|
package/dist/circle2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle2.js","sourceRoot":"","sources":["../src/circle2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"circle2.js","sourceRoot":"","sources":["../src/circle2.ts"],"names":[],"mappings":"AAKA,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAC,MAAuB;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACzB,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AACnD,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACzB,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAuB,EACvB,KAAmB;IAEnB,OAAO,iBAAiB,CAAC,MAAM,EAAE,KAAK,CA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,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAS,EAAE,MAAuB;IACpE,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACzB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5B,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Brand_ } from "../_brand.js";
|
|
2
|
+
/**
|
|
3
|
+
* Cylindrical coordinates: the distance from the axis, the azimuth around it in
|
|
4
|
+
* radians and the height along it. Which axis is up is in the name of the
|
|
5
|
+
* function that converts (`…YUp`, `…ZUp`), not in the type.
|
|
6
|
+
*
|
|
7
|
+
* A plain array of 3 binary64 numbers carrying a type-level brand, holding
|
|
8
|
+
* exactly the numbers one element of the matching bulk buffer holds, in the
|
|
9
|
+
* same order.
|
|
10
|
+
*
|
|
11
|
+
* Only {@link cylindricalCoordsCreate}, {@link cylindricalCoordsOf},
|
|
12
|
+
* {@link cylindricalCoordsClone}, {@link cylindricalCoordsFromArray} and the
|
|
13
|
+
* functions that write an `out` make one; see `Vec3` in `@ac-kit/math-linear`
|
|
14
|
+
* for the rules that bind callers who bypass the types.
|
|
15
|
+
*/
|
|
16
|
+
export type CylindricalCoords = [
|
|
17
|
+
radius: number,
|
|
18
|
+
azimuth: number,
|
|
19
|
+
height: number
|
|
20
|
+
] & Brand_<"CylindricalCoords">;
|
|
21
|
+
/** A {@link CylindricalCoords} that is only read. */
|
|
22
|
+
export type ReadonlyCylindricalCoords = readonly [
|
|
23
|
+
radius: number,
|
|
24
|
+
azimuth: number,
|
|
25
|
+
height: number
|
|
26
|
+
] & Brand_<"CylindricalCoords">;
|
|
27
|
+
/**
|
|
28
|
+
* Creates the cylindrical coordinates `[0, 0, 0]`, the origin.
|
|
29
|
+
*
|
|
30
|
+
* Allocates; keep it out of hot loops.
|
|
31
|
+
*/
|
|
32
|
+
export declare function cylindricalCoordsCreate(): CylindricalCoords;
|
|
33
|
+
/**
|
|
34
|
+
* Creates the cylindrical coordinates with the components `radius, azimuth,
|
|
35
|
+
* height`, in storage order.
|
|
36
|
+
*
|
|
37
|
+
* Allocates; keep it out of hot loops.
|
|
38
|
+
*/
|
|
39
|
+
export declare function cylindricalCoordsOf(radius: number, azimuth: number, height: number): CylindricalCoords;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
42
|
+
*
|
|
43
|
+
* Allocates; keep it out of hot loops.
|
|
44
|
+
*/
|
|
45
|
+
export declare function cylindricalCoordsClone(a: ReadonlyCylindricalCoords): CylindricalCoords;
|
|
46
|
+
/** Writes the components, in storage order, into `out`. */
|
|
47
|
+
export declare function cylindricalCoordsSet(out: CylindricalCoords, radius: number, azimuth: number, height: number): CylindricalCoords;
|
|
48
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
49
|
+
export declare function cylindricalCoordsCopy(out: CylindricalCoords, a: ReadonlyCylindricalCoords): CylindricalCoords;
|
|
50
|
+
/**
|
|
51
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
52
|
+
* included, and an infinity equals itself. See {@link cylindricalCoordsIsClose}
|
|
53
|
+
* for a tolerant test.
|
|
54
|
+
*/
|
|
55
|
+
export declare function cylindricalCoordsEquals(a: ReadonlyCylindricalCoords, b: ReadonlyCylindricalCoords): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
58
|
+
* `tolerance`, an absolute bound in the caller's units, and an infinity is
|
|
59
|
+
* close only to itself. Not transitive, so never a basis for ordering or a
|
|
60
|
+
* container key: use {@link cylindricalCoordsEquals} there.
|
|
61
|
+
*
|
|
62
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function cylindricalCoordsIsClose(a: ReadonlyCylindricalCoords, b: ReadonlyCylindricalCoords, tolerance?: number): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
67
|
+
* origin): `source[offset … offset + 3)` copied into `out`, each element that
|
|
68
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
69
|
+
* `out` never holds a non-number. A cold path: buffers use
|
|
70
|
+
* {@link cylindricalCoordsLoad}. O(1).
|
|
71
|
+
*
|
|
72
|
+
* `source` may be `out` itself: the 3 elements are read before the first write.
|
|
73
|
+
*
|
|
74
|
+
* @param out The cylindrical coordinates to fill.
|
|
75
|
+
* @param source The array to read, of any length and any content.
|
|
76
|
+
* @param offset The index of the first component in `source`.
|
|
77
|
+
* @returns `out`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function cylindricalCoordsFromArray(out: CylindricalCoords, source: ArrayLike<number>, offset?: number): CylindricalCoords;
|
|
80
|
+
/**
|
|
81
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
82
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
83
|
+
* that is not a number at all counts as not finite.
|
|
84
|
+
*/
|
|
85
|
+
export declare function cylindricalCoordsIsFinite(value: ReadonlyCylindricalCoords): boolean;
|
|
86
|
+
//# sourceMappingURL=cylindrical-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cylindrical-record.d.ts","sourceRoot":"","sources":["../../src/coordinates/cylindrical-record.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;;;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