438

Maxwell's EM Wave Propagation

True 3D vector field visualization of an electromagnetic wave derived from Maxwell's equations. Displays mutually perpendicular transverse Electric field E vectors (Cyan), Magnetic field B vectors (Rose), and the longitudinal Poynting energy propagation vector S = 1/μ₀(E × B).

Playground
60 FPS • Canvas 2D
Click + Drag to interact with field
</>

Full Executable Algorithm Code


import type { ArtRenderer, ParameterState, RenderContext, TimeState } from '../../types/engine';
import { hsla } from '../common/color';
import { project3D } from '../common/projection3d';

// Maxwell's Electromagnetic Wave Propagation
// 3D Visualization of Transverse Orthogonal Electric (E) & Magnetic (B) Field Vectors
// and Poynting Energy Flow Vector S = 1/μ₀ (E × B) based on Maxwell's equations.
export function createMaxwellEMWave(): ArtRenderer {
  const NODE_COUNT = 38;

  return {
    setup() {},

    render(context: RenderContext, timeState: TimeState, params: ParameterState) {
      const { ctx, width, height } = context;
      const waveFreq = Number(params.frequency || 1.2);
      const waveAmp = Number(params.amplitude || 1.0);
      const t = timeState.time * waveFreq;

      ctx.fillStyle = '#020308';
      ctx.fillRect(0, 0, width, height);

      const cx = width * 0.5;
      const cy = height * 0.52;
      const scale = Math.min(width, height) / 480;

      // 3D Isometric View
      const rotY = 0.55 + Math.sin(t * 0.2) * 0.1;
      const rotX = 0.38;
      const rotZ = 0;

      ctx.save();
      ctx.globalCompositeOperation = 'screen';

      const totalLength = 360 * scale;
      const k = 0.025; // wave number

      // 1. Central Propagation Axis (z-axis / Poynting Vector S)
      const pAxisStart = project3D(-totalLength * 0.5, 0, 0, rotX, rotY, rotZ, cx, cy, 450, 520);
      const pAxisEnd = project3D(totalLength * 0.5, 0, 0, rotX, rotY, rotZ, cx, cy, 450, 520);

      ctx.beginPath();
      ctx.moveTo(pAxisStart.x, pAxisStart.y);
      ctx.lineTo(pAxisEnd.x, pAxisEnd.y);
      ctx.strokeStyle = 'rgba(255, 255, 255, 0.4)';
      ctx.lineWidth = 1.6;
      ctx.stroke();

      // Poynting Vector Arrow Head S at propagation tip
      ctx.fillStyle = '#fbbf24';
      ctx.beginPath();
      ctx.arc(pAxisEnd.x, pAxisEnd.y, 5 * scale, 0, Math.PI * 2);
      ctx.fill();

      // 2. Transverse E-Field (Electric Vectors, Cyan along y-axis)
      ctx.beginPath();
      for (let i = 0; i < NODE_COUNT; i++) {
        const normI = i / (NODE_COUNT - 1);
        const xPos = (normI - 0.5) * totalLength;
        const eField = Math.sin(xPos * k - t * 3.5) * (70 * waveAmp * scale);

        const pBase = project3D(xPos, 0, 0, rotX, rotY, rotZ, cx, cy, 450, 520);
        const pTip = project3D(xPos, eField, 0, rotX, rotY, rotZ, cx, cy, 450, 520);

        // Vector Arrow Line
        ctx.moveTo(pBase.x, pBase.y);
        ctx.lineTo(pTip.x, pTip.y);

        // Arrow tip node
        ctx.fillStyle = '#38bdf8';
        ctx.fillRect(pTip.x - 1.5, pTip.y - 1.5, 3, 3);
      }
      ctx.strokeStyle = '#38bdf8';
      ctx.lineWidth = 1.6;
      ctx.stroke();

      // Continuous E-Field Envelope Sine Curve
      ctx.beginPath();
      for (let x = -totalLength * 0.5; x <= totalLength * 0.5; x += 4) {
        const eField = Math.sin(x * k - t * 3.5) * (70 * waveAmp * scale);
        const p = project3D(x, eField, 0, rotX, rotY, rotZ, cx, cy, 450, 520);
        if (x === -totalLength * 0.5) ctx.moveTo(p.x, p.y);
        else ctx.lineTo(p.x, p.y);
      }
      ctx.strokeStyle = '#38bdf8';
      ctx.shadowColor = '#38bdf8';
      ctx.shadowBlur = 10;
      ctx.lineWidth = 2.2;
      ctx.stroke();
      ctx.shadowBlur = 0;

      // 3. Transverse B-Field (Magnetic Vectors, Magenta along z-axis)
      ctx.beginPath();
      for (let i = 0; i < NODE_COUNT; i++) {
        const normI = i / (NODE_COUNT - 1);
        const xPos = (normI - 0.5) * totalLength;
        const bField = Math.sin(xPos * k - t * 3.5) * (70 * waveAmp * scale);

        const pBase = project3D(xPos, 0, 0, rotX, rotY, rotZ, cx, cy, 450, 520);
        const pTip = project3D(xPos, 0, bField, rotX, rotY, rotZ, cx, cy, 450, 520);

        ctx.moveTo(pBase.x, pBase.y);
        ctx.lineTo(pTip.x, pTip.y);

        ctx.fillStyle = '#f43f5e';
        ctx.fillRect(pTip.x - 1.5, pTip.y - 1.5, 3, 3);
      }
      ctx.strokeStyle = '#f43f5e';
      ctx.lineWidth = 1.6;
      ctx.stroke();

      // Continuous B-Field Envelope Sine Curve
      ctx.beginPath();
      for (let x = -totalLength * 0.5; x <= totalLength * 0.5; x += 4) {
        const bField = Math.sin(x * k - t * 3.5) * (70 * waveAmp * scale);
        const p = project3D(x, 0, bField, rotX, rotY, rotZ, cx, cy, 450, 520);
        if (x === -totalLength * 0.5) ctx.moveTo(p.x, p.y);
        else ctx.lineTo(p.x, p.y);
      }
      ctx.strokeStyle = '#f43f5e';
      ctx.shadowColor = '#f43f5e';
      ctx.shadowBlur = 10;
      ctx.lineWidth = 2.2;
      ctx.stroke();
      ctx.shadowBlur = 0;

      // 4. Study HUD Equations
      ctx.restore();
      ctx.save();
      ctx.font = '11px monospace';
      ctx.fillStyle = 'rgba(56, 189, 248, 0.9)';
      ctx.fillText(`Maxwell's Equations — Electromagnetic Wave Propagation`, 20, 28);
      ctx.fillStyle = '#94a3b8';
      ctx.fillText(`∇ × E = -∂B/∂t  |  ∇ × B = μ₀ε₀ ∂E/∂t  |  c = 1/√(μ₀ε₀)`, 20, 44);
      ctx.fillText(`Electric Vector E(x,t) [Cyan] ⊥ Magnetic Vector B(x,t) [Rose] ⊥ Poynting Vector S [Gold]`, 20, 60);
      ctx.restore();
    },
  };
}
Edit in Interactive Playground Zero Dependencies • Standalone Canvas 2D
ƒ

