A Python-based Vector library that allows the user to perform a variety of calculations, including the abitily to visualize vectors with mathplotlib.
- Vector class: custom vector class object that allows you to perform basic operations that you would expect from any other types.
- GraphVector class: used to graph the custom defined vector objects using mathplotlib.
-
Clone or download the repository containing the code.
-
Make sure you have Python 3 installed on your system and matplotlib is supported(is installed).
-
If you want to run the program on your local machine, just import the
GraphVec.pyscript.import GraphVec.py
-
Once the script is imported, you'll be able to create a vector object using:
- x = Vector((p1x,p1y),(p2x,p2y)) where p1 and p2 are defined with their x and y components.
-
Graph the vectors by puttting them into a list or dictionary and into the GraphVector object.
- Graphvector(vectors = [], dict = {})
This library allows you to add two custom created vector objects.
- Addition (
+): Add two vectors. - Subtraction (
-): Subtract two vectors. - Multiplication (
*): Multiply the x and y component of the vector to a scalar. - Division (
/): Divide the x and y components of the vector to a scalar.
- Visualization of vectors from a list
you can create a list containing vectors like this:
k = Vector((1,1),(2,2)) vectors = [Vector((0,0),(1,1)),k] GraphVector(vectors) - Visualization of vectors from a list
you can create a dictionary containing vectors like this:
k = Vector((1,1),(2,2)) vectors = {'A':Vector((0,0),(1,1)), 'k':k} GraphVector(dict = vectors)
- A console based interaction to this library in the Console_GraphVec.py file.
This project is licensed under the MIT License - see the LICENSE file for details.