How do you graph a fractal on a line, as a function of time and position?

185 Views Asked by At

I'm writing ANSI C code for work and just got working my LED Light Show Library. The first project it's going on is a sound bar with 10 volume indicator (1-color (white)) leds that are lined-up. I've already done a lot of the UI indicator light shows (such as dimming down to zero brightness), and was asked to do a "Knight Rider" effect where the leds form a blob that moves back and forth.

However, since I can use any math function of time (minimally 10mS ticks, specify any multiple of that) and led position (or some variable I define as position), I thought why not fractals. So what would make the most spectacular show that involves a fractal function like taking iterations of $P_c(z) = z^2 + c$, and displaying either $0$ or $\max$ brightness for divergent iterations and map the limit value of the converging sequence to $0\dots 255$ (PWM register values, that control the brightness of each LED), using $\tan^{-1}$ or something...

But two questions arise, (1) How should I parameterize $f(c) = \cdots \circ P_c\circ P_c(0)$, with a time and position variable and (2) How do should I map $f(\Bbb{C}) \to \Bbb{R}$, that makes for the best light show!!! Opinions welcome, as obviously this is not something you can prove without me defining what makes a better light show.

1

There are 1 best solutions below

0
On BEST ANSWER

I will apply K.I.S.S. principle.

I will create a light show that runs forever and calls a function of led position $x$ and time tick $t$.

The function returns a value from $0$ to $255$.

So for fractal function $f(t, x)$, I will embed the space of $(x, t)$ into $\Bbb{C}$ by $(x,t) \to t + ix$. Then set $g(x,t) = \cdots \circ P_{ix + t} \circ P_{ix + t} (0)$. Map the output of $g$ to $\Bbb{R}$ by taking the magnitude. Then take the $\tan^{-1}$ of that to map to $[0, \pi/2]$ ($\infty \mapsto \pi/2)$. Then map $[0, \pi/2] \to [0, 255] \subset \Bbb{Z}$ linearly.

If $t$ runs out of bounds, idk what do yet. Maybe I'll iterate a random $a \in C$ by setting $a = 0$ at first then $a = g(x,t_m)$ when the time runs out.