Skip to main content

A collection of 2D utilities for coordinate representation and manipulation.

Project description

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()

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

bidimensional-1.9.1.tar.gz (51.5 kB view details)

Uploaded Source

Built Distribution

bidimensional-1.9.1-py3-none-any.whl (42.1 kB view details)

Uploaded Python 3

File details

Details for the file bidimensional-1.9.1.tar.gz.

File metadata

  • Download URL: bidimensional-1.9.1.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for bidimensional-1.9.1.tar.gz
Algorithm Hash digest
SHA256 b180c22c0afc1079ce0c56f1aa82763448b87e08ac3f9f8d806185f150f0dd56
MD5 5adaeb8c1d984bd1e61ccf97327b21d2
BLAKE2b-256 eac1e02d2d431b14725cd06c10ef025c263ead735852a6984dc26f49895dc9e4

See more details on using hashes here.

File details

Details for the file bidimensional-1.9.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bidimensional-1.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31d34e171e77affe8414e4d998d37709fd271e215246fc72443388729cee3cfd
MD5 f975493e251865536a33d5b449bbb626
BLAKE2b-256 b8a14c4f13e5823f2d46ffb67f45b445e82e8385dc989ce970ec9cd06966f762

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page