Skip to main content

Function: fourierCoefficients()

fourierCoefficients(samples): FourierCoefficient[]

Defined in: src/mobjects/graphing/fourier.ts:43

Compute the discrete Fourier coefficients of a list of complex samples.

Given N samples f[0..N-1] taken at equal spacing over one period, the coefficient for index k is:

c_k = (1 / N) * Σ_n f[n] * e^(-2πi · k · n / N)

The returned array has one entry per k (DC term first, index k = 0). Each entry carries a centered signed frequency: indices in the upper half (k > N/2) map to the negative frequency k - N. Centered frequencies make the vectors rotate in their natural slow-to-fast, alternating-direction order while still reconstructing every sample exactly (see reconstructSample).

Parameters​

samples​

Complex[]

Complex path samples, equally spaced over one period.

Returns​

FourierCoefficient[]

One FourierCoefficient per sample index. Empty input yields [].