MathTools

A math library I made to learn and explore math.

Usage

Open up a terminal and go to the directory where you want to put Math Tools.


Clone the repo:

git clone https://github.com/martin-petersson/MathTools.git

Inside the same directory run the interactive Python interpreter:

$ python
>>> import mathtools as mt

Define a vector

a = mt.Vector([x, y])

Adding two vectors

a + b

Multiply vector by scalar

a * 0.78

Divide vector by scalar

a / 2

Normalize/unitize vector

a.unit

Dot product of two vectors

a.dot(b)

Cross product of two 3d vectors

a.cross(b)

Linear interpolation between two vectors

t = 0.5
a.lerp(b, t)

Define a matrix

m = mt.Matrix([[a, b], [c, d]])