HomeMedicine & BiophysicsECG & the Heartbeat — Electrical Waves of the Heart

❤️ ECG & the Heartbeat — Electrical Waves of the Heart

Each heartbeat is an electrical wave sweeping from the SA node through the heart. The ECG records it as the familiar P-QRS-T trace; arrhythmias distort the rhythm.

Medicine & Biophysics3DEasy60 FPS
ecg-heart ↗ Open standalone

About ECG & the Heartbeat

This simulation models the electrical excitation wave that travels through the heart with every beat, starting at the sinoatrial (SA) node in the right atrium and propagating through the atrioventricular (AV) node, the bundle of His, and the Purkinje fibres to reach the ventricles. The resulting voltage changes are recorded on the skin as the electrocardiogram (ECG), displaying the characteristic P wave (atrial depolarisation), QRS complex (ventricular depolarisation), and T wave (ventricular repolarisation). Users can adjust heart rate and amplitude, and switch between rhythm presets to observe how different arrhythmias distort the normal P-QRS-T pattern.

The ECG was pioneered by Willem Einthoven in the early 1900s and remains the most widely used cardiac diagnostic tool in clinical medicine today, capable of detecting arrhythmias, conduction defects, and myocardial injury within seconds of recording.

Frequently Asked Questions

What does an ECG actually measure?

An ECG (electrocardiogram) records the tiny voltage changes on the body surface caused by the wave of electrical depolarisation and repolarisation spreading through the heart muscle with each beat. Electrodes placed on the limbs and chest detect these millivolt-scale signals, which are amplified and plotted against time to produce the familiar waveform trace.

How do I use this simulation?

Use the Heart Rate slider to set beats per minute between 30 and 200 bpm, and watch both the animated heart diagram and the scrolling ECG trace update in real time. The Rhythm Preset buttons switch between normal sinus rhythm, tachycardia, bradycardia, AV block, and ventricular fibrillation so you can compare how each condition changes the waveform shape and spacing. The Amplitude control scales the vertical mV display, and Pause/Reset let you freeze or restart the trace.

What are the P wave, QRS complex, and T wave?

The P wave represents atrial depolarisation as the electrical impulse spreads from the SA node across both atria, causing them to contract. The QRS complex, the tallest and sharpest feature, represents rapid ventricular depolarisation conducted via the bundle of His and Purkinje fibres. The T wave represents ventricular repolarisation as the ventricles reset electrically for the next beat; atrial repolarisation is hidden inside the large QRS complex.

What is the mathematical model behind the simulated ECG waveform?

The ECG voltage at each point in the beat cycle is computed as a sum of Gaussian functions: V(t) = sum of A_i times exp(-(t - mu_i)^2 / (2 * sigma_i^2)), where each Gaussian models one wave component (P, Q, R, S, T) with its own amplitude A_i, timing mu_i, and width sigma_i. The beat period is T = 60 / HR seconds, and the phase within each beat is p = t mod T, normalised to 0..1. Ventricular fibrillation is approximated by a sum of incommensurate sine waves at frequencies around 20-100 Hz, replacing the structured Gaussian model.

How is the ECG used in real clinical practice?

A standard 12-lead clinical ECG is recorded at 25 mm/s paper speed and 10 mm/mV calibration, so each large 5 mm square equals 0.2 seconds, allowing cardiologists to measure intervals (PR, QRS, QT) and calculate heart rate by dividing 300 by the number of large squares between R peaks. ECGs are used to diagnose myocardial infarction (by ST-segment changes), arrhythmias, conduction blocks, electrolyte imbalances, and drug toxicity within minutes of recording.

Is it a misconception that a faster heart rate always means a less healthy heart?

Yes, this is a common misconception. A trained endurance athlete may have a resting rate of 35-50 bpm (bradycardia by textbook definition) because their stroke volume is large and each beat pumps more blood; this is a sign of cardiovascular fitness, not disease. Conversely, a normal rate of 70 bpm in a sedentary person may reflect a lower cardiac output per beat. Context, fitness level, and the presence of symptoms always matter far more than the number alone.

Who invented the electrocardiogram and when?

Willem Einthoven, a Dutch physiologist, developed the string galvanometer ECG between 1901 and 1903 and published the first systematic ECG recordings of cardiac arrhythmias. He defined the P, Q, R, S, and T wave nomenclature still used today. Einthoven received the Nobel Prize in Physiology or Medicine in 1924 for this discovery. Earlier work by Augustus Waller in 1887 demonstrated that the heart's electrical activity could be recorded from the body surface, but Einthoven's instrument was sensitive and practical enough for clinical use.

What other physiological phenomena are related to the cardiac ECG?

The ECG is closely related to the cardiac action potential at the cellular level, where sodium, calcium, and potassium ion channels open and close in sequence to produce the depolarisation and repolarisation currents. The mechanical contraction of the heart (producing the pulse and blood pressure waveform) follows the electrical signal with a short delay. Electromyography (EMG) uses similar surface electrode techniques to record muscle action potentials, and electroencephalography (EEG) records analogous electrical waves from the brain.

How is ECG technology used in wearable devices and engineering?

Modern smartwatches and fitness bands incorporate single-lead ECG electrodes that can detect atrial fibrillation in real time by analysing R-R interval irregularity. Implantable cardiac monitors can record continuously for up to three years. In biomedical engineering, deep-learning models trained on millions of ECG recordings can now identify conditions such as hypertrophic cardiomyopathy and low ejection fraction from a resting ECG with accuracy approaching that of trained cardiologists.

What are current research frontiers in cardiac electrophysiology?

Researchers are developing high-density multi-electrode mapping systems that can reconstruct three-dimensional electrical activation maps of the whole heart in real time, enabling more precise ablation therapy for complex arrhythmias. Optogenetics is being explored to control cardiac rhythm with light rather than electrical shocks. Computational cardiac models that couple ion-channel dynamics, tissue mechanics, and body-surface ECG prediction are being used to personalise treatment planning and predict which patients are at risk of sudden cardiac death before an event occurs.

⚙ Under the hood

Each heartbeat is an electrical wave sweeping from the SA node through the heart. The ECG records it as the familiar P-QRS-T trace; arrhythmias distort the rhythm.

ECGheartaction potentialP-QRS-TCanvas 2D

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)