This project visualizes a 2D linear transformation of a triangle using SFML 3 in C++. The triangle is smoothly animated from its original coordinates to its transformed coordinates on a Cartesian plane.
This project was influenced by this high school question
-
Draws Cartesian axes on screen
-
Displays an original triangle
-
Applies a matrix transformation:
x' = y y' = x − 2y -
Smooth step-by-step animation between original and transformed triangle
-
Built using SFML 3 and MinGW (MSYS2 g++)
You must have the following installed:
Verify installation:
g++ --versionExpected example:
g++ (Rev8, Built by MSYS2 project) 15.x.x
If not installed:
- Install MSYS2
- Install toolchain:
pacman -S mingw-w64-ucrt-x86_64-gccDownload:
SFML-3.0.2-windows-gcc-...-64-bit.zip
Extract somewhere like:
F:/downloads/SFML-3.0.2/
Important folders:
include/ → header files
lib/ → libraries for linking
bin/ → required DLLs at runtime
Install extensions:
- C/C++ (Microsoft)
Configure compilerPath:
C:/msys64/ucrt64/bin/g++.exe
Open PowerShell in the project folder and run:
C:/msys64/ucrt64/bin/g++.exe matrix.cpp `
-IF:/downloads/SFML-3.0.2-windows-gcc-14.2.0-mingw-64-bit/SFML-3.0.2/include `
-LF:/downloads/SFML-3.0.2-windows-gcc-14.2.0-mingw-64-bit/SFML-3.0.2/lib `
-lsfml-graphics -lsfml-window -lsfml-system `
-o matrix.exeAfter compiling:
.\matrix.exeIf you see missing DLL errors, copy all files from:
SFML/bin/
into the same folder as:
matrix.exe
Then run again.
A linear transformation matrix changes point coordinates:
[ x' ] [ 0 1 ] [ x ]
[ y' ] = [ 1 -2 ] [ y ]
This project:
- Shows the original triangle
- Animates the continuous transformation
- Helps visualize matrix effects in geometry
matrix_math/
│
├── matrix.cpp
├── matrix.exe (after compilation)
└── README.md
- Show both original and transformed triangles
- Add grid lines
- Allow keyboard-controlled transformations
- Display matrix values on screen
- Support multiple transformation types:
- Rotation
- Scaling
- Reflection
- Shear
David Kingori
