2 * The available geometries: their MATLAB source, and the metadata the host owns.
3 *
4 * The same split as the model registry — the .m is the shape, everything around
5 * it (parameter names, defaults, slider ranges) lives here, and the .m declares
6 * which of them it wants by naming them as arguments.
7 *
8 * `sphere` is first and is not merely one entry among several: it is the case
9 * the whole project is checked against, where the surface is exactly the unit
10 * sphere and every result must match turing-sphere.
11 */
12import sphereSource from '../../geometries/sphere.m?raw';
13import ellipsoidSource from '../../geometries/ellipsoid.m?raw';
14import peanutSource from '../../geometries/peanut.m?raw';
15import bumpySource from '../../geometries/bumpy.m?raw';
16import type { ParamSpec, Params } from '../mgpu/registry.ts';
18export interface MGeometry {
19 key: string;
20 label: string;
21 blurb: string;
22 params: ParamSpec[];
23 /** MATLAB source — the shape itself. */
24 source: string;
25}
27const sphere: MGeometry = {
28 key: 'sphere',
29 label: 'Sphere',
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 30 blurb: 'The unit sphere — the reference case.',
32 source: sphereSource,
33};
35const ellipsoid: MGeometry = {
36 key: 'ellipsoid',
37 label: 'Ellipsoid',
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 38 blurb: 'The sphere with each axis scaled independently.',
40 { key: 'ax', label: 'a', value: 1.5, min: 0.2, max: 3, step: 0.05 },
41 { key: 'ay', label: 'b', value: 1, min: 0.2, max: 3, step: 0.05 },
42 { key: 'az', label: 'c', value: 0.6, min: 0.2, max: 3, step: 0.05 },
43 ],
44 source: ellipsoidSource,
45};
47const peanut: MGeometry = {
48 key: 'peanut',
49 label: 'Peanut',
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 50 blurb: 'A dumbbell pinched at the equator.',
52 { key: 'waist', label: 'waist', value: 0.6, min: 0, max: 0.9, step: 0.05 },
53 { key: 'stretch', label: 'stretch', value: 0.6, min: 0, max: 2, step: 0.05 },
54 ],
55 source: peanutSource,
56};
58const bumpy: MGeometry = {
59 key: 'bumpy',
60 label: 'Bumpy',
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 61 blurb: 'Equatorial lobes plus a pear-shaped offset.',
63 { key: 'amp', label: 'amp', value: 0.3, min: 0, max: 0.6, step: 0.02 },
64 { key: 'nlobe', label: 'lobes', value: 5, min: 1, max: 12, step: 1 },
65 { key: 'pear', label: 'pear', value: 0.15, min: -0.4, max: 0.4, step: 0.05 },
66 ],
67 source: bumpySource,
68};
70export const mGeometries: MGeometry[] = [sphere, ellipsoid, peanut, bumpy];
72export const mGeometryByKey = (key: string): MGeometry | undefined =>
73 mGeometries.find((g) => g.key === key);
75export const defaultGeometryParams = (g: MGeometry): Params =>
76 Object.fromEntries(g.params.map((p) => [p.key, p.value]));
78/** The geometry every result is checked against, and what a caller who names
79 * none gets: the case where the solver is exact. */
80export const SPHERE_KEY = 'sphere';
82/** What the app and the benchmark start on. Not the sphere: this project
83 * exists for the other shapes, and opening on the reference case would hide
84 * the one thing it adds. */
85export const DEFAULT_GEOMETRY_KEY = 'ellipsoid';