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.0.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.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vec2d-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e721b26da652070b2c3b0059198a1a8dee58013ff003cfb47716582466d9577d
MD5 982bd03a4f0430afe22e35b5552ed944
BLAKE2b-256 6434fa3c8a15c27d9c45ae6e9e3e85df8aa8dc1d0d9d7efd3ccf1f6a50c9f760

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vec2d-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15dbca04689ec6c53610601a181e12e9aa6c7fd63f5a87ce8fd45076c17ced99
MD5 b987a11f532b32770a93bfd12dc4af23
BLAKE2b-256 fe57b73acb7149de9404b70608af5245430072ab39bd7794b7363612ae0190b0

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