Skip to content

Commit 8d3b192

Browse files
committed
transforms wip
1 parent 5db757e commit 8d3b192

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

src/dsp/fourier_from_finite_sequences.clj

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,11 @@ rotated-90
259259
rotated-neg-90
260260

261261
;; Example 4: Multiply by point on unit circle at arbitrary angle
262+
;; (The **unit circle** is the circle with radius 1 centered at the origin—all points at distance 1 from (0,0))
262263

263264
(def z-rotated
264265
(complex-mult {:real 1.0 :imag 1.0} ; 45° from x-axis, magnitude √2
265-
{:real 0.0 :imag 1.0})) ; i = 90° rotation
266+
{:real 0.0 :imag 1.0})) ; i = 90° rotation (i is on the unit circle)
266267

267268
z-rotated
268269

@@ -289,29 +290,31 @@ z-rotated
289290
;; Visualize rotation by multiplying several points by i (90° counterclockwise):
290291

291292
(def original-points
292-
[{:real 1.0 :imag 0.0}
293-
{:real 0.7 :imag 0.7}
294-
{:real 0.0 :imag 1.0}
295-
{:real -0.7 :imag 0.7}])
293+
[{:real 1.0 :imag 0.2}
294+
{:real 0.7 :imag 0.4}
295+
{:real 0.4 :imag 0.6}
296+
{:real 0.2 :imag 0.8}])
296297

297298
(def rotated-points
298299
(mapv #(complex-mult % {:real 0.0 :imag 1.0}) original-points))
299300

300301
(def rotation-demo-data
301302
(tc/concat
303+
;; Original points
302304
(tc/dataset (map-indexed
303305
(fn [i p]
304306
{:x (:real p)
305307
:y (:imag p)
306-
:type "Original"
307-
:point (str "P" i)})
308+
:type "Original points"
309+
:label (str "P" i)})
308310
original-points))
311+
;; Rotated points
309312
(tc/dataset (map-indexed
310313
(fn [i p]
311314
{:x (:real p)
312315
:y (:imag p)
313-
:type "After ×i (90° rotation)"
314-
:point (str "P" i)})
316+
:type "After ×i (rotated 90°)"
317+
:label (str "P" i "")})
315318
rotated-points))))
316319

317320
(-> rotation-demo-data
@@ -324,19 +327,12 @@ z-rotated
324327
:=title "Multiplying by i Rotates All Points 90° Counterclockwise"
325328
:=width 500
326329
:=height 500})
327-
(plotly/layer-point {:=mark-size 12})
330+
(plotly/layer-point {:=mark-size 14})
328331
plotly/plot
329332
(assoc-in [:layout :yaxis :scaleanchor] "x"))
330333

331334
;; **Key insight:** Multiplying by a number on the unit circle (magnitude 1) performs a pure rotation
332335
;; (no scaling—just rotation).
333-
;;
334-
;; **Why this matters for Fourier transforms:**
335-
;; - Addition = superposition of rotations
336-
;; - Multiplication = compose rotations (rotate by the angle, scale by magnitude)
337-
;;
338-
;; The algebra **matches the geometry**. Complex numbers aren't just a 2D plane with
339-
;; coordinates—they're an **algebraic structure that embodies rotation**.
340336

341337
;; ### Euler's Formula: The Compact Notation
342338

@@ -345,18 +341,18 @@ z-rotated
345341
;; **$e^{i\theta} = \cos(\theta) + i \cdot \sin(\theta)$**
346342
;;
347343
;; This expresses a point at angle $\theta$ on the unit circle. It's not a new concept—it's
348-
;; just compact notation for what we've been doing: the real part is $\cos(\theta)$ (horizontal)
344+
;; just compact representation for what we've been doing: the real part is $\cos(\theta)$ (horizontal)
349345
;; and the imaginary part is $\sin(\theta)$ (vertical).
350346
;;
351-
;; The exponential notation is powerful because it makes the rotation properties explicit:
352-
;; - $e^{i\theta}$ represents rotation by angle $\theta$
353-
;; - $e^{i\theta_1} \times e^{i\theta_2} = e^{i(\theta_1+\theta_2)}$ — multiplying rotations adds their angles
354-
;; - $e^{-i\theta}$ is rotation in the opposite direction (conjugate)
347+
;; The exponential is powerful because it makes the rotation properties explicit:
348+
;; - Multiplication by $e^{i\theta}$ is rotation by angle $\theta$
349+
;; - Multiplying $e^{i\theta_1} \times e^{i\theta_2} = e^{i(\theta_1+\theta_2)}$ composes rotationsangles add
350+
;; - Multiplication by $e^{-i\theta}$ is rotation in the opposite direction (conjugate)
355351
;;
356352
;; We'll use this notation when we write the DFT formula, but remember: it's describing the
357353
;; same geometric rotation we've been visualizing.
358354
;;
359-
;; **Now the compact notation makes sense:** Any number on the unit circle can be written
355+
;; **Now the compact representation makes sense:** Any number on the unit circle can be written
360356
;; as $e^{i\theta}$ for some angle $\theta$. Multiplication by $e^{i\theta}$ rotates by angle θ,
361357
;; and the algebra reflects the geometry: $e^{i\theta_1} \times e^{i\theta_2} = e^{i(\theta_1+\theta_2)}$ — angles add!
362358

0 commit comments

Comments
 (0)