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.

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.1.1.tar.gz (9.0 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.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vec2d-0.1.1.tar.gz
  • Upload date:
  • Size: 9.0 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.1.tar.gz
Algorithm Hash digest
SHA256 47f5b532560ed6edb9f84f8a9e3995fd8db657d63baaa2c781919db168651c6c
MD5 a142892b901791ceb1f9629607153671
BLAKE2b-256 28fea670b1affcbbfef546dcc486c2aa978d8c0d33fe591bce8e6724aa680ef3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vec2d-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fecb5016bd72742ec327bca6ac6de6e5d1ccf1ca4603c9a36ef8c09e3465f9a2
MD5 dc414192de1320ee5bb58535a1e16f77
BLAKE2b-256 5f66aa348f0ea5936a452f8d840859f5feb2c38ff1812a1bb110ff3197534086

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