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, 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

vec2d-0.2.1.tar.gz (9.4 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.2.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for vec2d-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6a32fdd95f0d73f26bd7a7da598c5ec58eafa645e505c11582e4540f0860430e
MD5 a24c7ed4773c52049184eed2202fff65
BLAKE2b-256 49fc2d4fee4af3ad18a91006a02b0ef2cee60a8300578246d2f69d14c7c68bb2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vec2d-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26056f91349d17b3b4968b8f4cd95e6445e5d91d11b8c959b205949686d3d15b
MD5 2cc54837c1e479f7d73a9f313b8e1cb3
BLAKE2b-256 ea6c99cae5d2cc9bd78b3a87c00ab2414f56108ed3c7397f0c2c39647c9d7b9a

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