Video summary
The video presents a fascinating visual demonstration where an ASCII spinning donut appears on the left side of the screen, while the corresponding C code that generates this animation is displayed on the right with syntax highlighting. This creative project was developed by Andy Sloan, whose work explores the intersection of mathematics and programming to render complex 3D objects using text-based graphics. The presentation highlights how a simple circle can be transformed into a torus, often referred to as a "Taurus" in this context, through specific geometric operations that form the basis of the visual effect. The mathematical foundation for generating these spinning donuts involves several precise steps: first creating an initial circle, then rotating it around the y-axis to form the toroidal shape. Once the 3D structure is established, rotation matrices are applied to spin the object along both the x and z axes, simulating movement in three-dimensional space before projecting the final image onto a two-dimensional screen. To add depth and realism, the code calculates surface normals for illumination purposes, determining how light interacts with different parts of the donut's geometry based on a specific light source position. A unique feature of this ASCII-based rendering is its ability to map varying levels of luminance to distinct characters, creating a textured appearance that mimics shading in traditional computer graphics. The code includes adjustable parameters such as the field of view and the distance between the viewer and the donut, allowing users to customize their perspective. Additionally, an optimized version of the code incorporates a microsecond sleep function specifically designed to aid in smooth animation timing when compiled and executed on different systems. Beyond the technical demonstration, the creator shares personal insights into their daily routine of spending at least an hour exploring topics outside their primary professional focus. This dedication to curiosity drives the production of quick videos that showcase beautiful concepts ranging from machine learning and computer science to psychology, biology, physics, history, and philosophy. The overarching goal is to share these discoveries with an audience interested in both basic and advanced subjects within STEM fields and beyond. The video serves as a bridge between abstract mathematical theory and tangible visual output, inviting viewers to explore the underlying mathematics behind such animations via Andy Sloan's blog post linked in the description. By combining rigorous geometric principles with creative coding techniques, the project illustrates how complex 3D rendering can be achieved using simple text characters. The final result is not only a visually engaging spinning donut but also an educational resource that demystifies the process of generating such graphics through code and math.
Read the full video transcript
here on the left is a spinning ASCII
donut
and on the right is a donut shaped C
code by Andy Sloan that generates it
now with syntax highlighting
now I recommend you check out Andy's
blog post on the mathematics behind a
flying spinning Taurus AKA donut the
link to the post is in the description
the basic steps are create a circle then
create a Taurus by rotating the circle
about the y-axis then using rotation
matrices spin a donut around the x and z
axes
finally project the donut onto the 2D
screen adding illumination by
calculating the surface normal after
picking a particular light source the
cool thing is because this is ASCII
world there's different characters
associated with different levels of
luminance we can go back to the
de-africated version of the code that I
generated
adding a microsecond sleeve function to
Aid in the animation compiling and
running the code
we get our spinning donut
there's a lot of parameters that you can
control with this donut including the
field of view and the distance of the
donor from the viewer I spend at least
an hour every day learning and exploring
outside my main line of work so I
thought it'd be cool to uh start
throwing together quick little videos
about things that I find beautiful
whether they're basic or advanced in the
world of machine learning math computer
science programming psychology whatever
even biology physics history and
philosophy so
hope this is uh a value fun and
something you would enjoy