Mathematical Formulation

medium
Analytical Equation
∇×E=−∂B∂t,∇×B=μ0ϵ0∂E∂t,S=1μ0(E×B)\nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t}, \quad \nabla \times \mathbf{B} = \mu_0\epsilon_0\frac{\partial \mathbf{E}}{\partial t}, \quad \mathbf{S} = \frac{1}{\mu_0}(\mathbf{E} \times \mathbf{B})
Click to expand
Compact Formula
E(z,t) = E_0 sin(kz - wt) j_hat; B(z,t) = B_0 sin(kz - wt) k_hat;

Mathematical Tags

#electrodynamics #maxwell-equations #em-wave #poynting-vector #physics-study #vector-fields
Author: Electrodynamics Core Target: 60 FPS

Export & Embed: Maxwell's EM Wave Propagation

4K PNG Snapshot

High-resolution single frame render

WebM Video (5s Loop)

60 FPS browser-captured stream

Standalone JS Script

Complete executable Canvas 2D algorithm

HTML Iframe Embed

<iframe src="https://art.fazleyrabbi.xyz/embed/maxwell-em-wave" width="500" height="500" frameborder="0" loading="lazy"></iframe>
ESC
↑↓ Navigate ↵ Select
113 Mathematical Artworks
Made by Fazley Rabbi
☕

Support the Project

Keep mathematical creative coding alive & open source

Or via Direct Payoneer ($0 Fee)
Payoneer Customer ID: $0 Fee Direct
24076084

💡 Payoneer app: Go to Pay → Pay to recipient → Enter ID 24076084.

Thank you for supporting generative mathematical animations! ✨