2D Geometry Library
Project description
2D Geometry Library in Python
This is a lightweight and simple library for handling 2D geometries using only Python's native libraries. It allows performing common geometric operations such as distance calculations, intersections, rotations, and other geometric transformations.
Main Features
- Point manipulation (
XYclass). - Creation and operations with lines (
Line). - Support for arcs (
Arc) and circles (Circle). - Bounding box generation (
BoundingBox). - Handling polylines (
Polyline) and rectangles (Rectangle). - Geometric utilities such as angle normalization, orthogonality checking, and shape intersections.
Installation
Install the library via pip:
pip install pygeometry2d
Then, import it into your project:
from pygeometry2d import XY, Line, Circle, Polyline
Usage Examples
Creating and Manipulating Points
p1 = XY(3, 4)
p2 = XY(6, 8)
distance = p1.distance(p2)
print(distance) # 5.0
Creating and Manipulating Lines
line = Line(XY(0, 0), XY(3, 4))
print(line.length) # Line length
Creating a Circle and Checking Intersections
circle = Circle(XY(0, 0), 10)
line = Line(XY(-10, 0), XY(10, 0))
intersections = circle.intersection(line)
print(intersections) # List of intersection points
Working with Polylines
polyline = Polyline([XY(0, 0), XY(3, 4), XY(6, 0)])
print(polyline.length) # Total polyline length
Documentation
Full documentation is available on readthedocs.
Contribution
If you would like to contribute with improvements or suggest new features, feel free to open a PR or create an issue on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygeometry2d-1.1.3.tar.gz.
File metadata
- Download URL: pygeometry2d-1.1.3.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b2a227913253580ec0e7bf5e6a0b96094678f4d4178efd6058b5b24e961a2a6
|
|
| MD5 |
f652de0f93ff41f694945912a0f07c62
|
|
| BLAKE2b-256 |
ed85fc91f94605c1ab427a5d032cff86f7cfae50312c4ea764594f1df61785b8
|
File details
Details for the file pygeometry2d-1.1.3-py3-none-any.whl.
File metadata
- Download URL: pygeometry2d-1.1.3-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6814daf7df7dfcd5dda7e434802c87a5cce9a7acb9a36a4cfd5bfe369dcb9558
|
|
| MD5 |
945729031dbfc5e71b588a14d026048b
|
|
| BLAKE2b-256 |
67b284d26e41c0f47ba5e85e453cb0f3738b6c6bdf4e17cf3da7b1d7815993a5
|