Electric-field-visualization.mp4
Electric Field Visualizer is a real-time 3D simulation of electrostatic fields generated by many moving point charges. It brings together Coulomb’s Law, Gauss’s Law, and numerical integration (RK4) to create a realistic, dynamic visualization of electric fields evolving in time and space.
Each charge contributes to the overall field, and the superposition principle ensures accurate interactions between dozens of charges simultaneously — in real time.
Every point charge generates an electric field E described by:
[ \vec{E} = \frac{1}{4 \pi \varepsilon_0} \cdot \frac{q}{r^2} \hat{r} ]
Where:
- ( q ) — charge magnitude (C)
- ( \hat{r} ) — unit vector from charge to observation point
- ( \varepsilon_0 ) — permittivity of free space
The simulation adds up all contributions from each charge to compute the resultant vector field.
To visualize electric field lines, we integrate the electric field vector field using Runge–Kutta 4 (RK4) — a 4th-order accurate method.
[ \vec{r}_{n+1} = \vec{r}_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4) ]
This ensures:
- Smooth, continuous trajectories for field lines
- Numerical stability even near strong field gradients
- Correct directionality and convergence around opposite charges
Unlike static field plots, this system supports dynamically moving charges using RK4 integration for motion as well:
- Charges can orbit, rotate, or follow defined motion patterns around a central point.
- Each charge’s motion continuously updates the surrounding field — creating a time-dependent electrostatic visualization.
- The system efficiently handles many simultaneous charges (tens or even hundreds, depending on setup), maintaining stable framerates through optimized computation and procedural line management.
Charge strengths can smoothly oscillate using Perlin noise, simulating fluctuations in field intensity — ideal for representing pulsating or dynamic systems.
| Feature | Description |
|---|---|
| ⚙️ Numerical Integration | RK4 method used for both motion and field tracing. |
| ⚡ Coulomb Field Calculation | Real-time vector summation from multiple sources. |
| 🧮 Gauss’s Law Visualization | Field line density proportional to net charge magnitude. |
| 🌀 Dynamic Multi-Charge Support | Move, rotate, or oscillate dozens of charges simultaneously. |
| 🎨 Gradient Field Lines | Continuous color blending between positive and negative sources. |
- 🧩 Unity Engine (C#) — Real-time 3D rendering & simulation framework
- 🧵 LineRenderer — Procedural field line drawing
- 🔄 RK4 Integration — Stable and accurate motion and field evolution
- 🌈 Perlin Noise — Smooth charge oscillation modeling
- 🧮 Coulomb + Gauss Foundations — Field superposition and flux concepts
- 🧠 Optimized Object Pooling — Efficient handling of many field lines and charge markers
-
Clone the repository:
git clone https://github.com/pietras333/ElectricFieldVisualizer.git
-
Open in Unity 2021.3+.
-
Add the
ElectricFieldVisualizerprefab to your scene. -
Configure:
- 🔋 Number of charges
- 🌀 Motion (rotation/oscillation)
- ⚙️ Visual parameters (field lines per charge, color gradients)
-
Press Play — and watch the field come alive!
- 🟥 Positive charges radiate outward field lines.
- 🟦 Negative charges attract lines inward.
- 🌀 Moving charges dynamically distort and reshape the field.
- 💫 Multiple charges interact through superposition, forming complex field structures and interference zones.
- ⚡ GPU-accelerated field computation (Compute Shaders)
- 🌈 Adaptive field line density for charge clusters
- 🔋 Integration with Maxwell’s Equations to simulate electromagnetic waves
- 🎥 Real-time export for educational or research animations
MIT License — Free to use, modify, and expand for physics education, visualization research, or scientific art.