Although this spinning donut is pretty impressive, it is quite easy to obtain using basic linear algebra. I'm going to show you how.
The first step is to sample points from the surface of a 3D donut. We can do this by rotating a circle sitting on the plane [begin-latex-inline](x, y)[end-latex-inline] centered at [begin-latex-inline](c,0,0)[end-latex-inline] around the [begin-latex-inline]y[end-latex-inline] axis.
Sampling the circle points can be done using polar coordinates:
Once we have the circle, we can rotate it around the [begin-latex-inline]y[end-latex-inline] axis using a 3D rotation matrix:
This will get you points on the donut surface. You can now multiply these points by a rotation matrix that rotates around all three axes to get the animation.