Decomposing Curves into Rotating Circles
DFT: Global frequency analysis with rotating circles
DCT: Cosine basis (JPEG compression)
STFT: Real-time localized analysis (draw mode only)
HHT: Adaptive decomposition via empirical modes
A periodic signal can be represented as a sum of rotating vectors — often visualized as epicycles — where each rotation corresponds to a frequency component with an amplitude, angular speed, and phase. By treating a 2D parametric curve as a complex-valued time sequence, we apply a discrete Fourier transform to extract its frequency components and reconstruct the motion using the dominant ones.
The natural method for epicycles! Complex exponentials e^(iωt) are literally rotating vectors in the complex plane. Each Fourier coefficient directly gives you one rotating circle. This is why Fourier analysis is fundamental to understanding periodic phenomena—the math naturally describes rotation.
Used in JPEG, MP3, and video compression! DCT uses only real-valued cosine basis functions (no complex numbers). To make it work with epicycles, we mirror the signal symmetrically and apply DFT. This shows how compression formats represent curves using only half the information (no sine components). Works surprisingly well! You can visually tell that DCT results tend to be smoother, this is also expected.
You might notice that the DCT animation is longer: it will reach the end and go all the way back. This is because DCT requires the signal to be even, meaning it's symmetric with respect to the time.
STFT applies Fourier analysis to localized windows that continuously track your drawing. Unlike other transforms that analyze a complete closed curve, STFT operates in real-time on the most recent segment you've drawn. This mimics audio spectrograms which analyze sound as it plays.
Unique capability: STFT captures drawing speed information that regular Fourier Transform cannot! Fast drawing creates denser point spacing in time, affecting the frequency content. This is why STFT is crucial for analyzing non-stationary signals where characteristics change over time.
Clamping behavior: When you release the mouse, STFT assumes your position stays at that point. This causes the endpoint to accumulate weight over time, shown by the intensifying pulsing glow. The longer you wait, the more that single point dominates the frequency spectrum, distorting the reconstruction toward that location.
Drawing techniques: You can draw smooth curves by dragging, or create piecewise linear paths (like line charts) by clicking at different points without dragging. Both approaches work well for exploring STFT's time-localized behavior!
Visual indicators:
HHT is an adaptive, data-driven method that normally uses Empirical Mode Decomposition (EMD). However, full EMD is extremely complex for this interactive demo. Instead, we use a simplified approach: compute a wider frequency range and adaptively select the strongest components.
⚠️ Warning: Component Explosion
Increasing the number of components can cause chaotic behavior. Unlike DFT/DCT which have stable orthogonal bases, HHT adaptively selects components by amplitude ranking. When you change the slider mid-animation, previously dominant frequencies may suddenly get replaced by different ones, causing violent jumps. This is a key difference from Fourier methods!
HHT vs FFT Comparison:
| Property | FFT/DFT | HHT |
|---|---|---|
| Basis functions | Fixed (sine/cosine) | Adaptive (data-driven) |
| Stability | ✓ Stable, orthogonal | ✗ Can be chaotic |
| Non-linear signals | ✗ Poor for non-stationary | ✓ Excellent |
| Speed | ✓ Fast (O(n log n)) | ✗ Slow (iterative) |
| Use cases | Audio, images, general | Biomedical (EEG, ECG), seismic, climate |
HHT is widely used in biomechanical animation (motion capture analysis), medical imaging (extracting physiological rhythms), and financial time series. Its adaptive nature makes it ideal for signals with time-varying characteristics.
The more circles you add, the more faithfully the original curve is reconstructed. Try adjusting the slider to see!
Fourier Series Decomposition:
$$f(t) = \sum_{n=-\infty}^{\infty} c_n e^{2\pi i n t}$$
Each coefficient $c_n$ represents a rotating circle with radius $|c_n|$ and frequency $n$
Discrete Fourier Transform:
$$X_k = \sum_{n=0}^{N-1} x_n e^{-2\pi i k n / N}$$
Converts discrete time-domain points to frequency components (complex coefficients)
Discrete Cosine Transform (Type-II):
$$X_k = \sum_{n=0}^{N-1} x_n \cos\left[\frac{\pi k (n + 0.5)}{N}\right]$$
Real-valued transform using only cosine basis. Popular in compression (JPEG uses 8×8 DCT blocks)
Complex Exponential as Rotation:
$$e^{i\theta} = \cos\theta + i\sin\theta$$
Euler's formula shows why Fourier naturally creates rotating circles—complex exponentials trace circular paths!
Short-Time Fourier Transform (STFT):
$$\text{STFT}(t, \omega) = \int_{-\infty}^{\infty} f(\tau) w(\tau - t) e^{-i\omega\tau} d\tau$$
Applies Fourier transform to windowed segments $w(t)$ (e.g., Hann window) sliding through time
Empirical Mode Decomposition (EMD):
$$f(t) = \sum_{i=1}^{n} \text{IMF}_i(t) + r_n(t)$$
Adaptively decomposes signal into Intrinsic Mode Functions (IMFs) via iterative sifting based on local extrema