Maths and Graph functions for vectors on the 2D plane
Project description
Vector2D library
Helper library with Math and graphing related functions for vectors in the 2D plane.
Usage
Install the library by typing:
python -m pip install vec2d
Once installed, you'll have access to the Math and graphing packages:
from vec2d.math import add
from vec2d.graph import draw, Arrow, Colors, LineStyles
u = (2, 0)
v = (1, 3)
draw(
Arrow(u, color=Colors.ORANGE),
Arrow(v, color=Colors.PINK, linestyle=LineStyles.LOOSELY_DASHED),
Arrow(add(u, v), color=Colors.BLUE)
)
The functions in the vec2d.math library are self-explanatory. Vectors are represented and tuples with int or float components.
The vec2d.graph is a helper library for graphing related capabilities for 2D objects. With it you can draw simple figures such as points, segments, polygons, and arrows on the 2D plane using Matplotlib as the backend in a very simple way and without any hassle.
The library exposes classes for the figures, an enumeration for the common colors, and a function draw to render the figures as Matplotlib plots.
| Class | Constructor example | Description |
|---|---|---|
Polygon |
Polygon(*vectors) |
Draws a polygon whose vertices are represented by the given list of vectors. |
Points |
Points(*vectors) |
Represents a list of points (i.e., dots), one at each of the input vectors. |
Arrow |
Arrow(tip)Arrow(tip, tail) |
Draws an arrow from the origin to the tip vector, or from the tail vector to the tip vector if tail if given. |
Segment |
Segment(start, end) |
Draws a line segment from the start to the vector end. |
See Also
See also vec3d for a similar library for vectors in the 3D space.
Acknowledgements
This library is a small refactoring of https://github.com/orlandpm/Math-for-Programmers library.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vec2d-0.2.3.tar.gz.
File metadata
- Download URL: vec2d-0.2.3.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.8.10 Linux/5.15.133.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b775604a42b34ccd61c94709a5e446fd852e13bc46c53af44943e97bff458453
|
|
| MD5 |
20c323d28eb605d7714114a6c57417ba
|
|
| BLAKE2b-256 |
9f5d456faf6fb8cb1096bbb368dc52f7bbac7e1e6296f39ea81033d467bc6100
|
File details
Details for the file vec2d-0.2.3-py3-none-any.whl.
File metadata
- Download URL: vec2d-0.2.3-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.8.10 Linux/5.15.133.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f986c92bdd01a18a7ef65448eba98b45341867285d2fb7d64e77aa888cfc83c
|
|
| MD5 |
3f0ebc71c01b8ab3b4c470deff77cce5
|
|
| BLAKE2b-256 |
7a1b8772f230bd80f634f27eeb5c47a52d2ce61223fe3b7bbbe2d422a2d70f09
|