aboutsummaryrefslogtreecommitdiff
path: root/src/test4.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test4.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/test4.ts b/src/test4.ts
index 9bd32d8..c031fa5 100644
--- a/src/test4.ts
+++ b/src/test4.ts
@@ -1,4 +1,5 @@
-import { format, number, type Choice, type Experiment, type Measurement, type Parameters, type Slider, type TestId } from './experiments';
+import { format, formatDisplay, number, type Choice, type Experiment, type Measurement, type Parameters, type Slider, type TestId } from './experiments';
+import { word } from './i18n';
import { type Charge } from './physics/electricField';
import { pairEnergy } from './physics/models';
import { assembledEnergy, centralWork, dipoleState, energyTransfer, uniformWork } from './physics/test4';
@@ -19,7 +20,7 @@ export interface TestLesson extends Experiment {
}
const slider = (id: string, label: string, min: number, max: number, step: number, value: number, unit: string): Slider => ({ kind: 'range', id, label, min, max, step, value, unit });
const choice = (id: string, label: string, value: string, options: [string, string][]): Choice => ({ kind: 'select', id, label, value, options: options.map(([value, label]) => ({ value, label })) });
-const metric = (label: string, value: number, unit = 'nJ'): Measurement => ({ label, value: format(Math.abs(value) < 1e-10 ? 0 : value), unit });
+const metric = (label: string, value: number, unit = 'nJ'): Measurement => ({ label, value: formatDisplay(Math.abs(value) < 1e-10 ? 0 : value), unit: word(unit) });
const energy = (label: string, joules: number) => metric(label, joules * 1e9);
const radians = (degrees: number) => degrees * Math.PI / 180;
export const progress = (p: Parameters) => number(p, 'progress') / 100;