A small C program that renders a rotating 3D cube in the terminal using ASCII characters.
It works by generating points on the surface of a cube, rotating them in 3D space, projecting them onto a 2D terminal screen, and then drawing them frame by frame.
The animation runs continuously, creating the illusion of a spinning cube entirely using text characters.
The terminal is fundamentally 2D, but this program simulates 3D rendering by doing the following:
- Generate points on the surfaces of a cube in 3D space
- Rotate those points around the X, Y, and Z axes
- Project the rotated 3D coordinates onto a 2D screen
- Use a z-buffer to determine which surfaces should appear in front
- Draw characters at the projected coordinates
- Repeat the process while gradually changing rotation angles
Because this runs in a loop, the cube appears to rotate smoothly.
This file contains everything needed to render the animation:
- cube geometry
- rotation math
- perspective projection
- z-buffer rendering
- terminal animation loop