Writing
Visualizing transfer functions in p5.js
In 2020 I was following lectures on automatic control and learned about the transfer function of a system and ways to visualize it, at which point I was curious so I went ahead and wrote a simple visualizer for generic transfer functions.
You can jump ahead to the visualizer.
Setup
The basic idea is that we can build a system with a feedback loop that takes an input signal
We then focus on linear time-invariant (LTI) transformations, which in a few words are those which take as input
In the Laplace function space, the convolution of our transformation becomes a multiplication
Let’s plug in our
We recursively apply it so we end up with:
Visualizer
Note that if our
So, when designing
But
Well, there are multiple approaches and this is where I got curious and decided to write a visualizer in p5.js. I included a cartesian plot and a Nichols plot. Other common plots include Bode and Nyquist.
I also included a simple abstract syntax tree (AST) parser and traversal so you can write any
You can try it out right here:
Controls:
Drag to move around.
Mouse wheel to zoom in/out.
Space to reset offset.