Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

ASCII Rotating Cube (cube.c)

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.


What This Program Does

The terminal is fundamentally 2D, but this program simulates 3D rendering by doing the following:

  1. Generate points on the surfaces of a cube in 3D space
  2. Rotate those points around the X, Y, and Z axes
  3. Project the rotated 3D coordinates onto a 2D screen
  4. Use a z-buffer to determine which surfaces should appear in front
  5. Draw characters at the projected coordinates
  6. Repeat the process while gradually changing rotation angles

Because this runs in a loop, the cube appears to rotate smoothly.


File

This file contains everything needed to render the animation:

  • cube geometry
  • rotation math
  • perspective projection
  • z-buffer rendering
  • terminal animation loop

About

3D ASCII Spinning Cube

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages