aboutsummaryrefslogtreecommitdiff
path: root/src/models/electric-flux/state.ts
diff options
context:
space:
mode:
authorvictor2026-10-24 15:57:01 +0200
committervictor2026-10-24 15:57:01 +0200
commit4533910bce394e7a0ee6debfc05ca1221ee51899 (patch)
tree73aaa5b2c7a48dbf226e6b81d499ba1a8ecc33a1 /src/models/electric-flux/state.ts
parentTilføj dansk (diff)
download3D-Electrophysics-ny-start.tar.gz
3D-Electrophysics-ny-start.zip
Astra!ny-start
Diffstat (limited to 'src/models/electric-flux/state.ts')
-rw-r--r--src/models/electric-flux/state.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/models/electric-flux/state.ts b/src/models/electric-flux/state.ts
new file mode 100644
index 0000000..7bded33
--- /dev/null
+++ b/src/models/electric-flux/state.ts
@@ -0,0 +1,36 @@
+import type { ClosedSurface, PointCharge, SurfaceShape } from './physics';
+
+export interface FluxState {
+ chargeNC: number;
+ chargeX: number;
+ size: number;
+ shape: SurfaceShape;
+ fieldLines: boolean;
+ surface: boolean;
+ normals: boolean;
+}
+
+export const defaultState: Readonly<FluxState> = {
+ chargeNC: 2,
+ chargeX: 0,
+ size: 1.8,
+ shape: 'sphere',
+ fieldLines: true,
+ surface: true,
+ normals: false,
+};
+
+export const presets = {
+ positive: { ...defaultState },
+ negative: { ...defaultState, chargeNC: -2 },
+ outside: { ...defaultState, chargeX: 3.2 },
+} satisfies Record<string, FluxState>;
+
+export type Preset = keyof typeof presets;
+
+export function physicsInputs(state: FluxState): { charge: PointCharge; surface: ClosedSurface } {
+ return {
+ charge: { coulombs: state.chargeNC * 1e-9, position: { x: state.chargeX, y: 0, z: 0 } },
+ surface: { shape: state.shape, size: state.size },
+ };
+}