Donut-shaped C code that generates a 3D spinning donut
DEqXNfs_HhY • 2020-07-06
Transcript preview
Open
Kind: captions
Language: en
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
Resume
Read
file updated 2026-02-13 13:23:59 UTC
Categories
Manage