Linear Algebra Testcase

A small utility program in Python (pygame + numpy) to visualize concepts of linear transformations executed in browser using pyodide. Watch 3Blue1Brown for a nice introduction.

Try it out!

Add Objects

Click on the menu button on the top left. Click the small plus buttons to add Objects, Transforms or Transformed Objects.
You can mutate objects by dragging in the editor window (on the right) or by changing the number values (on the left side) by dragging them up or down.

Using Transformed Objects

There are two kinds of transformed objects. The first one will apply a transform onto an object (basically doing a matrix multiplication with the vector(s) of the object). Click on the transformed object and then on an object. Then click on the transformed object again and then on the transform. This will apply the transform onto the object.
The second transformed is a free text transformation, that can use all names present (like v1, T1, ...) and all numpy functions. Try np.linalg.inv(T1) to calculate the inverse of a transform.
For a more verbose explanation see Usage bellow.

Usage

You can move around in the plane with the mouse. Zoom is controlled with the mouse wheel. If you click on the button on the left top, a menu opens.

The menu shows three sections:

Controls

Custom Transformed

If you create a custom transformed and click on it, a text window appears. Here you can write a python expression. You can use all object names listed above and numpy functions (accessible via np). Objects from above will be presented as numpy-ndarray.

Example: Lets say you have a vector v1 and a 2d transformation matrix T1. You could write T1 @ v1 to apply the transformation matrix on your vector and render the result. The same works for unit circles (replace v1 with u1).

As applying a 3d transformation matrix on a 2d vector is a bit complicated, you can use the special function mm()(matrix-multiplication): mm(T1, v1).

Installation

You can install this program locally using python.
# clone repository
git clone https://github.com/Bluemi/linear-algebra-testcase.git
cd linear-algebra-testcase

# install requirements (numpy, pygame)
pip3 install -r requirements.txt

# run the programm
python3 ./src/main.py

Consider using a virtual python-environment (eg virtualenvwrapper).

Limitations / Risks