Giter Club home page Giter Club logo

bidimensional's Introduction

Bidimensional

PyPI release Python Test Execution

This package contains a collection of useful classes and functions for working with 2D geometry in Python.

Objectives and contributions

This package has three fundamental bases:

  • Simplicity - The package is designed to be simple and easy to use, with a minimalistic approach to the implementation of its features.
  • Rich documentation - The package is fully documented, with a detailed description of its features and their usage.
  • Performance - The package is designed to be as fast as possible, mainly using simple algebraic operations instead of complex calculations.

Any contribution is welcome as long as it follows the objectives of the package. For more information, refer to the contributing guidelines.

Features

The following features are currently implemented:

  • Coordinate - A class for representing a 2D coordinate. It can be used to represent a point in the plane, or a vector from the origin. It provides with multiple access methods, as well as a set of useful methods for performing operations with other coordinates.
  • polygons.Triangle - A class for representing a triangle in the plane. Contains several methods that can be used to compute its area, perimeter and relevant centers, as well as determining relevant properties of triangles (e.g. if they are equilateral, isosceles, etc.).
  • functions.Spline - A class for representing a spline function. It can be used to interpolate a set of points in the plane and to compute the value of the function at any given point in between.
  • operations - A module that contains relevant functions for performing operations with coordinates and triangles. It provides with functions for computing the distance between two points, the area of a triangle, the midpoint of a segment, etc.

Installation

The installation process is performed via PyPI (Python Package Index), so the package can be installed using the pip command.

pip install bidimensional

Refer to the PyPI release for more information about how to install the package in your system.

Usage

Once the package has been installed, its modules can be easily imported into custom programs via the import statement.

Examples

Composition of a small triangle out of the midpoints of the sides of a larger triangle, computation of the circumcircle of the inner triangle and figure plotting.

import bidimensional.operations as op
import matplotlib.pyplot as plt

from bidimensional import Coordinate
from bidimensional.polygons import Triangle


outer_triangle = Triangle(
    Coordinate(0, 0),
    Coordinate(1, 0),
    Coordinate(0, 1)
)

inner_triangle = Triangle(
    op.midpoint(outer_triangle.a, outer_triangle.b),
    op.midpoint(outer_triangle.b, outer_triangle.c),
    op.midpoint(outer_triangle.c, outer_triangle.a)
)

outer_triangle.plot(color="darkorange", lw=2)
inner_triangle.plot()

plt.gca().add_patch(plt.Circle(
    inner_triangle.circumcenter,
    inner_triangle.circumradius,
    color="darkblue",
    fill=False,
    lw=2
))

plt.axis("equal")
plt.grid()
plt.show()

bidimensional's People

Contributors

erlete avatar

Stargazers

 avatar  avatar  avatar

bidimensional's Issues

Incorrect operations

Some magic methods of the Coordinate2D class such as mul, truediv, pow (...) do not represent valid vector operations.

This is a copy of #1 performed in order to generate an automatic branch based on this issue.

Polygon classes

This module should implement polygon classes, such as Triangle, Square, Pentagon... with specific properties and methods.

For example, the Triangle class could feature methods such as is_equilateral, is_scalene and so on.

Rectangle class implementation

Rectangle class implementation with triangle decomposition and rectangle properties, such as:

  • Area
  • Perimeter
  • Diagonal

It would also be interesting to determine whether or not the rectangle is a square.

Furthermore, the circumcircle of the rectangle could also be computed as the common center of the circumcircles of the triangles that compose it.

Incorrect operations

Some magic methods of the Coordinate2D class such as __mul__, __truediv__, __pow__ (...) do not represent valid vector operations.

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.