@nakafa/aksara-contracts 8.16.0 → 8.17.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.
@@ -0,0 +1,140 @@
1
+ import { Schema } from "effect";
2
+ import { byIds, byPickedIds, cardFields, namesEach, TextSchema, } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** A non-negative finite number for unit-interval and skew sliders. */
5
+ const NonNegativeSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
6
+ /** A strictly positive finite upper bound for sliders. */
7
+ const PositiveSchema = Schema.Finite.check(Schema.isGreaterThan(0));
8
+ /** A non-negative slider whose minimum sits below its maximum. */
9
+ const UnitSliderSchema = Schema.Struct({
10
+ max: PositiveSchema,
11
+ min: NonNegativeSchema,
12
+ value: NonNegativeSchema,
13
+ }).check(Schema.makeFilter(({ max, min, value }) => min < max && min <= value && value <= max, {
14
+ message: "Expected a non-negative slider range whose minimum is below its maximum, with the starting value between them.",
15
+ }));
16
+ const EIGEN_TRANSFORMS = [
17
+ "stretchShear",
18
+ "symmetricDiag",
19
+ "reflectionScale",
20
+ "anisotropic3D",
21
+ ];
22
+ const PCA_SUBSPACES = ["pc1Line", "pc1Pc2Plane", "full3D"];
23
+ const QR_STEPS = [
24
+ "originalBasis",
25
+ "normalizeQ1",
26
+ "orthogonalizeQ2",
27
+ "orthogonalizeQ3",
28
+ ];
29
+ /**
30
+ * Props of `EigenTransform3DLab`: a 3D linear transformation cube showing
31
+ * invariant eigenvector spans and scaling factors as the space morphs from the
32
+ * identity to matrix A. Eigenvalues and determinant readouts are optional
33
+ * answer state.
34
+ */
35
+ function eigenTransform3DLab(rich) {
36
+ return figure(Schema.Struct({
37
+ ...cardFields(rich),
38
+ labels: Schema.Struct({
39
+ determinant: Schema.optionalKey(rich),
40
+ eigenvalues: Schema.optionalKey(rich),
41
+ parts: byIds([
42
+ "basisAxes",
43
+ "transformedGrid",
44
+ "eigenvectorOne",
45
+ "eigenvectorTwo",
46
+ "eigenvectorThree",
47
+ "testVector",
48
+ ], TextSchema),
49
+ progress: TextSchema,
50
+ transform: TextSchema,
51
+ transforms: byPickedIds(EIGEN_TRANSFORMS, Schema.Struct({
52
+ formula: rich,
53
+ name: TextSchema,
54
+ })),
55
+ view: TextSchema,
56
+ }),
57
+ progress: UnitSliderSchema,
58
+ transforms: Schema.NonEmptyArray(Schema.Literals(EIGEN_TRANSFORMS)).check(Schema.isUnique()),
59
+ }).check(Schema.makeFilter(({ labels, transforms }) => namesEach(transforms, labels.transforms), {
60
+ message: "Expected a name and formula for every linear transformation preset shown, and no other.",
61
+ })), answerAt(["labels", "eigenvalues"], ["labels", "determinant"]));
62
+ }
63
+ /**
64
+ * Props of `PcaProjection3DLab`: a 3D correlated point cloud with orthogonal
65
+ * principal component axes and residual projection drop-lines onto PC1 or the
66
+ * PC1-PC2 plane. Variance explained and reconstruction error readouts are
67
+ * optional answer state.
68
+ */
69
+ function pcaProjection3DLab(rich) {
70
+ return figure(Schema.Struct({
71
+ ...cardFields(rich),
72
+ correlation: UnitSliderSchema,
73
+ labels: Schema.Struct({
74
+ correlation: TextSchema,
75
+ parts: byIds([
76
+ "pointCloud",
77
+ "pc1Axis",
78
+ "pc2Axis",
79
+ "pc3Axis",
80
+ "projectionPlane",
81
+ "residualLines",
82
+ ], TextSchema),
83
+ reconstructionError: Schema.optionalKey(rich),
84
+ subspace: TextSchema,
85
+ subspaces: byPickedIds(PCA_SUBSPACES, Schema.Struct({
86
+ name: TextSchema,
87
+ summary: rich,
88
+ })),
89
+ varianceExplained: Schema.optionalKey(rich),
90
+ view: TextSchema,
91
+ }),
92
+ subspaces: Schema.NonEmptyArray(Schema.Literals(PCA_SUBSPACES)).check(Schema.isUnique()),
93
+ }).check(Schema.makeFilter(({ labels, subspaces }) => namesEach(subspaces, labels.subspaces), {
94
+ message: "Expected a name and summary for every PCA projection subspace shown, and no other.",
95
+ })), answerAt(["labels", "varianceExplained"], ["labels", "reconstructionError"]));
96
+ }
97
+ /**
98
+ * Props of `QrGramSchmidt3DLab`: a 3D step-by-step Gram-Schmidt
99
+ * orthogonalization turning three skewed column vectors into an orthonormal
100
+ * basis Q with upper-triangular projection coordinates R. Orthogonality check
101
+ * and R-entry readouts are optional answer state.
102
+ */
103
+ function qrGramSchmidt3DLab(rich) {
104
+ return figure(Schema.Struct({
105
+ ...cardFields(rich),
106
+ labels: Schema.Struct({
107
+ orthogonalityCheck: Schema.optionalKey(rich),
108
+ parts: byIds([
109
+ "inputVectors",
110
+ "orthonormalBasis",
111
+ "projectionShadow",
112
+ "orthogonalFrame",
113
+ "unitSphere",
114
+ ], TextSchema),
115
+ rEntries: Schema.optionalKey(rich),
116
+ skew: TextSchema,
117
+ step: TextSchema,
118
+ steps: byPickedIds(QR_STEPS, Schema.Struct({
119
+ name: TextSchema,
120
+ summary: rich,
121
+ })),
122
+ view: TextSchema,
123
+ }),
124
+ skew: UnitSliderSchema,
125
+ steps: Schema.NonEmptyArray(Schema.Literals(QR_STEPS)).check(Schema.isUnique()),
126
+ }).check(Schema.makeFilter(({ labels, steps }) => namesEach(steps, labels.steps), {
127
+ message: "Expected a name and summary for every Gram-Schmidt step shown, and no other.",
128
+ })), answerAt(["labels", "orthogonalityCheck"], ["labels", "rEntries"]));
129
+ }
130
+ /**
131
+ * Linear methods 3D labs covering eigen-transformations, principal component
132
+ * projection, and QR Gram-Schmidt orthogonalization.
133
+ */
134
+ export function linearVisuals(rich) {
135
+ return {
136
+ EigenTransform3DLab: eigenTransform3DLab(rich),
137
+ PcaProjection3DLab: pcaProjection3DLab(rich),
138
+ QrGramSchmidt3DLab: qrGramSchmidt3DLab(rich),
139
+ };
140
+ }
@@ -0,0 +1,419 @@
1
+ import { Schema } from "effect";
2
+ import type { RichSlot } from "#contracts/visual/card";
3
+ /**
4
+ * 3D vector operations labs covering cross products, orthogonal dot-product
5
+ * projections, and scalar triple product parallelepipeds.
6
+ */
7
+ export declare function vectorVisuals<E>(rich: RichSlot<E>): {
8
+ DotProductProjection3DLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
9
+ readonly description: RichSlot<E>;
10
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
11
+ readonly marks?: readonly [{
12
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
13
+ } | {
14
+ readonly attrs: {
15
+ readonly href: string;
16
+ };
17
+ readonly type: "link";
18
+ } | {
19
+ readonly attrs: {
20
+ readonly variant: "success" | "warning" | null;
21
+ };
22
+ readonly type: "highlight";
23
+ }, ...({
24
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
25
+ } | {
26
+ readonly attrs: {
27
+ readonly href: string;
28
+ };
29
+ readonly type: "link";
30
+ } | {
31
+ readonly attrs: {
32
+ readonly variant: "success" | "warning" | null;
33
+ };
34
+ readonly type: "highlight";
35
+ })[]];
36
+ readonly text: string;
37
+ readonly type: "text";
38
+ } | {
39
+ readonly attrs: {
40
+ readonly latex: string;
41
+ };
42
+ readonly marks?: readonly [{
43
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
44
+ } | {
45
+ readonly attrs: {
46
+ readonly href: string;
47
+ };
48
+ readonly type: "link";
49
+ } | {
50
+ readonly attrs: {
51
+ readonly variant: "success" | "warning" | null;
52
+ };
53
+ readonly type: "highlight";
54
+ }, ...({
55
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
56
+ } | {
57
+ readonly attrs: {
58
+ readonly href: string;
59
+ };
60
+ readonly type: "link";
61
+ } | {
62
+ readonly attrs: {
63
+ readonly variant: "success" | "warning" | null;
64
+ };
65
+ readonly type: "highlight";
66
+ })[]];
67
+ readonly type: "mathInline";
68
+ }, ...({
69
+ readonly marks?: readonly [{
70
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
71
+ } | {
72
+ readonly attrs: {
73
+ readonly href: string;
74
+ };
75
+ readonly type: "link";
76
+ } | {
77
+ readonly attrs: {
78
+ readonly variant: "success" | "warning" | null;
79
+ };
80
+ readonly type: "highlight";
81
+ }, ...({
82
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
83
+ } | {
84
+ readonly attrs: {
85
+ readonly href: string;
86
+ };
87
+ readonly type: "link";
88
+ } | {
89
+ readonly attrs: {
90
+ readonly variant: "success" | "warning" | null;
91
+ };
92
+ readonly type: "highlight";
93
+ })[]];
94
+ readonly text: string;
95
+ readonly type: "text";
96
+ } | {
97
+ readonly attrs: {
98
+ readonly latex: string;
99
+ };
100
+ readonly marks?: readonly [{
101
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
102
+ } | {
103
+ readonly attrs: {
104
+ readonly href: string;
105
+ };
106
+ readonly type: "link";
107
+ } | {
108
+ readonly attrs: {
109
+ readonly variant: "success" | "warning" | null;
110
+ };
111
+ readonly type: "highlight";
112
+ }, ...({
113
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
114
+ } | {
115
+ readonly attrs: {
116
+ readonly href: string;
117
+ };
118
+ readonly type: "link";
119
+ } | {
120
+ readonly attrs: {
121
+ readonly variant: "success" | "warning" | null;
122
+ };
123
+ readonly type: "highlight";
124
+ })[]];
125
+ readonly type: "mathInline";
126
+ })[]], E, never, never>>;
127
+ readonly title: RichSlot<E>;
128
+ readonly angle: Schema.Struct<{
129
+ readonly max: Schema.Finite;
130
+ readonly min: Schema.Finite;
131
+ readonly value: Schema.Finite;
132
+ }>;
133
+ readonly labels: Schema.Struct<{
134
+ readonly angle: Schema.Trimmed;
135
+ readonly dotValue: Schema.optionalKey<RichSlot<E>>;
136
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["vectorU", "vectorV", "projectionVector", "dropLine", "angleArc", "coordinateAxes"]>, Schema.Trimmed>;
137
+ readonly preset: Schema.Trimmed;
138
+ readonly presets: Schema.$Record<Schema.Literals<readonly ["acute", "orthogonal", "obtuse"]>, Schema.optionalKey<Schema.Trimmed>>;
139
+ readonly projectionLength: Schema.optionalKey<RichSlot<E>>;
140
+ readonly view: Schema.Trimmed;
141
+ }>;
142
+ readonly presets: Schema.NonEmptyArray<Schema.Literals<readonly ["acute", "orthogonal", "obtuse"]>>;
143
+ }>, "figure">;
144
+ Vector3DCrossProductLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
145
+ readonly description: RichSlot<E>;
146
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
147
+ readonly marks?: readonly [{
148
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
149
+ } | {
150
+ readonly attrs: {
151
+ readonly href: string;
152
+ };
153
+ readonly type: "link";
154
+ } | {
155
+ readonly attrs: {
156
+ readonly variant: "success" | "warning" | null;
157
+ };
158
+ readonly type: "highlight";
159
+ }, ...({
160
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
161
+ } | {
162
+ readonly attrs: {
163
+ readonly href: string;
164
+ };
165
+ readonly type: "link";
166
+ } | {
167
+ readonly attrs: {
168
+ readonly variant: "success" | "warning" | null;
169
+ };
170
+ readonly type: "highlight";
171
+ })[]];
172
+ readonly text: string;
173
+ readonly type: "text";
174
+ } | {
175
+ readonly attrs: {
176
+ readonly latex: string;
177
+ };
178
+ readonly marks?: readonly [{
179
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
180
+ } | {
181
+ readonly attrs: {
182
+ readonly href: string;
183
+ };
184
+ readonly type: "link";
185
+ } | {
186
+ readonly attrs: {
187
+ readonly variant: "success" | "warning" | null;
188
+ };
189
+ readonly type: "highlight";
190
+ }, ...({
191
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
192
+ } | {
193
+ readonly attrs: {
194
+ readonly href: string;
195
+ };
196
+ readonly type: "link";
197
+ } | {
198
+ readonly attrs: {
199
+ readonly variant: "success" | "warning" | null;
200
+ };
201
+ readonly type: "highlight";
202
+ })[]];
203
+ readonly type: "mathInline";
204
+ }, ...({
205
+ readonly marks?: readonly [{
206
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
207
+ } | {
208
+ readonly attrs: {
209
+ readonly href: string;
210
+ };
211
+ readonly type: "link";
212
+ } | {
213
+ readonly attrs: {
214
+ readonly variant: "success" | "warning" | null;
215
+ };
216
+ readonly type: "highlight";
217
+ }, ...({
218
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
219
+ } | {
220
+ readonly attrs: {
221
+ readonly href: string;
222
+ };
223
+ readonly type: "link";
224
+ } | {
225
+ readonly attrs: {
226
+ readonly variant: "success" | "warning" | null;
227
+ };
228
+ readonly type: "highlight";
229
+ })[]];
230
+ readonly text: string;
231
+ readonly type: "text";
232
+ } | {
233
+ readonly attrs: {
234
+ readonly latex: string;
235
+ };
236
+ readonly marks?: readonly [{
237
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
238
+ } | {
239
+ readonly attrs: {
240
+ readonly href: string;
241
+ };
242
+ readonly type: "link";
243
+ } | {
244
+ readonly attrs: {
245
+ readonly variant: "success" | "warning" | null;
246
+ };
247
+ readonly type: "highlight";
248
+ }, ...({
249
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
250
+ } | {
251
+ readonly attrs: {
252
+ readonly href: string;
253
+ };
254
+ readonly type: "link";
255
+ } | {
256
+ readonly attrs: {
257
+ readonly variant: "success" | "warning" | null;
258
+ };
259
+ readonly type: "highlight";
260
+ })[]];
261
+ readonly type: "mathInline";
262
+ })[]], E, never, never>>;
263
+ readonly title: RichSlot<E>;
264
+ readonly angle: Schema.Struct<{
265
+ readonly max: Schema.Finite;
266
+ readonly min: Schema.Finite;
267
+ readonly value: Schema.Finite;
268
+ }>;
269
+ readonly labels: Schema.Struct<{
270
+ readonly angle: Schema.Trimmed;
271
+ readonly crossMagnitude: Schema.optionalKey<RichSlot<E>>;
272
+ readonly directionRule: Schema.optionalKey<RichSlot<E>>;
273
+ readonly order: Schema.Trimmed;
274
+ readonly orders: Schema.$Record<Schema.Literals<readonly ["uCrossV", "vCrossU"]>, Schema.optionalKey<Schema.Trimmed>>;
275
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["vectorU", "vectorV", "crossVector", "parallelogram", "curlArc", "coordinateAxes"]>, Schema.Trimmed>;
276
+ readonly view: Schema.Trimmed;
277
+ }>;
278
+ readonly orders: Schema.NonEmptyArray<Schema.Literals<readonly ["uCrossV", "vCrossU"]>>;
279
+ }>, "figure">;
280
+ VectorParallelepipedLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
281
+ readonly description: RichSlot<E>;
282
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
283
+ readonly marks?: readonly [{
284
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
285
+ } | {
286
+ readonly attrs: {
287
+ readonly href: string;
288
+ };
289
+ readonly type: "link";
290
+ } | {
291
+ readonly attrs: {
292
+ readonly variant: "success" | "warning" | null;
293
+ };
294
+ readonly type: "highlight";
295
+ }, ...({
296
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
297
+ } | {
298
+ readonly attrs: {
299
+ readonly href: string;
300
+ };
301
+ readonly type: "link";
302
+ } | {
303
+ readonly attrs: {
304
+ readonly variant: "success" | "warning" | null;
305
+ };
306
+ readonly type: "highlight";
307
+ })[]];
308
+ readonly text: string;
309
+ readonly type: "text";
310
+ } | {
311
+ readonly attrs: {
312
+ readonly latex: string;
313
+ };
314
+ readonly marks?: readonly [{
315
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
316
+ } | {
317
+ readonly attrs: {
318
+ readonly href: string;
319
+ };
320
+ readonly type: "link";
321
+ } | {
322
+ readonly attrs: {
323
+ readonly variant: "success" | "warning" | null;
324
+ };
325
+ readonly type: "highlight";
326
+ }, ...({
327
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
328
+ } | {
329
+ readonly attrs: {
330
+ readonly href: string;
331
+ };
332
+ readonly type: "link";
333
+ } | {
334
+ readonly attrs: {
335
+ readonly variant: "success" | "warning" | null;
336
+ };
337
+ readonly type: "highlight";
338
+ })[]];
339
+ readonly type: "mathInline";
340
+ }, ...({
341
+ readonly marks?: readonly [{
342
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
343
+ } | {
344
+ readonly attrs: {
345
+ readonly href: string;
346
+ };
347
+ readonly type: "link";
348
+ } | {
349
+ readonly attrs: {
350
+ readonly variant: "success" | "warning" | null;
351
+ };
352
+ readonly type: "highlight";
353
+ }, ...({
354
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
355
+ } | {
356
+ readonly attrs: {
357
+ readonly href: string;
358
+ };
359
+ readonly type: "link";
360
+ } | {
361
+ readonly attrs: {
362
+ readonly variant: "success" | "warning" | null;
363
+ };
364
+ readonly type: "highlight";
365
+ })[]];
366
+ readonly text: string;
367
+ readonly type: "text";
368
+ } | {
369
+ readonly attrs: {
370
+ readonly latex: string;
371
+ };
372
+ readonly marks?: readonly [{
373
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
374
+ } | {
375
+ readonly attrs: {
376
+ readonly href: string;
377
+ };
378
+ readonly type: "link";
379
+ } | {
380
+ readonly attrs: {
381
+ readonly variant: "success" | "warning" | null;
382
+ };
383
+ readonly type: "highlight";
384
+ }, ...({
385
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
386
+ } | {
387
+ readonly attrs: {
388
+ readonly href: string;
389
+ };
390
+ readonly type: "link";
391
+ } | {
392
+ readonly attrs: {
393
+ readonly variant: "success" | "warning" | null;
394
+ };
395
+ readonly type: "highlight";
396
+ })[]];
397
+ readonly type: "mathInline";
398
+ })[]], E, never, never>>;
399
+ readonly title: RichSlot<E>;
400
+ readonly configurations: Schema.NonEmptyArray<Schema.Literals<readonly ["orthogonalBox", "shearedPrism", "coplanarFlat"]>>;
401
+ readonly elevation: Schema.Struct<{
402
+ readonly max: Schema.Finite;
403
+ readonly min: Schema.Finite;
404
+ readonly value: Schema.Finite;
405
+ }>;
406
+ readonly labels: Schema.Struct<{
407
+ readonly configuration: Schema.Trimmed;
408
+ readonly configurations: Schema.$Record<Schema.Literals<readonly ["orthogonalBox", "shearedPrism", "coplanarFlat"]>, Schema.optionalKey<Schema.Struct<{
409
+ readonly name: Schema.Trimmed;
410
+ readonly summary: RichSlot<E>;
411
+ }>>>;
412
+ readonly coplanarityNote: Schema.optionalKey<RichSlot<E>>;
413
+ readonly elevation: Schema.Trimmed;
414
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["vectorU", "vectorV", "vectorW", "baseParallelogram", "parallelepipedMesh", "altitudeLine"]>, Schema.Trimmed>;
415
+ readonly tripleVolume: Schema.optionalKey<RichSlot<E>>;
416
+ readonly view: Schema.Trimmed;
417
+ }>;
418
+ }>, "figure">;
419
+ };
@@ -0,0 +1,129 @@
1
+ import { Schema } from "effect";
2
+ import { byIds, byPickedIds, cardFields, namesEach, TextSchema, } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** A non-negative finite number for angle and elevation sliders. */
5
+ const NonNegativeSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
6
+ /** A strictly positive finite upper bound for angle sliders. */
7
+ const PositiveSchema = Schema.Finite.check(Schema.isGreaterThan(0));
8
+ /** A non-negative slider whose minimum sits below its maximum. */
9
+ const AngleSliderSchema = Schema.Struct({
10
+ max: PositiveSchema,
11
+ min: NonNegativeSchema,
12
+ value: NonNegativeSchema,
13
+ }).check(Schema.makeFilter(({ max, min, value }) => min < max && min <= value && value <= max, {
14
+ message: "Expected a non-negative angle range whose minimum is below its maximum, with the starting value between them.",
15
+ }));
16
+ const CROSS_ORDERS = ["uCrossV", "vCrossU"];
17
+ const DOT_PRESETS = ["acute", "orthogonal", "obtuse"];
18
+ const PARALLELEPIPED_CONFIGS = [
19
+ "orthogonalBox",
20
+ "shearedPrism",
21
+ "coplanarFlat",
22
+ ];
23
+ /**
24
+ * Props of `Vector3DCrossProductLab`: a 3D vector stage displaying vectors u
25
+ * and v, their spanned parallelogram area, and the orthogonal normal vector
26
+ * u x v obeying the right-hand rule and anti-commutativity. Cross magnitude
27
+ * and direction rule readouts are optional answer state.
28
+ */
29
+ function vector3DCrossProductLab(rich) {
30
+ return figure(Schema.Struct({
31
+ ...cardFields(rich),
32
+ angle: AngleSliderSchema,
33
+ labels: Schema.Struct({
34
+ angle: TextSchema,
35
+ crossMagnitude: Schema.optionalKey(rich),
36
+ directionRule: Schema.optionalKey(rich),
37
+ order: TextSchema,
38
+ orders: byPickedIds(CROSS_ORDERS, TextSchema),
39
+ parts: byIds([
40
+ "vectorU",
41
+ "vectorV",
42
+ "crossVector",
43
+ "parallelogram",
44
+ "curlArc",
45
+ "coordinateAxes",
46
+ ], TextSchema),
47
+ view: TextSchema,
48
+ }),
49
+ orders: Schema.NonEmptyArray(Schema.Literals(CROSS_ORDERS)).check(Schema.isUnique()),
50
+ }).check(Schema.makeFilter(({ labels, orders }) => namesEach(orders, labels.orders), {
51
+ message: "Expected a name for every cross-product order shown, and no other.",
52
+ })), answerAt(["labels", "crossMagnitude"], ["labels", "directionRule"]));
53
+ }
54
+ /**
55
+ * Props of `DotProductProjection3DLab`: a 3D vector projection bench showing
56
+ * orthogonal drop-lines from u onto v and sweeping between acute, orthogonal,
57
+ * and obtuse dot products. Dot value and projection length readouts are
58
+ * optional answer state.
59
+ */
60
+ function dotProductProjection3DLab(rich) {
61
+ return figure(Schema.Struct({
62
+ ...cardFields(rich),
63
+ angle: AngleSliderSchema,
64
+ labels: Schema.Struct({
65
+ angle: TextSchema,
66
+ dotValue: Schema.optionalKey(rich),
67
+ parts: byIds([
68
+ "vectorU",
69
+ "vectorV",
70
+ "projectionVector",
71
+ "dropLine",
72
+ "angleArc",
73
+ "coordinateAxes",
74
+ ], TextSchema),
75
+ preset: TextSchema,
76
+ presets: byPickedIds(DOT_PRESETS, TextSchema),
77
+ projectionLength: Schema.optionalKey(rich),
78
+ view: TextSchema,
79
+ }),
80
+ presets: Schema.NonEmptyArray(Schema.Literals(DOT_PRESETS)).check(Schema.isUnique()),
81
+ }).check(Schema.makeFilter(({ labels, presets }) => namesEach(presets, labels.presets), {
82
+ message: "Expected a name for every dot-product angle preset shown, and no other.",
83
+ })), answerAt(["labels", "dotValue"], ["labels", "projectionLength"]));
84
+ }
85
+ /**
86
+ * Props of `VectorParallelepipedLab`: a 3D translucent parallelepiped spanned
87
+ * by three vectors (u, v, w) illustrating the scalar triple product volume and
88
+ * collapse to zero when coplanar. Triple volume and coplanarity note readouts
89
+ * are optional answer state.
90
+ */
91
+ function vectorParallelepipedLab(rich) {
92
+ return figure(Schema.Struct({
93
+ ...cardFields(rich),
94
+ configurations: Schema.NonEmptyArray(Schema.Literals(PARALLELEPIPED_CONFIGS)).check(Schema.isUnique()),
95
+ elevation: AngleSliderSchema,
96
+ labels: Schema.Struct({
97
+ configuration: TextSchema,
98
+ configurations: byPickedIds(PARALLELEPIPED_CONFIGS, Schema.Struct({
99
+ name: TextSchema,
100
+ summary: rich,
101
+ })),
102
+ coplanarityNote: Schema.optionalKey(rich),
103
+ elevation: TextSchema,
104
+ parts: byIds([
105
+ "vectorU",
106
+ "vectorV",
107
+ "vectorW",
108
+ "baseParallelogram",
109
+ "parallelepipedMesh",
110
+ "altitudeLine",
111
+ ], TextSchema),
112
+ tripleVolume: Schema.optionalKey(rich),
113
+ view: TextSchema,
114
+ }),
115
+ }).check(Schema.makeFilter(({ configurations, labels }) => namesEach(configurations, labels.configurations), {
116
+ message: "Expected a name and summary for every parallelepiped configuration shown, and no other.",
117
+ })), answerAt(["labels", "tripleVolume"], ["labels", "coplanarityNote"]));
118
+ }
119
+ /**
120
+ * 3D vector operations labs covering cross products, orthogonal dot-product
121
+ * projections, and scalar triple product parallelepipeds.
122
+ */
123
+ export function vectorVisuals(rich) {
124
+ return {
125
+ DotProductProjection3DLab: dotProductProjection3DLab(rich),
126
+ Vector3DCrossProductLab: vector3DCrossProductLab(rich),
127
+ VectorParallelepipedLab: vectorParallelepipedLab(rich),
128
+ };
129
+ }