Project 10: The 3D Renderer (Linear Algebra & Projection)
Build a simple 3D renderer that projects points onto a 2D screen.
Project Overview
| Attribute | Value |
|---|---|
| Difficulty | Level 2: Intermediate |
| Time Estimate | 1-2 weeks |
| Main Language | Python |
| Alternative Languages | JavaScript, C++ |
| Knowledge Area | Linear algebra and projection |
| Tools | Plotting tool |
| Main Book | “Computer Graphics from Scratch” by Gabriel Gambetta |
What you’ll build: A program that renders rotating 3D points or wireframes onto a 2D canvas using projection math.
Why it teaches math: Projection makes vectors and matrices practical. You can see transformations directly.
Core challenges you’ll face:
- Implementing rotation matrices
- Applying perspective projection
- Managing camera position
Real World Outcome
You will render a rotating cube or simple model, showing a wireframe animation or sequence of frames.
Example Output:
$ python render.py --model cube
Rendered 120 frames
Saved frames to ./frames/
Verification steps:
- Confirm rotations look correct
- Compare projection results to expected perspective behavior
The Core Question You’re Answering
“How do 3D points become 2D pixels?”
This is the core math behind computer graphics.
Concepts You Must Understand First
Stop and research these before coding:
- Vectors and matrices
- How does a matrix transform a vector?
- Book Reference: “Computer Graphics from Scratch” by Gabriel Gambetta, Ch. 1
- Rotation matrices
- How do you rotate a point around an axis?
- Book Reference: “Linear Algebra and Its Applications” by Gilbert Strang, Ch. 5
- Perspective projection
- Why do distant objects appear smaller?
- Book Reference: “Computer Graphics from Scratch” by Gabriel Gambetta, Ch. 3
Questions to Guide Your Design
- Coordinate system
- Where is the camera located?
- Which axis is up?
- Rendering pipeline
- Will you draw just points, or connect edges?
- How will you handle depth ordering?
Thinking Exercise
Project a Point
Given a 3D point (2, 3, 4) and a camera at the origin, compute its projected 2D coordinates using a simple perspective rule.
Questions while working:
- How does the z-value affect scale?
- What happens if z approaches zero?
The Interview Questions They’ll Ask
Prepare to answer these:
- “What is a projection matrix?”
- “Why does rotation use matrices?”
- “What is the difference between orthographic and perspective projection?”
- “How do you handle depth ordering?”
- “What is a camera transform?”
Hints in Layers
Hint 1: Starting Point Render a single 3D point and project it to 2D.
Hint 2: Next Level Add rotation matrices to animate the point.
Hint 3: Technical Details Use homogeneous coordinates if you want to combine transforms.
Hint 4: Tools/Debugging Plot the projected points and check symmetry as you rotate.
Books That Will Help
| Topic | Book | Chapter |
|---|---|---|
| Graphics pipeline | “Computer Graphics from Scratch” by Gabriel Gambetta | Ch. 1 |
| Rotation matrices | “Linear Algebra and Its Applications” by Gilbert Strang | Ch. 5 |
| Projection | “Computer Graphics from Scratch” by Gabriel Gambetta | Ch. 3 |
Implementation Hints
- Start with a wireframe cube to keep it simple.
- Keep projection parameters configurable.
- Export frames to inspect motion step by step.
Learning Milestones
- First milestone: You can project a 3D point to 2D.
- Second milestone: You can rotate and render a cube.
- Final milestone: You can explain projection and camera transforms.