aboutsummaryrefslogtreecommitdiff
path: root/src/physics/electricField.ts
diff options
context:
space:
mode:
authorvictor2026-10-24 15:57:01 +0200
committervictor2026-10-24 15:57:01 +0200
commit4533910bce394e7a0ee6debfc05ca1221ee51899 (patch)
tree73aaa5b2c7a48dbf226e6b81d499ba1a8ecc33a1 /src/physics/electricField.ts
parentTilføj dansk (diff)
download3D-Electrophysics-4533910bce394e7a0ee6debfc05ca1221ee51899.tar.gz
3D-Electrophysics-4533910bce394e7a0ee6debfc05ca1221ee51899.zip
Astra!ny-start
Diffstat (limited to 'src/physics/electricField.ts')
-rw-r--r--src/physics/electricField.ts22
1 files changed, 0 insertions, 22 deletions
diff --git a/src/physics/electricField.ts b/src/physics/electricField.ts
deleted file mode 100644
index 26975e3..0000000
--- a/src/physics/electricField.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-export interface Point { x: number; y: number; z: number }
-export interface Charge extends Point { coulombs: number }
-export const COULOMB_CONSTANT = 8.9875517923e9;
-
-/** SI units: positions in metres, charges in coulombs, output in N/C.
- * Samples inside 0.18 m of a charge are omitted to avoid visual singularities.
- */
-export function electricField(point: Point, charges: readonly Charge[]): Point {
- const field = { x: 0, y: 0, z: 0 };
- for (const charge of charges) {
- const dx = point.x - charge.x;
- const dy = point.y - charge.y;
- const dz = point.z - charge.z;
- const r2 = dx * dx + dy * dy + dz * dz;
- if (r2 < 0.18 ** 2) continue;
- const factor = COULOMB_CONSTANT * charge.coulombs / (r2 * Math.sqrt(r2));
- field.x += factor * dx;
- field.y += factor * dy;
- field.z += factor * dz;
- }
- return field;
-}