Skip to content

singh2034/C-programming-Practice

Repository files navigation

🚀 C-Programming-Practice

A collection of C projects exploring 3D math, matrix transformations, and SDL2 graphics.


🧊 Project: Rotating Cube (Euler Angles)

This project renders a 3D wireframe cube using 1,200 points. It applies a complex rotation matrix (pitch, yaw, and roll) to every point in real-time.

🛠️ Installation & Setup

To fix SDL2/SDL.h missing errors, install the development headers:

🐧 Linux (Ubuntu/Debian/Mint)

sudo apt update && sudo apt install libsdl2-dev

🎩 Linux (Fedora/Arch)

  • Fedora: sudo dnf install SDL2-devel
  • Arch: sudo pacman -S sdl2

🏗️ How to Compile

Because this project uses both SDL2 for graphics and math.h for rotation matrices, you must link both libraries:

cc -o cube cube.c -lm `sdl2-config --cflags --libs`
⚠️ Linker Warning:
If you see undefined reference to cos or DSO missing, ensure you have placed -lm at the end of your command. This tells the compiler to include the math library.

📐 The Math Behind the Rotation

The cube rotates using a 3x3 rotation matrix for 3D space. It calculates the new position of each point using the Dot Product of the rotation matrix and the point's current vector:

  • α (Alpha): Rotation around the Z-axis (Roll)
  • β (Beta): Rotation around the Y-axis (Yaw)
  • γ (Gamma): Rotation around the X-axis (Pitch)

📅 Project Roadmap

  • ✅ Setup Basic Rendering & SDL Window
  • ✅ Implement 3D Point cloud
  • ✅ Matrix Rotation (Euler Angles)
  • 🚧 Perspective Projection (Coming Soon)
  • 📅 Line Drawing/Wireframe (Planned)
Maintained by Luna

About

C-programming Practice & Projects

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors