Skip to main content

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

u = (2, 0)
v = (1, 3)

draw(
    Arrow(u, color=Colors.ORANGE),
    Arrow(v, color=Colors.PINK),
    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.

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

vec2d-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vec2d-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file vec2d-0.1.0.tar.gz.

File metadata

  • Download URL: vec2d-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for vec2d-0.1.0.tar.gz
Algorithm Hash digest
SHA256 031ea82c748b280168f4b6ffa362582fba5b2acd97ab29710a7dc1d4bde617e3
MD5 eac19ffca6fd1652b36d890a5157e2ce
BLAKE2b-256 a972a1918387747d22467c738f4c79b8eca711b32a2738fe8c0f832779b0d5ea

See more details on using hashes here.

File details

Details for the file vec2d-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vec2d-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for vec2d-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f13d613f4b6f082138ce48626521949598826f46b12e141cda2fd3c044c019be
MD5 82418474f642a078fc0d512ef9f54714
BLAKE2b-256 e132e069fad9178da4b360ce6fbf0c6a984703ae2af7e8e1ba4a92c5dbcdaf47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page