Skip to content

Davidmuthee12/matrix-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Triangle Matrix Transformation (SFML 3 + C++)

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

alt text

Features

  • 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++)


Requirements

You must have the following installed:

1. C++ Compiler (MSYS2 MinGW)

Verify installation:

g++ --version

Expected example:

g++ (Rev8, Built by MSYS2 project) 15.x.x

If not installed:

  • Install MSYS2
  • Install toolchain:
pacman -S mingw-w64-ucrt-x86_64-gcc

2. SFML 3 (GCC / MinGW build)

Download:

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

3. VS Code (optional but recommended)

Install extensions:

  • C/C++ (Microsoft)

Configure compilerPath:

C:/msys64/ucrt64/bin/g++.exe

How to Compile

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.exe

How to Run

After compiling:

.\matrix.exe

If you see missing DLL errors, copy all files from:

SFML/bin/

into the same folder as:

matrix.exe

Then run again.


📐 Mathematical Idea

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

Project Structure

matrix_math/
│
├── matrix.cpp
├── matrix.exe (after compilation)
└── README.md

Possible Improvements

  • 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

Author

David Kingori

About

A C++ matrix mathematics library with real-time visualization using SFML graphics. Explore linear algebra operations through interactive graphics.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages