Skip to main content

PolygonCollision is a Python module designed for efficient collision detection between 2D polygons. Using the Separating Axis Theorem (SAT), this library enables precise detection of intersections between polygons, making it an essential tool for game developers, simulations, and applications requiring accurate collision detection between shapes.

Features:

Polygon Collision Detection: Determine whether two 2D polygons overlap with accurate collision detection algorithms. Customizable Shapes: Define custom 2D shapes by specifying their vertices as Vector objects. Calculate verlocity: Calculate the verlocity between two different shapes. Efficient Algorithm: Implementing the Separating Axis Theorem (SAT) ensures fast and reliable collision detection for complex polygons.

How It Works:

The library checks for collisions by projecting the shapes onto various axes and checking if the projections overlap. If there is no axis along which the projections of the two shapes do not overlap, they are colliding.

Code Examples:

import PolygonCollision

#Create Squares
polygon1 = PolygonCollision.shape.Shape(vertices = [(0, 0), (0, 10), (10, 10), (10, 0)])
polygon2 = PolygonCollision.shape.Shape(vertices = [(5, 5), (5, 15), (15, 15), (15, 5)], fill=False)

#Create Circle
circle = PolygonCollision.shape.Shape(vertices = [(30, 30)], radius = 5)

#Output The Size And Posiotion Of The Shapes
print('polygon1:', polygon1.get_width(), polygon1.get_height())

#Check For Polygons Collision
if polygon1.collide(polygon2):
    print('POLYGON COLLISION!!!')
else:
    print('no polygon colllision')

#Check For Polygons + Circle Collision
if polygon1.collide(polygon2):
    print('CIRCLE COLLISION!!!')
else:
    print('no circle colllision')

Output

POLYGON COLLISION!!!
no circle collision

License:

This Collision Detection Library is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for PolygonCollision 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PolygonCollision 0.0.6
File Size Uploaded Provenance Actions
PolygonCollision-0.0.6.tar.gz 4.0 kB Without provenance Details for PolygonCollision-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PolygonCollision 0.0.6
File Interpreter ABI Platform Actions
PolygonCollision-0.0.6-py3-none-any.whl Python 3 none any Details for PolygonCollision-0.0.6-py3-none-any.whl

Total release size: 8.7 kB

Release files / PolygonCollision-0.0.6.tar.gz

Download URL PolygonCollision-0.0.6.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4645f577508b47810755ccf5e502a6556ffbcd4080e4166e37d1d5cb0d6d3d2c
BLAKE2b-256 checksum
How to use checksums
ba2dc0f77bb8b080c90a9a6f4bedf71bfd66590934d99e60bfa376d141c96285
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release files / PolygonCollision-0.0.6-py3-none-any.whl

Download URL PolygonCollision-0.0.6-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
131d005b49bfb9812b8a626347dea76aa90de7b57abbb97d6d187cccbb016b18
BLAKE2b-256 checksum
How to use checksums
5f3757c1ee9b28f211e21ff3fdb097ddf61ff4def559c15e5fcab3b8a32d70c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Security for PolygonCollision 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page