@thi.ng/geom 7.0.1 → 8.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.
- package/CHANGELOG.md +190 -1
- package/README.md +349 -112
- package/aabb.d.ts +26 -1
- package/api/aabb.d.ts +5 -4
- package/api/aabb.js +10 -7
- package/api/apc.d.ts +5 -3
- package/api/arc.d.ts +6 -5
- package/api/arc.js +3 -4
- package/api/bpatch.d.ts +6 -3
- package/api/bpatch.js +5 -3
- package/api/circle.d.ts +4 -3
- package/api/circle.js +9 -6
- package/api/complex-polygon.d.ts +7 -3
- package/api/complex-polygon.js +14 -4
- package/api/cubic.d.ts +8 -5
- package/api/cubic.js +12 -6
- package/api/cubic3.d.ts +15 -0
- package/api/cubic3.js +38 -0
- package/api/ellipse.d.ts +4 -3
- package/api/ellipse.js +7 -8
- package/api/extra.d.ts +15 -0
- package/api/extra.js +19 -0
- package/api/group.d.ts +12 -11
- package/api/group.js +4 -5
- package/api/group3.d.ts +30 -0
- package/api/group3.js +48 -0
- package/api/line.d.ts +8 -5
- package/api/line.js +8 -8
- package/api/line3.d.ts +15 -0
- package/api/line3.js +29 -0
- package/api/path.d.ts +14 -11
- package/api/path.js +17 -12
- package/api/path3.d.ts +28 -0
- package/api/path3.js +91 -0
- package/api/plane.d.ts +4 -3
- package/api/plane.js +7 -4
- package/api/points.d.ts +8 -10
- package/api/points.js +7 -20
- package/api/points3.d.ts +13 -0
- package/api/points3.js +21 -0
- package/api/polygon.d.ts +7 -4
- package/api/polygon.js +5 -3
- package/api/polygon3.d.ts +14 -0
- package/api/polygon3.js +24 -0
- package/api/polyline.d.ts +18 -4
- package/api/polyline.js +8 -5
- package/api/polyline3.d.ts +28 -0
- package/api/polyline3.js +31 -0
- package/api/quad.d.ts +7 -4
- package/api/quad.js +5 -3
- package/api/quad3.d.ts +7 -4
- package/api/quad3.js +6 -4
- package/api/quadratic.d.ts +8 -5
- package/api/quadratic.js +12 -6
- package/api/quadratic3.d.ts +15 -0
- package/api/quadratic3.js +38 -0
- package/api/ray.d.ts +4 -3
- package/api/ray.js +6 -7
- package/api/ray3.d.ts +14 -0
- package/api/ray3.js +33 -0
- package/api/rect.d.ts +5 -3
- package/api/rect.js +11 -8
- package/api/sphere.d.ts +4 -3
- package/api/sphere.js +8 -5
- package/api/text.d.ts +4 -3
- package/api/text.js +8 -5
- package/api/triangle.d.ts +7 -4
- package/api/triangle.js +5 -3
- package/api/triangle3.d.ts +14 -0
- package/api/triangle3.js +26 -0
- package/api.d.ts +193 -0
- package/api.js +10 -0
- package/apply-transforms.d.ts +33 -11
- package/apply-transforms.js +24 -4
- package/arc-length.d.ts +18 -4
- package/arc-length.js +18 -3
- package/arc.d.ts +1 -1
- package/area.d.ts +6 -10
- package/area.js +3 -3
- package/as-cubic.d.ts +31 -5
- package/as-cubic.js +86 -24
- package/as-path.d.ts +14 -7
- package/as-path.js +49 -24
- package/as-polygon.d.ts +20 -5
- package/as-polygon.js +46 -12
- package/as-polyline.d.ts +18 -5
- package/as-polyline.js +29 -23
- package/as-sector.d.ts +13 -0
- package/as-sector.js +18 -0
- package/as-svg.d.ts +31 -9
- package/as-svg.js +21 -18
- package/bounds.d.ts +12 -2
- package/bounds.js +15 -0
- package/bpatch.d.ts +26 -1
- package/center-of-weight.d.ts +22 -0
- package/center-of-weight.js +23 -0
- package/center.d.ts +11 -5
- package/center.js +9 -4
- package/centroid-of-bounds.d.ts +12 -0
- package/centroid-of-bounds.js +9 -0
- package/centroid.d.ts +14 -4
- package/centroid.js +16 -17
- package/circle.d.ts +1 -1
- package/classify-point.d.ts +3 -1
- package/classify-point.js +7 -4
- package/clip-convex.d.ts +27 -8
- package/clip-convex.js +52 -17
- package/closest-point.d.ts +1 -1
- package/complex-polygon-from-path.d.ts +1 -1
- package/complex-polygon.d.ts +1 -1
- package/convex-hull.d.ts +9 -2
- package/convex-hull.js +3 -3
- package/convolve.d.ts +72 -0
- package/convolve.js +33 -0
- package/cubic.d.ts +1 -1
- package/cubic.js +7 -7
- package/cubic3.d.ts +8 -0
- package/cubic3.js +14 -0
- package/edges.d.ts +2 -2
- package/ellipse.d.ts +1 -1
- package/extra.d.ts +14 -0
- package/extra.js +5 -0
- package/fit-into-bounds.d.ts +14 -4
- package/fit-into-bounds.js +6 -6
- package/flip.d.ts +21 -5
- package/flip.js +19 -12
- package/from-tessellation.d.ts +54 -0
- package/from-tessellation.js +27 -0
- package/group.d.ts +2 -2
- package/group3.d.ts +16 -0
- package/group3.js +5 -0
- package/index.d.ts +35 -1
- package/index.js +35 -1
- package/internal/bounds.d.ts +3 -4
- package/internal/copy.d.ts +8 -7
- package/internal/copy.js +3 -7
- package/internal/dispatch.d.ts +1 -1
- package/internal/error.d.ts +3 -0
- package/internal/error.js +6 -0
- package/internal/pclike.d.ts +3 -2
- package/internal/pclike.js +6 -0
- package/internal/points-as-shape.d.ts +11 -2
- package/internal/points-as-shape.js +10 -1
- package/internal/split.d.ts +2 -2
- package/internal/split.js +13 -8
- package/internal/transform.d.ts +6 -22
- package/internal/transform.js +2 -21
- package/internal/vertices.d.ts +3 -2
- package/internal/vertices.js +3 -1
- package/intersects.d.ts +5 -4
- package/intersects.js +6 -4
- package/line.d.ts +1 -1
- package/line3.d.ts +6 -0
- package/line3.js +9 -0
- package/map-point.d.ts +1 -1
- package/normalized-path.d.ts +17 -0
- package/normalized-path.js +23 -0
- package/offset.d.ts +16 -2
- package/offset.js +2 -2
- package/package.json +149 -35
- package/path-builder.d.ts +42 -13
- package/path-builder.js +68 -42
- package/path-from-cubics.d.ts +26 -0
- package/path-from-cubics.js +39 -0
- package/path-from-svg.d.ts +1 -1
- package/path-from-svg.js +29 -29
- package/path.d.ts +2 -52
- package/path.js +1 -58
- package/path3.d.ts +16 -0
- package/path3.js +5 -0
- package/plane.d.ts +11 -1
- package/plane.js +3 -0
- package/point-at.d.ts +1 -1
- package/point-inside.d.ts +3 -1
- package/point-inside.js +4 -1
- package/points.d.ts +2 -3
- package/points.js +2 -4
- package/points3.d.ts +5 -0
- package/points3.js +5 -0
- package/polygon.d.ts +5 -5
- package/polygon3.d.ts +5 -0
- package/polygon3.js +5 -0
- package/polyline.d.ts +2 -2
- package/polyline3.d.ts +5 -0
- package/polyline3.js +5 -0
- package/proximity.d.ts +5 -3
- package/proximity.js +2 -2
- package/quad.d.ts +2 -7
- package/quad.js +1 -29
- package/quad3.d.ts +8 -0
- package/quad3.js +30 -0
- package/quadratic.d.ts +1 -1
- package/quadratic3.d.ts +7 -0
- package/quadratic3.js +11 -0
- package/ray.d.ts +1 -1
- package/ray.js +2 -2
- package/ray3.d.ts +5 -0
- package/ray3.js +6 -0
- package/rect.d.ts +1 -1
- package/resample.d.ts +45 -4
- package/resample.js +26 -16
- package/rotate-around-axis.d.ts +33 -0
- package/rotate-around-axis.js +57 -0
- package/rotate.d.ts +15 -2
- package/rotate.js +47 -45
- package/rounded-rect.d.ts +25 -0
- package/rounded-rect.js +18 -0
- package/scale-with-center.d.ts +2 -2
- package/scale.d.ts +24 -2
- package/scale.js +59 -43
- package/scatter.d.ts +1 -1
- package/simplify.d.ts +8 -2
- package/simplify.js +7 -4
- package/smooth-poly.d.ts +27 -0
- package/smooth-poly.js +11 -0
- package/sphere.d.ts +1 -1
- package/split-arclength.d.ts +6 -2
- package/split-at.d.ts +18 -2
- package/split-at.js +66 -34
- package/split-near.d.ts +13 -2
- package/split-near.js +23 -27
- package/subdiv-curve.d.ts +81 -27
- package/subdiv-curve.js +44 -28
- package/tangent-at.d.ts +1 -1
- package/tessellate.d.ts +72 -18
- package/tessellate.js +53 -8
- package/text.d.ts +1 -1
- package/transform-vertices.d.ts +30 -6
- package/transform-vertices.js +36 -38
- package/transform.d.ts +30 -2
- package/transform.js +54 -40
- package/translate.d.ts +12 -2
- package/translate.js +42 -43
- package/triangle.d.ts +1 -1
- package/triangle3.d.ts +6 -0
- package/triangle3.js +8 -0
- package/union.d.ts +11 -2
- package/union.js +6 -7
- package/unmap-point.d.ts +1 -1
- package/vertices.d.ts +3 -3
- package/vertices.js +14 -4
- package/volume.d.ts +1 -1
- package/warp-points.d.ts +35 -4
- package/warp-points.js +2 -0
- package/with-attribs.d.ts +4 -5
- package/internal/rotate.d.ts +0 -5
- package/internal/rotate.js +0 -8
- package/internal/scale.d.ts +0 -5
- package/internal/scale.js +0 -12
- package/internal/translate.d.ts +0 -5
- package/internal/translate.js +0 -8
package/points3.d.ts
ADDED
package/points3.js
ADDED
package/polygon.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attribs } from "
|
|
1
|
+
import type { Attribs } from "./api.js";
|
|
2
2
|
import type { Vec } from "@thi.ng/vectors";
|
|
3
3
|
import { Polygon } from "./api/polygon.js";
|
|
4
4
|
export declare const polygon: (pts?: Iterable<Vec>, attribs?: Attribs) => Polygon;
|
|
@@ -9,7 +9,6 @@ export declare const polygon: (pts?: Iterable<Vec>, attribs?: Attribs) => Polygo
|
|
|
9
9
|
* @param n
|
|
10
10
|
* @param profile
|
|
11
11
|
* @param attribs
|
|
12
|
-
* @returns
|
|
13
12
|
*/
|
|
14
13
|
export declare const star: (r: number, n: number, profile: number[], attribs?: Attribs) => Polygon;
|
|
15
14
|
/**
|
|
@@ -21,10 +20,12 @@ export declare const star: (r: number, n: number, profile: number[], attribs?: A
|
|
|
21
20
|
* vertex will be inset to 50% of the base radius.
|
|
22
21
|
*
|
|
23
22
|
* @example
|
|
24
|
-
* ```ts
|
|
23
|
+
* ```ts tangle:../export/star-with-centroid.ts
|
|
25
24
|
* import { starWithCentroid } from "@thi.ng/geom";
|
|
26
25
|
*
|
|
27
|
-
*
|
|
26
|
+
* console.log(
|
|
27
|
+
* starWithCentroid([100,200], 50, 5, [1, 0.5])
|
|
28
|
+
* );
|
|
28
29
|
* // Polygon {
|
|
29
30
|
* // points: [
|
|
30
31
|
* // [150.000, 200.000],
|
|
@@ -47,7 +48,6 @@ export declare const star: (r: number, n: number, profile: number[], attribs?: A
|
|
|
47
48
|
* @param n
|
|
48
49
|
* @param profile
|
|
49
50
|
* @param attribs
|
|
50
|
-
* @returns
|
|
51
51
|
*/
|
|
52
52
|
export declare const starWithCentroid: (pos: Vec, r: number, n: number, profile: number[], attribs?: Attribs) => Polygon;
|
|
53
53
|
//# sourceMappingURL=polygon.d.ts.map
|
package/polygon3.d.ts
ADDED
package/polygon3.js
ADDED
package/polyline.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Attribs } from "
|
|
1
|
+
import type { Attribs } from "./api.js";
|
|
2
2
|
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
3
|
import { Polyline } from "./api/polyline.js";
|
|
4
|
-
export declare const polyline: (pts
|
|
4
|
+
export declare const polyline: (pts?: Iterable<Vec>, attribs?: Attribs) => Polyline;
|
|
5
5
|
/**
|
|
6
6
|
* Creates a polyline spiral from given params. The number of twists is defined
|
|
7
7
|
* by the angle range. Resolution depends on angle range and number of steps.
|
package/polyline3.d.ts
ADDED
package/polyline3.js
ADDED
package/proximity.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { IShape } from "@thi.ng/geom-api";
|
|
2
1
|
import type { ReadonlyVec } from "@thi.ng/vectors";
|
|
2
|
+
import type { IShape } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Computes {@link closestPoint} on `shape` to `p`, and if successful, returns
|
|
5
|
-
*
|
|
5
|
+
* the distance between that point and `p`, using optionally given `dist`ance
|
|
6
|
+
* function (by default uses Eucledian distance).
|
|
6
7
|
*
|
|
7
8
|
* @param shape
|
|
8
9
|
* @param p
|
|
10
|
+
* @param dist
|
|
9
11
|
*/
|
|
10
|
-
export declare const proximity: (shape: IShape, p: ReadonlyVec) => number | undefined;
|
|
12
|
+
export declare const proximity: (shape: IShape, p: ReadonlyVec, dist?: import("@thi.ng/vectors").DistanceFn) => number | undefined;
|
|
11
13
|
//# sourceMappingURL=proximity.d.ts.map
|
package/proximity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dist } from "@thi.ng/vectors/dist";
|
|
1
|
+
import { dist as $dist } from "@thi.ng/vectors/dist";
|
|
2
2
|
import { closestPoint } from "./closest-point.js";
|
|
3
|
-
const proximity = (shape, p) => {
|
|
3
|
+
const proximity = (shape, p, dist = $dist) => {
|
|
4
4
|
const q = closestPoint(shape, p);
|
|
5
5
|
return q ? dist(p, q) : void 0;
|
|
6
6
|
};
|
package/quad.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import type { Attribs } from "
|
|
2
|
-
import
|
|
3
|
-
import type { Plane } from "./api/plane.js";
|
|
1
|
+
import type { Attribs } from "./api.js";
|
|
2
|
+
import type { Vec } from "@thi.ng/vectors";
|
|
4
3
|
import { Quad } from "./api/quad.js";
|
|
5
|
-
import { Quad3 } from "./api/quad3.js";
|
|
6
4
|
export declare function quad(a: Vec, b: Vec, c: Vec, d: Vec, attribs?: Attribs): Quad;
|
|
7
5
|
export declare function quad(pts: Iterable<Vec>, attribs?: Attribs): Quad;
|
|
8
|
-
export declare function quad3(a: Vec, b: Vec, c: Vec, d: Vec, attribs?: Attribs): Quad;
|
|
9
|
-
export declare function quad3(pts: Iterable<Vec>, attribs?: Attribs): Quad;
|
|
10
|
-
export declare const quadOnPlane: (plane: Plane, pos: ReadonlyVec, size: number | ReadonlyVec, attribs?: Attribs) => Quad3;
|
|
11
6
|
//# sourceMappingURL=quad.d.ts.map
|
package/quad.js
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
|
-
import { closestPointPlane } from "@thi.ng/geom-closest-point/plane";
|
|
3
|
-
import { alignmentQuat } from "@thi.ng/matrices/alignment-quat";
|
|
4
|
-
import { mulVQ } from "@thi.ng/matrices/mulv";
|
|
5
|
-
import { add3 } from "@thi.ng/vectors/add";
|
|
6
|
-
import { Z3 } from "@thi.ng/vectors/api";
|
|
7
1
|
import { Quad } from "./api/quad.js";
|
|
8
|
-
import { Quad3 } from "./api/quad3.js";
|
|
9
|
-
import { __argAttribs } from "./internal/args.js";
|
|
10
2
|
import { __pclike } from "./internal/pclike.js";
|
|
11
3
|
function quad(...args) {
|
|
12
4
|
return __pclike(Quad, args);
|
|
13
5
|
}
|
|
14
|
-
function quad3(...args) {
|
|
15
|
-
const attr = __argAttribs(args);
|
|
16
|
-
return new Quad3(args.length === 1 ? args[0] : args, attr);
|
|
17
|
-
}
|
|
18
|
-
const quadOnPlane = (plane, pos, size, attribs) => {
|
|
19
|
-
pos = closestPointPlane(pos, plane.normal, plane.w);
|
|
20
|
-
const [w, h] = isNumber(size) ? [size, size] : size;
|
|
21
|
-
const q = alignmentQuat(Z3, plane.normal);
|
|
22
|
-
return new Quad3(
|
|
23
|
-
[
|
|
24
|
-
[-w, -h, 0],
|
|
25
|
-
[w, -h, 0],
|
|
26
|
-
[w, h, 0],
|
|
27
|
-
[-w, h, 0]
|
|
28
|
-
].map((p) => add3(null, mulVQ(null, q, p), pos)),
|
|
29
|
-
attribs
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
6
|
export {
|
|
33
|
-
quad
|
|
34
|
-
quad3,
|
|
35
|
-
quadOnPlane
|
|
7
|
+
quad
|
|
36
8
|
};
|
package/quad3.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Attribs } from "./api.js";
|
|
2
|
+
import { type ReadonlyVec, type Vec } from "@thi.ng/vectors/api";
|
|
3
|
+
import type { Plane } from "./api/plane.js";
|
|
4
|
+
import { Quad3 } from "./api/quad3.js";
|
|
5
|
+
export declare function quad3(a: Vec, b: Vec, c: Vec, d: Vec, attribs?: Attribs): Quad3;
|
|
6
|
+
export declare function quad3(pts: Iterable<Vec>, attribs?: Attribs): Quad3;
|
|
7
|
+
export declare const quadOnPlane: (plane: Plane, pos: ReadonlyVec, size: number | ReadonlyVec, attribs?: Attribs) => Quad3;
|
|
8
|
+
//# sourceMappingURL=quad3.d.ts.map
|
package/quad3.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
|
+
import { closestPointPlane } from "@thi.ng/geom-closest-point/plane";
|
|
3
|
+
import { alignmentQuat } from "@thi.ng/matrices/alignment-quat";
|
|
4
|
+
import { mulVQ } from "@thi.ng/matrices/mulv";
|
|
5
|
+
import { add3 } from "@thi.ng/vectors/add";
|
|
6
|
+
import { Z3 } from "@thi.ng/vectors/api";
|
|
7
|
+
import { Quad3 } from "./api/quad3.js";
|
|
8
|
+
import { __argAttribs } from "./internal/args.js";
|
|
9
|
+
function quad3(...args) {
|
|
10
|
+
const attr = __argAttribs(args);
|
|
11
|
+
return new Quad3(args.length === 1 ? args[0] : args, attr);
|
|
12
|
+
}
|
|
13
|
+
const quadOnPlane = (plane, pos, size, attribs) => {
|
|
14
|
+
pos = closestPointPlane(pos, plane.normal, plane.w);
|
|
15
|
+
const [w, h] = isNumber(size) ? [size, size] : size;
|
|
16
|
+
const q = alignmentQuat(Z3, plane.normal);
|
|
17
|
+
return new Quad3(
|
|
18
|
+
[
|
|
19
|
+
[-w, -h, 0],
|
|
20
|
+
[w, -h, 0],
|
|
21
|
+
[w, h, 0],
|
|
22
|
+
[-w, h, 0]
|
|
23
|
+
].map((p) => add3(null, mulVQ(null, q, p), pos)),
|
|
24
|
+
attribs
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
quad3,
|
|
29
|
+
quadOnPlane
|
|
30
|
+
};
|
package/quadratic.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attribs } from "
|
|
1
|
+
import type { Attribs } from "./api.js";
|
|
2
2
|
import type { Vec } from "@thi.ng/vectors";
|
|
3
3
|
import { Quadratic } from "./api/quadratic.js";
|
|
4
4
|
export declare function quadratic(a: Vec, b: Vec, c: Vec, attribs?: Attribs): Quadratic;
|
package/quadratic3.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Attribs } from "./api.js";
|
|
2
|
+
import type { Vec } from "@thi.ng/vectors";
|
|
3
|
+
import { Quadratic3 } from "./api/quadratic3.js";
|
|
4
|
+
export declare function quadratic3(a: Vec, b: Vec, c: Vec, attribs?: Attribs): Quadratic3;
|
|
5
|
+
export declare function quadratic3(pts: Iterable<Vec>, attribs?: Attribs): Quadratic3;
|
|
6
|
+
export declare const quadraticFromLine3: (a: Vec, b: Vec, attribs?: Attribs) => Quadratic3;
|
|
7
|
+
//# sourceMappingURL=quadratic3.d.ts.map
|
package/quadratic3.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { quadraticFromLine as _line } from "@thi.ng/geom-splines/quadratic-line";
|
|
2
|
+
import { Quadratic3 } from "./api/quadratic3.js";
|
|
3
|
+
import { __pclike } from "./internal/pclike.js";
|
|
4
|
+
function quadratic3(...args) {
|
|
5
|
+
return __pclike(Quadratic3, args);
|
|
6
|
+
}
|
|
7
|
+
const quadraticFromLine3 = (a, b, attribs) => new Quadratic3(_line(a, b), attribs);
|
|
8
|
+
export {
|
|
9
|
+
quadratic3,
|
|
10
|
+
quadraticFromLine3
|
|
11
|
+
};
|
package/ray.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attribs } from "
|
|
1
|
+
import type { Attribs } from "./api.js";
|
|
2
2
|
import type { Vec } from "@thi.ng/vectors";
|
|
3
3
|
import { Ray } from "./api/ray.js";
|
|
4
4
|
export declare const ray: (pos: Vec, dir: Vec, attribs?: Attribs, normalize?: boolean) => Ray;
|
package/ray.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalize2 } from "@thi.ng/vectors/normalize";
|
|
2
2
|
import { Ray } from "./api/ray.js";
|
|
3
|
-
const ray = (pos, dir, attribs, normalize = true) => new Ray(pos, normalize ?
|
|
3
|
+
const ray = (pos, dir, attribs, normalize = true) => new Ray(pos, normalize ? normalize2(null, dir) : dir, attribs);
|
|
4
4
|
export {
|
|
5
5
|
ray
|
|
6
6
|
};
|
package/ray3.d.ts
ADDED
package/ray3.js
ADDED
package/rect.d.ts
CHANGED
package/resample.d.ts
CHANGED
|
@@ -1,27 +1,68 @@
|
|
|
1
1
|
import type { MultiFn2 } from "@thi.ng/defmulti";
|
|
2
|
-
import type { IShape, SamplingOpts } from "
|
|
2
|
+
import type { IShape, IShape2, IShape3, SamplingOpts } from "./api.js";
|
|
3
|
+
import type { ComplexPolygon } from "./api/complex-polygon.js";
|
|
4
|
+
import type { Cubic } from "./api/cubic.js";
|
|
5
|
+
import type { Cubic3 } from "./api/cubic3.js";
|
|
6
|
+
import type { Group } from "./api/group.js";
|
|
7
|
+
import type { Line } from "./api/line.js";
|
|
8
|
+
import type { Line3 } from "./api/line3.js";
|
|
9
|
+
import type { Polygon } from "./api/polygon.js";
|
|
10
|
+
import type { Polygon3 } from "./api/polygon3.js";
|
|
11
|
+
import type { Polyline } from "./api/polyline.js";
|
|
12
|
+
import type { Polyline3 } from "./api/polyline3.js";
|
|
13
|
+
import type { Quad3 } from "./api/quad3.js";
|
|
14
|
+
import type { Quadratic } from "./api/quadratic.js";
|
|
15
|
+
import type { Quadratic3 } from "./api/quadratic3.js";
|
|
3
16
|
/**
|
|
4
|
-
*
|
|
17
|
+
* Function overrides for {@link resample}.
|
|
18
|
+
*/
|
|
19
|
+
export type ResampleFn = {
|
|
20
|
+
(shape: ComplexPolygon, opts: number | Partial<SamplingOpts>): ComplexPolygon;
|
|
21
|
+
(shape: Cubic, opts: number | Partial<SamplingOpts>): Polyline;
|
|
22
|
+
(shape: Cubic3, opts: number | Partial<SamplingOpts>): Polyline3;
|
|
23
|
+
(shape: Group, opts: number | Partial<SamplingOpts>): Group;
|
|
24
|
+
(shape: Line, opts: number | Partial<SamplingOpts>): Polyline;
|
|
25
|
+
(shape: Line3, opts: number | Partial<SamplingOpts>): Polyline3;
|
|
26
|
+
(shape: Polyline, opts: number | Partial<SamplingOpts>): Polyline;
|
|
27
|
+
(shape: Polyline3, opts: number | Partial<SamplingOpts>): Polyline3;
|
|
28
|
+
(shape: Quadratic, opts: number | Partial<SamplingOpts>): Polyline;
|
|
29
|
+
(shape: Quadratic3, opts: number | Partial<SamplingOpts>): Polyline3;
|
|
30
|
+
(shape: Quad3, opts: number | Partial<SamplingOpts>): Polygon3;
|
|
31
|
+
(shape: IShape2, opts: number | Partial<SamplingOpts>): Polygon;
|
|
32
|
+
(shape: IShape3, opts: number | Partial<SamplingOpts>): IShape3;
|
|
33
|
+
} & MultiFn2<IShape, number | Partial<SamplingOpts>, IShape>;
|
|
34
|
+
/**
|
|
35
|
+
* Resamples given shape with given options and returns result as polygon (if
|
|
5
36
|
* closed) or polyline (if open).
|
|
6
37
|
*
|
|
7
38
|
* @remarks
|
|
8
39
|
* If the shape has a `__samples` attribute, it will be removed in the result to
|
|
9
|
-
*
|
|
40
|
+
* ensure idempotent behavior.
|
|
10
41
|
*
|
|
11
42
|
* Currently implemented for:
|
|
12
43
|
*
|
|
44
|
+
* - {@link Arc}
|
|
13
45
|
* - {@link Circle}
|
|
14
46
|
* - {@link ComplexPolygon}
|
|
47
|
+
* - {@link Cubic}
|
|
48
|
+
* - {@link Cubic3}
|
|
15
49
|
* - {@link Ellipse}
|
|
16
50
|
* - {@link Line}
|
|
51
|
+
* - {@link Line3}
|
|
17
52
|
* - {@link Polygon}
|
|
53
|
+
* - {@link Polygon3}
|
|
18
54
|
* - {@link Polyline}
|
|
55
|
+
* - {@link Polyline3}
|
|
19
56
|
* - {@link Quad}
|
|
57
|
+
* - {@link Quad3}
|
|
58
|
+
* - {@link Quadratic}
|
|
59
|
+
* - {@link Quadratic3}
|
|
20
60
|
* - {@link Rect}
|
|
21
61
|
* - {@link Triangle}
|
|
62
|
+
* - {@link Triangle3}
|
|
22
63
|
*
|
|
23
64
|
* @param shape
|
|
24
65
|
* @param opts
|
|
25
66
|
*/
|
|
26
|
-
export declare const resample:
|
|
67
|
+
export declare const resample: ResampleFn;
|
|
27
68
|
//# sourceMappingURL=resample.d.ts.map
|
package/resample.js
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
import { defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
2
|
import { resample as _resample } from "@thi.ng/geom-resample/resample";
|
|
3
|
-
import { ComplexPolygon } from "./api/complex-polygon.js";
|
|
4
|
-
import { Polygon } from "./api/polygon.js";
|
|
5
|
-
import { Polyline } from "./api/polyline.js";
|
|
6
3
|
import { asPolygon } from "./as-polygon.js";
|
|
7
|
-
import {
|
|
4
|
+
import { asPolyline } from "./as-polyline.js";
|
|
8
5
|
import { __dispatch } from "./internal/dispatch.js";
|
|
9
6
|
const resample = defmulti(
|
|
10
7
|
__dispatch,
|
|
11
8
|
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
arc: "$aspolyline",
|
|
10
|
+
circle: "$aspoly",
|
|
11
|
+
complexpoly: "group",
|
|
12
|
+
cubic: "$aspolyline",
|
|
13
|
+
cubic3: "$aspolyline",
|
|
14
|
+
ellipse: "$aspoly",
|
|
15
|
+
line: "$aspolyline",
|
|
16
|
+
line3: "$aspolyline",
|
|
17
|
+
poly3: "poly",
|
|
18
|
+
polyline3: "polyline",
|
|
19
|
+
quad: "$aspoly",
|
|
20
|
+
quad3: "$aspoly",
|
|
21
|
+
quadratic: "$aspolyline",
|
|
22
|
+
quadratic3: "$aspolyline",
|
|
23
|
+
rect: "$aspoly",
|
|
24
|
+
tri: "$aspoly",
|
|
25
|
+
tri3: "$aspoly"
|
|
17
26
|
},
|
|
18
27
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
$aspoly: ($, opts) => asPolygon($, opts)[0],
|
|
29
|
+
$aspolyline: ($, opts) => asPolyline($, opts)[0],
|
|
30
|
+
group: ($, opts) => $.copyTransformed((child) => resample(child, opts)),
|
|
31
|
+
poly: ($, opts) => $.copyTransformed(
|
|
32
|
+
(points) => _resample(points, opts, true, true)
|
|
24
33
|
),
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
polyline: ($, opts) => $.copyTransformed(
|
|
35
|
+
(points) => _resample(points, opts, false, true)
|
|
36
|
+
)
|
|
27
37
|
}
|
|
28
38
|
);
|
|
29
39
|
export {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MultiFn3 } from "@thi.ng/defmulti";
|
|
2
|
+
import type { ReadonlyVec } from "@thi.ng/vectors";
|
|
3
|
+
import type { IShape3 } from "./api.js";
|
|
4
|
+
export type RotateAroundAxisFn = {
|
|
5
|
+
<T extends IShape3>(shape: T, axis: ReadonlyVec, theta: number): T;
|
|
6
|
+
} & MultiFn3<IShape3, ReadonlyVec, number, IShape3>;
|
|
7
|
+
/**
|
|
8
|
+
* Rotates given 3D shape by `theta` (in radians) around `axis`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Currently implemented for:
|
|
12
|
+
*
|
|
13
|
+
* - {@link Cubic3}
|
|
14
|
+
* - {@link Group3}
|
|
15
|
+
* - {@link Polygon3}
|
|
16
|
+
* - {@link Polyline3}
|
|
17
|
+
* - {@link Line3}
|
|
18
|
+
* - {@link Path3}
|
|
19
|
+
* - {@link Points3}
|
|
20
|
+
* - {@link Quad3}
|
|
21
|
+
* - {@link Quadratic3}
|
|
22
|
+
* - {@link Ray3}
|
|
23
|
+
* - {@link Triangle3}
|
|
24
|
+
*
|
|
25
|
+
* @param shape
|
|
26
|
+
* @param axis
|
|
27
|
+
* @param theta
|
|
28
|
+
*/
|
|
29
|
+
export declare const rotateAroundAxis: RotateAroundAxisFn;
|
|
30
|
+
export declare const rotateX: (shape: IShape3, theta: number) => IShape3;
|
|
31
|
+
export declare const rotateY: (shape: IShape3, theta: number) => IShape3;
|
|
32
|
+
export declare const rotateZ: (shape: IShape3, theta: number) => IShape3;
|
|
33
|
+
//# sourceMappingURL=rotate-around-axis.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
|
+
import { mulV33 } from "@thi.ng/matrices/mulv";
|
|
3
|
+
import { rotationAroundAxis33 } from "@thi.ng/matrices/rotation-around-axis";
|
|
4
|
+
import { X3, Y3, Z3 } from "@thi.ng/vectors/api";
|
|
5
|
+
import { rotateAroundAxis3 } from "@thi.ng/vectors/rotate-around-axis";
|
|
6
|
+
import { Ray3 } from "./api/ray3.js";
|
|
7
|
+
import { __copyAttribs } from "./internal/copy.js";
|
|
8
|
+
import { __dispatch } from "./internal/dispatch.js";
|
|
9
|
+
import { __segmentTransformer } from "./internal/transform.js";
|
|
10
|
+
const rotateAroundAxis = defmulti(
|
|
11
|
+
__dispatch,
|
|
12
|
+
{
|
|
13
|
+
cubic3: "points3",
|
|
14
|
+
line3: "points3",
|
|
15
|
+
poly3: "points3",
|
|
16
|
+
polyline3: "points3",
|
|
17
|
+
quad3: "points3",
|
|
18
|
+
quadratic3: "points3",
|
|
19
|
+
tri3: "points3"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
group3: ($, axis, theta) => $.copyTransformed(
|
|
23
|
+
(x) => rotateAroundAxis(x, axis, theta)
|
|
24
|
+
),
|
|
25
|
+
path3: ($, axis, theta) => {
|
|
26
|
+
const mat = rotationAroundAxis33([], axis, theta);
|
|
27
|
+
return $.copyTransformed(
|
|
28
|
+
__segmentTransformer(
|
|
29
|
+
(geo) => rotateAroundAxis(geo, axis, theta),
|
|
30
|
+
(p) => mulV33([], mat, p)
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
points3: ($, axis, theta) => {
|
|
35
|
+
const mat = rotationAroundAxis33([], axis, theta);
|
|
36
|
+
return $.copyTransformed(
|
|
37
|
+
(points) => points.map((p) => mulV33([], mat, p))
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
ray3: ($, axis, theta) => {
|
|
41
|
+
return new Ray3(
|
|
42
|
+
rotateAroundAxis3([], $.pos, axis, theta),
|
|
43
|
+
rotateAroundAxis3([], $.dir, axis, theta),
|
|
44
|
+
__copyAttribs($.attribs)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
const rotateX = (shape, theta) => rotateAroundAxis(shape, X3, theta);
|
|
50
|
+
const rotateY = (shape, theta) => rotateAroundAxis(shape, Y3, theta);
|
|
51
|
+
const rotateZ = (shape, theta) => rotateAroundAxis(shape, Z3, theta);
|
|
52
|
+
export {
|
|
53
|
+
rotateAroundAxis,
|
|
54
|
+
rotateX,
|
|
55
|
+
rotateY,
|
|
56
|
+
rotateZ
|
|
57
|
+
};
|
package/rotate.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { MultiFn2 } from "@thi.ng/defmulti";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IShape2 } from "./api.js";
|
|
3
|
+
import type { Arc } from "./api/arc.js";
|
|
4
|
+
import type { Ellipse } from "./api/ellipse.js";
|
|
5
|
+
import type { Path } from "./api/path.js";
|
|
6
|
+
import type { Polygon } from "./api/polygon.js";
|
|
7
|
+
import type { Rect } from "./api/rect.js";
|
|
8
|
+
export type RotateFn = {
|
|
9
|
+
(shape: Arc, theta: number): Path;
|
|
10
|
+
(shape: Ellipse, theta: number): Path;
|
|
11
|
+
(shape: Rect, theta: number): Polygon;
|
|
12
|
+
<T extends IShape2>(shape: T, theta: number): T;
|
|
13
|
+
} & MultiFn2<IShape2, number, IShape2>;
|
|
3
14
|
/**
|
|
4
15
|
* Rotates given 2D shape by `theta` (in radians).
|
|
5
16
|
*
|
|
@@ -7,10 +18,12 @@ import type { IShape } from "@thi.ng/geom-api";
|
|
|
7
18
|
* Currently implemented for:
|
|
8
19
|
*
|
|
9
20
|
* - {@link Arc}
|
|
21
|
+
* - {@link BPatch}
|
|
10
22
|
* - {@link Circle}
|
|
11
23
|
* - {@link ComplexPolygon}
|
|
12
24
|
* - {@link Cubic}
|
|
13
25
|
* - {@link Ellipse}
|
|
26
|
+
* - {@link Extra}
|
|
14
27
|
* - {@link Group}
|
|
15
28
|
* - {@link Line}
|
|
16
29
|
* - {@link Path}
|
|
@@ -27,5 +40,5 @@ import type { IShape } from "@thi.ng/geom-api";
|
|
|
27
40
|
* @param shape
|
|
28
41
|
* @param theta
|
|
29
42
|
*/
|
|
30
|
-
export declare const rotate:
|
|
43
|
+
export declare const rotate: RotateFn;
|
|
31
44
|
//# sourceMappingURL=rotate.d.ts.map
|
package/rotate.js
CHANGED
|
@@ -1,68 +1,70 @@
|
|
|
1
1
|
import { defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
|
+
import { mulV22 } from "@thi.ng/matrices/mulv";
|
|
3
|
+
import { rotation22 } from "@thi.ng/matrices/rotation";
|
|
2
4
|
import { rotate as $rotate } from "@thi.ng/vectors/rotate";
|
|
3
5
|
import { Circle } from "./api/circle.js";
|
|
4
|
-
import { ComplexPolygon } from "./api/complex-polygon.js";
|
|
5
|
-
import { Cubic } from "./api/cubic.js";
|
|
6
|
-
import { Line } from "./api/line.js";
|
|
7
|
-
import { Path } from "./api/path.js";
|
|
8
|
-
import { Points } from "./api/points.js";
|
|
9
|
-
import { Polygon } from "./api/polygon.js";
|
|
10
|
-
import { Polyline } from "./api/polyline.js";
|
|
11
|
-
import { Quad } from "./api/quad.js";
|
|
12
|
-
import { Quadratic } from "./api/quadratic.js";
|
|
13
6
|
import { Ray } from "./api/ray.js";
|
|
14
7
|
import { Text } from "./api/text.js";
|
|
15
|
-
import { Triangle } from "./api/triangle.js";
|
|
16
8
|
import { asPath } from "./as-path.js";
|
|
17
9
|
import { asPolygon } from "./as-polygon.js";
|
|
18
10
|
import { __copyAttribs } from "./internal/copy.js";
|
|
19
11
|
import { __dispatch } from "./internal/dispatch.js";
|
|
20
|
-
import {
|
|
12
|
+
import { __ensureNoArc } from "./internal/error.js";
|
|
21
13
|
import { __segmentTransformer } from "./internal/transform.js";
|
|
22
14
|
const rotate = defmulti(
|
|
23
15
|
__dispatch,
|
|
24
|
-
{},
|
|
25
16
|
{
|
|
26
|
-
arc:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
arc: "$aspath",
|
|
18
|
+
bpatch: "points",
|
|
19
|
+
complexpoly: "group",
|
|
20
|
+
cubic: "points",
|
|
21
|
+
ellipse: "$aspath",
|
|
22
|
+
line: "points",
|
|
23
|
+
poly: "points",
|
|
24
|
+
polyline: "points",
|
|
25
|
+
quad: "points",
|
|
26
|
+
quadratic: "points",
|
|
27
|
+
rect: "$aspoly",
|
|
28
|
+
tri: "points"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
$aspath: ($, theta) => rotate(asPath($), theta),
|
|
32
|
+
$aspoly: ($, theta) => rotate(asPolygon($)[0], theta),
|
|
33
|
+
circle: ($, theta) => new Circle(
|
|
34
|
+
$rotate([], $.pos, theta),
|
|
35
|
+
$.r,
|
|
36
|
+
__copyAttribs($.attribs)
|
|
35
37
|
),
|
|
36
|
-
|
|
37
|
-
ellipse: ($, theta) => rotate(asPath($), theta),
|
|
38
|
+
extra: ($) => $,
|
|
38
39
|
group: ($, theta) => $.copyTransformed((x) => rotate(x, theta)),
|
|
39
|
-
line: tx(Line),
|
|
40
40
|
path: ($, theta) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
const mat = rotation22([], theta);
|
|
42
|
+
return $.copyTransformed(
|
|
43
|
+
__segmentTransformer(
|
|
44
|
+
(geo) => {
|
|
45
|
+
__ensureNoArc(geo);
|
|
46
|
+
return rotate(geo, theta);
|
|
47
|
+
},
|
|
48
|
+
(p) => mulV22([], mat, p)
|
|
49
|
+
)
|
|
49
50
|
);
|
|
50
51
|
},
|
|
51
|
-
points:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
quadratic: tx(Quadratic),
|
|
56
|
-
ray: ($, theta) => {
|
|
57
|
-
return new Ray(
|
|
58
|
-
$rotate([], $.pos, theta),
|
|
59
|
-
$rotate([], $.dir, theta),
|
|
60
|
-
__copyAttribs($)
|
|
52
|
+
points: ($, theta) => {
|
|
53
|
+
const mat = rotation22([], theta);
|
|
54
|
+
return $.copyTransformed(
|
|
55
|
+
(points) => points.map((p) => mulV22([], mat, p))
|
|
61
56
|
);
|
|
62
57
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
ray: ($, theta) => new Ray(
|
|
59
|
+
$rotate([], $.pos, theta),
|
|
60
|
+
$rotate([], $.dir, theta),
|
|
61
|
+
__copyAttribs($.attribs)
|
|
62
|
+
),
|
|
63
|
+
text: ($, theta) => new Text(
|
|
64
|
+
$rotate([], $.pos, theta),
|
|
65
|
+
$.body,
|
|
66
|
+
__copyAttribs($.attribs)
|
|
67
|
+
)
|
|
66
68
|
}
|
|
67
69
|
);
|
|
68
70
|
export {
|