@nakafa/aksara-contracts 0.32.0 → 0.34.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/dist/math/arc-precision.d.ts +7 -0
- package/dist/math/arc-precision.js +82 -0
- package/dist/math/bounds.d.ts +7 -0
- package/dist/math/bounds.js +131 -0
- package/dist/math/collision.d.ts +7 -0
- package/dist/math/collision.js +41 -0
- package/dist/math/coordinate.d.ts +32 -0
- package/dist/math/coordinate.js +61 -0
- package/dist/math/extent.d.ts +51 -0
- package/dist/math/extent.js +143 -0
- package/dist/math/intersection.d.ts +19 -0
- package/dist/math/intersection.js +41 -0
- package/dist/math/plane.d.ts +32 -68
- package/dist/math/plane.js +21 -15
- package/dist/math/precision.d.ts +26 -0
- package/dist/math/precision.js +114 -0
- package/dist/math/proximity.d.ts +12 -0
- package/dist/math/proximity.js +138 -0
- package/dist/math/rational.d.ts +22 -0
- package/dist/math/rational.js +42 -0
- package/dist/math/resolution.d.ts +9 -0
- package/dist/math/resolution.js +110 -0
- package/dist/math/scene.d.ts +10 -0
- package/dist/math/scene.js +115 -0
- package/dist/math/space.d.ts +4 -84
- package/dist/math/space.js +7 -15
- package/dist/math/visual.d.ts +41 -227
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { arcCurvatureUnresolved, arcEndpointAxesUnresolved, arcEndpointsUnresolved, } from "#contracts/math/arc-precision";
|
|
2
|
+
import { concentricRadiusCollisionPaths, coordinateCollisionPaths, } from "#contracts/math/collision";
|
|
3
|
+
import { pathAxes } from "#contracts/math/coordinate";
|
|
4
|
+
import { axisEnvelopePairs, axisSpan, measureUnresolved, polygonAltitudeUnresolved, quadraticCurvatureUnresolved, renderThreshold, spanUnresolved, visiblePathResolvable, } from "#contracts/math/precision";
|
|
5
|
+
import { planeSceneCoordinates, spaceSceneCoordinates, } from "#contracts/math/scene";
|
|
6
|
+
/** One stable authoring failure for geometry below renderer resolution. */
|
|
7
|
+
export const MATH_VISUAL_RESOLUTION_MESSAGE = "Expected every non-zero mathematical visual delta to be at least 2^-23 of its combined render envelope.";
|
|
8
|
+
/** Places the shared resolution failure at one authored schema path. */
|
|
9
|
+
function issue(path) {
|
|
10
|
+
return { issue: MATH_VISUAL_RESOLUTION_MESSAGE, path };
|
|
11
|
+
}
|
|
12
|
+
/** Removes repeated issue paths while preserving first-cause order. */
|
|
13
|
+
function uniqueIssues(issues) {
|
|
14
|
+
return [
|
|
15
|
+
...new Map(issues.map((candidate) => [JSON.stringify(candidate.path), candidate])).values(),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
/** Reports one non-zero authored measure below the scene threshold. */
|
|
19
|
+
function measureIssue(value, threshold, path) {
|
|
20
|
+
return measureUnresolved(value, threshold) ? [issue(path)] : [];
|
|
21
|
+
}
|
|
22
|
+
/** Checks polygon altitude and infinite-path visible extent. */
|
|
23
|
+
function objectResolutionIssues(frame, object, index, threshold) {
|
|
24
|
+
const root = ["objects", index];
|
|
25
|
+
if (object.kind === "polygon") {
|
|
26
|
+
return polygonAltitudeUnresolved(object.vertices, threshold)
|
|
27
|
+
? [issue(root)]
|
|
28
|
+
: [];
|
|
29
|
+
}
|
|
30
|
+
if (object.kind !== "line" && object.kind !== "ray") {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const [from, through] = object.kind === "line" ? object.through : [object.from, object.through];
|
|
34
|
+
return visiblePathResolvable(object.kind, pathAxes(frame, from, through), threshold)
|
|
35
|
+
? []
|
|
36
|
+
: [issue(root)];
|
|
37
|
+
}
|
|
38
|
+
/** Applies plane-specific measure and exact curve-resolution checks. */
|
|
39
|
+
function planeObjectIssues(frame, object, index, threshold) {
|
|
40
|
+
const root = ["objects", index];
|
|
41
|
+
if (object.kind === "circle") {
|
|
42
|
+
return measureIssue(object.radius, threshold, [...root, "radius"]);
|
|
43
|
+
}
|
|
44
|
+
if (object.kind === "arc") {
|
|
45
|
+
const radiusIssues = measureIssue(object.radius, threshold, [
|
|
46
|
+
...root,
|
|
47
|
+
"radius",
|
|
48
|
+
]);
|
|
49
|
+
const shapeUnresolved = arcEndpointsUnresolved(object.radius, object.sweepDegrees, threshold) ||
|
|
50
|
+
arcCurvatureUnresolved(object.radius, object.sweepDegrees, threshold);
|
|
51
|
+
if (shapeUnresolved) {
|
|
52
|
+
return [...radiusIssues, issue([...root, "sweepDegrees"])];
|
|
53
|
+
}
|
|
54
|
+
return arcEndpointAxesUnresolved(object.radius, object.startDegrees, object.sweepDegrees, threshold)
|
|
55
|
+
? [...radiusIssues, issue(root)]
|
|
56
|
+
: radiusIssues;
|
|
57
|
+
}
|
|
58
|
+
if (object.kind === "quadratic") {
|
|
59
|
+
const domainSpan = axisSpan(object.domain);
|
|
60
|
+
const domainIssues = spanUnresolved(object.domain, threshold)
|
|
61
|
+
? [issue([...root, "domain"])]
|
|
62
|
+
: [];
|
|
63
|
+
return quadraticCurvatureUnresolved(object.coefficients.a, domainSpan, threshold)
|
|
64
|
+
? [...domainIssues, issue([...root, "coefficients", "a"])]
|
|
65
|
+
: domainIssues;
|
|
66
|
+
}
|
|
67
|
+
return objectResolutionIssues(frame, object, index, threshold);
|
|
68
|
+
}
|
|
69
|
+
/** Reports every frame axis whose non-zero span collapses in the envelope. */
|
|
70
|
+
function frameIssues(entries, threshold) {
|
|
71
|
+
return entries.flatMap(({ axis, range }) => spanUnresolved(range, threshold) ? [issue(["frame", axis])] : []);
|
|
72
|
+
}
|
|
73
|
+
/** Reports every plane delta that a normalized renderer cannot preserve. */
|
|
74
|
+
export function planeResolutionIssues(frame, objects, labels, view) {
|
|
75
|
+
const threshold = renderThreshold([frame.x, frame.y], view.padding ?? 0);
|
|
76
|
+
return uniqueIssues([
|
|
77
|
+
...frameIssues([
|
|
78
|
+
{ axis: "x", range: frame.x },
|
|
79
|
+
{ axis: "y", range: frame.y },
|
|
80
|
+
], threshold),
|
|
81
|
+
...measureIssue(view.padding ?? 0, threshold, ["view", "padding"]),
|
|
82
|
+
...coordinateCollisionPaths(planeSceneCoordinates(frame, objects, labels, threshold), threshold).map(issue),
|
|
83
|
+
...concentricRadiusCollisionPaths(objects, threshold).map(issue),
|
|
84
|
+
...objects.flatMap((object, index) => planeObjectIssues(frame, object, index, threshold)),
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
/** Reports every space delta that a normalized renderer cannot preserve. */
|
|
88
|
+
export function spaceResolutionIssues(frame, objects, labels, view) {
|
|
89
|
+
const envelopePairs = view.kind === "camera"
|
|
90
|
+
? [
|
|
91
|
+
...axisEnvelopePairs(frame.x, view.position.x, view.target.x),
|
|
92
|
+
...axisEnvelopePairs(frame.y, view.position.y, view.target.y),
|
|
93
|
+
...axisEnvelopePairs(frame.z, view.position.z, view.target.z),
|
|
94
|
+
]
|
|
95
|
+
: [];
|
|
96
|
+
const threshold = renderThreshold([frame.x, frame.y, frame.z], view.kind === "fit" ? (view.padding ?? 0) : 0, envelopePairs);
|
|
97
|
+
return uniqueIssues([
|
|
98
|
+
...frameIssues([
|
|
99
|
+
{ axis: "x", range: frame.x },
|
|
100
|
+
{ axis: "y", range: frame.y },
|
|
101
|
+
{ axis: "z", range: frame.z },
|
|
102
|
+
], threshold),
|
|
103
|
+
...measureIssue(view.kind === "fit" ? (view.padding ?? 0) : 0, threshold, [
|
|
104
|
+
"view",
|
|
105
|
+
"padding",
|
|
106
|
+
]),
|
|
107
|
+
...coordinateCollisionPaths(spaceSceneCoordinates(frame, objects, labels, view, threshold), threshold).map(issue),
|
|
108
|
+
...objects.flatMap((object, index) => objectResolutionIssues(frame, object, index, threshold)),
|
|
109
|
+
]);
|
|
110
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SceneCoordinate, type ScenePath } from "#contracts/math/coordinate";
|
|
2
|
+
import type { PlaneLabelAnchor, PlaneMathFrame, PlaneMathObject } from "#contracts/math/plane";
|
|
3
|
+
import { type RenderThreshold } from "#contracts/math/precision";
|
|
4
|
+
import type { SpaceLabelAnchor, SpaceMathFrame, SpaceMathObject, SpaceMathView } from "#contracts/math/space";
|
|
5
|
+
/** Owns one stable path for radial geometry-resolution failures. */
|
|
6
|
+
export declare function radialGeometryPath(kind: "arc" | "circle", index: number): ScenePath;
|
|
7
|
+
/** Projects one plane scene into a single ordered exact coordinate stream. */
|
|
8
|
+
export declare function planeSceneCoordinates(frame: PlaneMathFrame, objects: readonly PlaneMathObject[], labels: readonly PlaneLabelAnchor[], threshold: RenderThreshold): SceneCoordinate[];
|
|
9
|
+
/** Projects one space scene into a single ordered exact coordinate stream. */
|
|
10
|
+
export declare function spaceSceneCoordinates(frame: SpaceMathFrame, objects: readonly SpaceMathObject[], labels: readonly SpaceLabelAnchor[], view: SpaceMathView, threshold: RenderThreshold): SceneCoordinate[];
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { BigDecimal } from "effect";
|
|
2
|
+
import { arcCurvatureUnresolved, arcEndpointsUnresolved, } from "#contracts/math/arc-precision";
|
|
3
|
+
import { clippedPathCoordinates, sceneCoordinate as coordinate, frameCoordinates, pointCoordinates, } from "#contracts/math/coordinate";
|
|
4
|
+
import { cuboidExtents, quadraticExtrema, radialOffsets, } from "#contracts/math/extent";
|
|
5
|
+
import { axisSpan, measureUnresolved, quadraticCurvatureUnresolved, spanUnresolved, } from "#contracts/math/precision";
|
|
6
|
+
import { decimal, decimalRatio } from "#contracts/math/rational";
|
|
7
|
+
/** Projects exact cardinal extrema from one circle or directed arc. */
|
|
8
|
+
function radialCoordinates(object, path, threshold) {
|
|
9
|
+
if (measureUnresolved(object.radius, threshold)) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
if (object.kind === "arc" &&
|
|
13
|
+
(arcEndpointsUnresolved(object.radius, object.sweepDegrees, threshold) ||
|
|
14
|
+
arcCurvatureUnresolved(object.radius, object.sweepDegrees, threshold))) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
return radialOffsets(object).flatMap((offset) => [
|
|
18
|
+
coordinate("x", path, decimalRatio(BigDecimal.sum(decimal(object.center.x), offset.x)), true, offset.error),
|
|
19
|
+
coordinate("y", path, decimalRatio(BigDecimal.sum(decimal(object.center.y), offset.y)), true, offset.error),
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
/** Owns one stable path for radial geometry-resolution failures. */
|
|
23
|
+
export function radialGeometryPath(kind, index) {
|
|
24
|
+
return kind === "arc" ? ["objects", index] : ["objects", index, "radius"];
|
|
25
|
+
}
|
|
26
|
+
/** Projects the exact endpoints and in-domain vertex of one quadratic. */
|
|
27
|
+
function quadraticCoordinates(object, path, threshold) {
|
|
28
|
+
const domainSpan = axisSpan(object.domain);
|
|
29
|
+
if (spanUnresolved(object.domain, threshold) ||
|
|
30
|
+
quadraticCurvatureUnresolved(object.coefficients.a, domainSpan, threshold)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const { inputAxis } = object;
|
|
34
|
+
const outputAxis = inputAxis === "x" ? "y" : "x";
|
|
35
|
+
return quadraticExtrema(object).flatMap(({ input, output }) => [
|
|
36
|
+
coordinate(inputAxis, path, input),
|
|
37
|
+
coordinate(outputAxis, path, output),
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
/** Projects the center and exact face coordinates of one cuboid. */
|
|
41
|
+
function cuboidCoordinates(object, path) {
|
|
42
|
+
return [
|
|
43
|
+
...pointCoordinates(object.center, [...path, "center"]),
|
|
44
|
+
...cuboidExtents(object).flatMap(({ axis, center, dimension, extent }) => [
|
|
45
|
+
coordinate(axis, [...path, "size", dimension], decimalRatio(BigDecimal.subtract(decimal(center), extent))),
|
|
46
|
+
coordinate(axis, [...path, "size", dimension], decimalRatio(BigDecimal.sum(decimal(center), extent))),
|
|
47
|
+
]),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
/** Projects every finite or frame-clipped coordinate of one scene object. */
|
|
51
|
+
function objectCoordinates(frame, object, index, threshold) {
|
|
52
|
+
const root = ["objects", index];
|
|
53
|
+
if (object.kind === "point") {
|
|
54
|
+
return pointCoordinates(object.at, [...root, "at"]);
|
|
55
|
+
}
|
|
56
|
+
if (object.kind === "line") {
|
|
57
|
+
const [from, through] = object.through;
|
|
58
|
+
return clippedPathCoordinates(frame, "line", from, through, root, threshold);
|
|
59
|
+
}
|
|
60
|
+
if (object.kind === "ray") {
|
|
61
|
+
return clippedPathCoordinates(frame, "ray", object.from, object.through, root, threshold);
|
|
62
|
+
}
|
|
63
|
+
if (object.kind === "segment") {
|
|
64
|
+
return [
|
|
65
|
+
...pointCoordinates(object.from, [...root, "from"]),
|
|
66
|
+
...pointCoordinates(object.to, [...root, "to"]),
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
if (object.kind === "polyline" || object.kind === "polygon") {
|
|
70
|
+
return object.vertices.flatMap((point, pointIndex) => pointCoordinates(point, [...root, "vertices", pointIndex]));
|
|
71
|
+
}
|
|
72
|
+
if (object.kind === "circle" || object.kind === "arc") {
|
|
73
|
+
return [
|
|
74
|
+
...pointCoordinates(object.center, [...root, "center"]),
|
|
75
|
+
...radialCoordinates(object, radialGeometryPath(object.kind, index), threshold),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
if (object.kind === "quadratic") {
|
|
79
|
+
return quadraticCoordinates(object, root, threshold);
|
|
80
|
+
}
|
|
81
|
+
return cuboidCoordinates(object, root);
|
|
82
|
+
}
|
|
83
|
+
/** Projects all label anchors after the objects they annotate. */
|
|
84
|
+
function labelCoordinates(labels) {
|
|
85
|
+
return labels.flatMap((label, index) => pointCoordinates(label.at, ["labels", index, "at"]));
|
|
86
|
+
}
|
|
87
|
+
/** Projects semantic camera or isometric coordinates before space objects. */
|
|
88
|
+
function viewCoordinates(view) {
|
|
89
|
+
if (view.kind === "camera") {
|
|
90
|
+
return [
|
|
91
|
+
...pointCoordinates(view.position, ["view", "position"]),
|
|
92
|
+
...pointCoordinates(view.target, ["view", "target"]),
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
return view.kind === "isometric" && view.target
|
|
96
|
+
? pointCoordinates(view.target, ["view", "target"])
|
|
97
|
+
: [];
|
|
98
|
+
}
|
|
99
|
+
/** Projects one plane scene into a single ordered exact coordinate stream. */
|
|
100
|
+
export function planeSceneCoordinates(frame, objects, labels, threshold) {
|
|
101
|
+
return [
|
|
102
|
+
...frameCoordinates(frame),
|
|
103
|
+
...objects.flatMap((object, index) => objectCoordinates(frame, object, index, threshold)),
|
|
104
|
+
...labelCoordinates(labels),
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
/** Projects one space scene into a single ordered exact coordinate stream. */
|
|
108
|
+
export function spaceSceneCoordinates(frame, objects, labels, view, threshold) {
|
|
109
|
+
return [
|
|
110
|
+
...frameCoordinates(frame),
|
|
111
|
+
...viewCoordinates(view),
|
|
112
|
+
...objects.flatMap((object, index) => objectCoordinates(frame, object, index, threshold)),
|
|
113
|
+
...labelCoordinates(labels),
|
|
114
|
+
];
|
|
115
|
+
}
|
package/dist/math/space.d.ts
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
/** Mathematical objects supported by a Cartesian space scene. */
|
|
3
3
|
export declare const SpaceMathObjectSchema: Schema.Union<readonly [Schema.Struct<{
|
|
4
|
-
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
5
|
-
readonly id: Schema.String;
|
|
6
|
-
readonly kind: Schema.Literal<"closed-spline">;
|
|
7
|
-
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
8
|
-
readonly x: Schema.Finite;
|
|
9
|
-
readonly y: Schema.Finite;
|
|
10
|
-
readonly z: Schema.Finite;
|
|
11
|
-
}>, Schema.Struct<{
|
|
12
|
-
readonly x: Schema.Finite;
|
|
13
|
-
readonly y: Schema.Finite;
|
|
14
|
-
readonly z: Schema.Finite;
|
|
15
|
-
}>, Schema.Struct<{
|
|
16
|
-
readonly x: Schema.Finite;
|
|
17
|
-
readonly y: Schema.Finite;
|
|
18
|
-
readonly z: Schema.Finite;
|
|
19
|
-
}>]>, readonly [Schema.Struct<{
|
|
20
|
-
readonly x: Schema.Finite;
|
|
21
|
-
readonly y: Schema.Finite;
|
|
22
|
-
readonly z: Schema.Finite;
|
|
23
|
-
}>]>;
|
|
24
|
-
}>, Schema.Struct<{
|
|
25
4
|
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
26
5
|
readonly id: Schema.String;
|
|
27
6
|
readonly center: Schema.Struct<{
|
|
@@ -123,28 +102,8 @@ export declare const SpaceMathObjectSchema: Schema.Union<readonly [Schema.Struct
|
|
|
123
102
|
readonly y: Schema.Finite;
|
|
124
103
|
readonly z: Schema.Finite;
|
|
125
104
|
}>;
|
|
126
|
-
}>, Schema.Struct<{
|
|
127
|
-
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
128
|
-
readonly id: Schema.String;
|
|
129
|
-
readonly kind: Schema.Literal<"spline">;
|
|
130
|
-
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
131
|
-
readonly x: Schema.Finite;
|
|
132
|
-
readonly y: Schema.Finite;
|
|
133
|
-
readonly z: Schema.Finite;
|
|
134
|
-
}>, Schema.Struct<{
|
|
135
|
-
readonly x: Schema.Finite;
|
|
136
|
-
readonly y: Schema.Finite;
|
|
137
|
-
readonly z: Schema.Finite;
|
|
138
|
-
}>, Schema.Struct<{
|
|
139
|
-
readonly x: Schema.Finite;
|
|
140
|
-
readonly y: Schema.Finite;
|
|
141
|
-
readonly z: Schema.Finite;
|
|
142
|
-
}>]>, readonly [Schema.Struct<{
|
|
143
|
-
readonly x: Schema.Finite;
|
|
144
|
-
readonly y: Schema.Finite;
|
|
145
|
-
readonly z: Schema.Finite;
|
|
146
|
-
}>]>;
|
|
147
105
|
}>]>;
|
|
106
|
+
export type SpaceMathObject = typeof SpaceMathObjectSchema.Type;
|
|
148
107
|
/** Exact Cartesian frame presented behind a space construction. */
|
|
149
108
|
export declare const SpaceMathFrameSchema: Schema.Struct<{
|
|
150
109
|
readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
|
|
@@ -163,6 +122,7 @@ export declare const SpaceMathFrameSchema: Schema.Struct<{
|
|
|
163
122
|
readonly min: Schema.Finite;
|
|
164
123
|
}>;
|
|
165
124
|
}>;
|
|
125
|
+
export type SpaceMathFrame = typeof SpaceMathFrameSchema.Type;
|
|
166
126
|
/** Minimal semantic views supported by one space scene. */
|
|
167
127
|
export declare const SpaceMathViewSchema: Schema.Union<readonly [Schema.Struct<{
|
|
168
128
|
readonly kind: Schema.Literal<"camera">;
|
|
@@ -187,6 +147,7 @@ export declare const SpaceMathViewSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
187
147
|
readonly z: Schema.Finite;
|
|
188
148
|
}>>;
|
|
189
149
|
}>]>;
|
|
150
|
+
export type SpaceMathView = typeof SpaceMathViewSchema.Type;
|
|
190
151
|
/** One coordinate anchor resolved against a separate rich-label map. */
|
|
191
152
|
export declare const SpaceLabelAnchorSchema: Schema.Struct<{
|
|
192
153
|
readonly at: Schema.Struct<{
|
|
@@ -197,6 +158,7 @@ export declare const SpaceLabelAnchorSchema: Schema.Struct<{
|
|
|
197
158
|
readonly key: Schema.String;
|
|
198
159
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
199
160
|
}>;
|
|
161
|
+
export type SpaceLabelAnchor = typeof SpaceLabelAnchorSchema.Type;
|
|
200
162
|
/** Complete stable space visual before rich labels are attached. */
|
|
201
163
|
export declare const SpaceMathVisualSchema: Schema.Struct<{
|
|
202
164
|
readonly frame: Schema.Struct<{
|
|
@@ -226,27 +188,6 @@ export declare const SpaceMathVisualSchema: Schema.Struct<{
|
|
|
226
188
|
readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
|
|
227
189
|
}>>>;
|
|
228
190
|
readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
229
|
-
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
230
|
-
readonly id: Schema.String;
|
|
231
|
-
readonly kind: Schema.Literal<"closed-spline">;
|
|
232
|
-
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
233
|
-
readonly x: Schema.Finite;
|
|
234
|
-
readonly y: Schema.Finite;
|
|
235
|
-
readonly z: Schema.Finite;
|
|
236
|
-
}>, Schema.Struct<{
|
|
237
|
-
readonly x: Schema.Finite;
|
|
238
|
-
readonly y: Schema.Finite;
|
|
239
|
-
readonly z: Schema.Finite;
|
|
240
|
-
}>, Schema.Struct<{
|
|
241
|
-
readonly x: Schema.Finite;
|
|
242
|
-
readonly y: Schema.Finite;
|
|
243
|
-
readonly z: Schema.Finite;
|
|
244
|
-
}>]>, readonly [Schema.Struct<{
|
|
245
|
-
readonly x: Schema.Finite;
|
|
246
|
-
readonly y: Schema.Finite;
|
|
247
|
-
readonly z: Schema.Finite;
|
|
248
|
-
}>]>;
|
|
249
|
-
}>, Schema.Struct<{
|
|
250
191
|
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
251
192
|
readonly id: Schema.String;
|
|
252
193
|
readonly center: Schema.Struct<{
|
|
@@ -348,27 +289,6 @@ export declare const SpaceMathVisualSchema: Schema.Struct<{
|
|
|
348
289
|
readonly y: Schema.Finite;
|
|
349
290
|
readonly z: Schema.Finite;
|
|
350
291
|
}>;
|
|
351
|
-
}>, Schema.Struct<{
|
|
352
|
-
readonly appearance: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
|
|
353
|
-
readonly id: Schema.String;
|
|
354
|
-
readonly kind: Schema.Literal<"spline">;
|
|
355
|
-
readonly samples: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Struct<{
|
|
356
|
-
readonly x: Schema.Finite;
|
|
357
|
-
readonly y: Schema.Finite;
|
|
358
|
-
readonly z: Schema.Finite;
|
|
359
|
-
}>, Schema.Struct<{
|
|
360
|
-
readonly x: Schema.Finite;
|
|
361
|
-
readonly y: Schema.Finite;
|
|
362
|
-
readonly z: Schema.Finite;
|
|
363
|
-
}>, Schema.Struct<{
|
|
364
|
-
readonly x: Schema.Finite;
|
|
365
|
-
readonly y: Schema.Finite;
|
|
366
|
-
readonly z: Schema.Finite;
|
|
367
|
-
}>]>, readonly [Schema.Struct<{
|
|
368
|
-
readonly x: Schema.Finite;
|
|
369
|
-
readonly y: Schema.Finite;
|
|
370
|
-
readonly z: Schema.Finite;
|
|
371
|
-
}>]>;
|
|
372
292
|
}>]>>;
|
|
373
293
|
readonly space: Schema.Literal<"space">;
|
|
374
294
|
readonly view: Schema.Union<readonly [Schema.Struct<{
|
package/dist/math/space.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathFeatureVisibilitySchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PositiveMeasureSchema, SpacePointSchema, sameSpacePoint, } from "#contracts/math/base";
|
|
3
|
+
import { spaceBoundsIssues } from "#contracts/math/bounds";
|
|
4
|
+
import { spaceResolutionIssues } from "#contracts/math/resolution";
|
|
3
5
|
import { hasCoplanarArea } from "#contracts/math/vector";
|
|
4
6
|
const ObjectFields = {
|
|
5
7
|
appearance: MathAppearanceSchema,
|
|
@@ -48,18 +50,6 @@ const SpacePolygonObjectSchema = Schema.Struct({
|
|
|
48
50
|
hasCoplanarArea(vertices), {
|
|
49
51
|
message: "Expected unique, coplanar vertices forming a non-degenerate polygon.",
|
|
50
52
|
})));
|
|
51
|
-
const SpaceSplineObjectSchema = Schema.Struct({
|
|
52
|
-
...ObjectFields,
|
|
53
|
-
kind: Schema.Literal("spline"),
|
|
54
|
-
samples: SpaceShapeSchema,
|
|
55
|
-
}).pipe(Schema.check(Schema.makeFilter(({ samples }) => hasUniquePositions(samples, sameSpacePoint), { message: "Expected at least three unique spline samples." })));
|
|
56
|
-
const SpaceClosedSplineObjectSchema = Schema.Struct({
|
|
57
|
-
...ObjectFields,
|
|
58
|
-
kind: Schema.Literal("closed-spline"),
|
|
59
|
-
samples: SpaceShapeSchema,
|
|
60
|
-
}).pipe(Schema.check(Schema.makeFilter(({ samples }) => hasUniquePositions(samples, sameSpacePoint), {
|
|
61
|
-
message: "Expected unique closed-spline samples without a repeated closing sample.",
|
|
62
|
-
})));
|
|
63
53
|
/**
|
|
64
54
|
* Axis-aligned cuboid whose length spans x, height spans y, and width spans z.
|
|
65
55
|
*/
|
|
@@ -75,7 +65,6 @@ const SpaceCuboidObjectSchema = Schema.Struct({
|
|
|
75
65
|
});
|
|
76
66
|
/** Mathematical objects supported by a Cartesian space scene. */
|
|
77
67
|
export const SpaceMathObjectSchema = Schema.Union([
|
|
78
|
-
SpaceClosedSplineObjectSchema,
|
|
79
68
|
SpaceCuboidObjectSchema,
|
|
80
69
|
SpaceLineObjectSchema,
|
|
81
70
|
SpacePointObjectSchema,
|
|
@@ -83,7 +72,6 @@ export const SpaceMathObjectSchema = Schema.Union([
|
|
|
83
72
|
SpacePolylineObjectSchema,
|
|
84
73
|
SpaceRayObjectSchema,
|
|
85
74
|
SpaceSegmentObjectSchema,
|
|
86
|
-
SpaceSplineObjectSchema,
|
|
87
75
|
]);
|
|
88
76
|
/** Exact Cartesian frame presented behind a space construction. */
|
|
89
77
|
export const SpaceMathFrameSchema = Schema.Struct({
|
|
@@ -126,4 +114,8 @@ export const SpaceMathVisualSchema = Schema.Struct({
|
|
|
126
114
|
objects: Schema.NonEmptyArray(SpaceMathObjectSchema),
|
|
127
115
|
space: Schema.Literal("space"),
|
|
128
116
|
view: SpaceMathViewSchema,
|
|
129
|
-
}).pipe(Schema.check(Schema.makeFilter(({ labels = [], objects }) =>
|
|
117
|
+
}).pipe(Schema.check(Schema.makeFilter(({ frame, labels = [], objects, view }) => [
|
|
118
|
+
...mathVisualIdentityIssues(objects, labels),
|
|
119
|
+
...spaceBoundsIssues(frame, objects, labels, view),
|
|
120
|
+
...spaceResolutionIssues(frame, objects, labels, view),
|
|
121
|
+
])));
|