This content originally appeared on DEV Community and was authored by NordicBeaver
What if we connect a couple of rotating sticks together and trace the shape they make? We can get something like this.
The most interesting part about this is if we get enough sticks we can draw anything we want!
You can try it yourself here. Just draw a closed (that's pretty important) shape and press 'Start'.
This is based on a thing caller Fourier Transform. Basically, every complex function on a set interval can be represented as an infinite sum of exponents:
Where
But if we look closer we may notice that every element of that sum is actually a rotating vector Cn. So if we manage to represent a shape as a complex function, we could find these vectors (maybe not all, since there is infinite number of them, but we don't need all) and that would mean drawing the shape just by rotating those vectors!
I made a video where I tried to explain this in more detail and code it in TypeScript.
Enjoy!
This content originally appeared on DEV Community and was authored by NordicBeaver

NordicBeaver | Sciencx (2021-11-24T15:06:59+00:00) Drawing with Mr. Fourier and Typescript. Retrieved from https://www.scien.cx/2021/11/24/drawing-with-mr-fourier-and-typescript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.