We use matrices throughout multiple field of mathematics, but we seldom quite "see" what changes these matrices make. A matrix cannot have 0 as its determinant. But we can't really tell the reason behind it.
This project is an effort to visualize the mathematics that we've studied in our high school years: Linear Transformations
Highly inspired by 3Blue1Brown and his efforts in visualizing mathematics, Linear Transformation Visualizer attempts for a similar goal: for you to become clearer what mathematics means
A 3D interactive visualizer that demonstrates how linear transformations affect objects and coordinate spaces. It allows users to apply, animate, and explore transformations such as rotations, scaling, reflections, and shears — all through a real-time rendered cube and grid using OpenGL, Pygame, and a Tkinter matrix input GUI.
In linear algebra, every linear transformation can be represented by a matrix. Upon matrix multiplication, the entire space changes it's dimenison: it stretches, rotates, reflects or skews. And this program allows you to see the phenomenon!
Note:
- Determinant = Volume scaling factor
- Negative determinant → Orientation reversal
And what happens when the matrix is non-invertible? Run it to find out ;)
---
Make sure you have Python 3.8+ installed.
Then run:
pip install pygame PyOpenGL PyOpenGL_accelerate numpypython linear_transformation_visualizer.py| Component | Description |
|---|---|
MatrixInputGUI |
Tkinter interface for entering and applying transformation matrices |
LinearTransformationVisualizer |
Main OpenGL + Pygame visualizer for rendering and animating transformations |
apply_transformation() |
Applies the given matrix to cube, grid, and basis |
update_animation() |
Interpolates transformation for smooth visual transitions |
draw_info_panel() |
Displays determinant, type, and control instructions overlay |
| Library | Purpose |
|---|---|
pygame |
Window creation, input handling, and OpenGL context |
PyOpenGL |
3D rendering and visualization |
numpy |
Matrix and vector operations |
tkinter |
Matrix input GUI |
| Transformation | Matrix |
|---|---|
| Rotate Z (90°) | [[0, -1, 0], [1, 0, 0], [0, 0, 1]] |
| Scale XY (2×) | [[2, 0, 0], [0, 2, 0], [0, 0, 1]] |
| Shear X | [[1, 0.5, 0], [0, 1, 0], [0, 0, 1]] |
| Reflect X | [[-1, 0, 0], [0, 1, 0], [0, 0, 1]] |
- If you see an error like
No module named 'OpenGL'→ Runpip install PyOpenGL PyOpenGL_accelerate - If GUI doesn’t show up → Ensure Tkinter is installed (it comes by default with most Python distributions)
- Some systems may require a restart after installing
pygameandPyOpenGL.
Prashansa Shrestha *Computer Engineering Student @ Pulchowk Campus



