back to indexDonut-shaped C code that generates a 3D spinning donut
00:00:00.000 |
Here on the left is a spinning ASCII donut, and on the right is a donut-shaped C code 00:00:13.780 |
Now I recommend you check out Andy's blog post on the mathematics behind a flying spinning 00:00:24.220 |
The basic steps are create a circle, then create a torus by rotating the circle about 00:00:31.300 |
Then using rotation matrices, spin the donut around the X and Z axes. 00:00:37.800 |
Finally project the donut onto the 2D screen, adding illumination by calculating the surface 00:00:42.960 |
normal after picking a particular light source. 00:00:46.820 |
The cool thing is because this is ASCII world, there's different characters associated with 00:00:52.820 |
We can go back to the de-obfuscated version of the code that I generated, adding a microsecond 00:01:02.680 |
Compiling and running the code, we get our spinning donut. 00:01:08.880 |
There's a lot of parameters that you can control with this donut, including the field of view 00:01:13.320 |
and the distance of the donut from the viewer. 00:01:17.080 |
I spend at least an hour every day learning and exploring outside my main line of work, 00:01:22.320 |
so I thought it'd be cool to start throwing together quick little videos about things 00:01:27.600 |
that I find beautiful, whether they're basic or advanced in the world of machine learning, 00:01:32.840 |
math, computer science, programming, psychology, whatever, even biology, physics, history, 00:01:38.440 |
So, hope this is of value, fun, and something you would enjoy.