Giter Club home page Giter Club logo

vec2d's Introduction

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.

vec2d's People

Contributors

sergiofgonzalez avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.