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 = { 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; 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 }, }; }