An unofficial python extension for the GImpact collision library.
Project description
GImpact-Python
An unofficial python extension for the GImpact collision library. This extension integrates directly with GImpact's C++ API using Cython.
Features
- Create trimesh object from numpy array
- Mesh decimation using Sven Forstmann's C++ mesh simplification code
- Axis Aligned Bounding Box (AABB)
- AABB set for box prunning
- Collision of triangle mesh with the following
- triangle mesh
- sphere
- capsule
- plane
- ray
- Supports "first contact" or "all contacts" modes
Build Wheel
pip install -q build
python -m build
Installation
Build requires numpy and cython (tested on Linux and Windows).
pip install gimpact
Example Usage
AABB
import gimpact
aabb1 = gimpact.AABB(-1, 1, -1, 1, -1, 1)
aabb2 = gimpact.AABB(-1, 1, -1, 1, 1.5, 2)
print(aabb1.intersects(aabb2))
print(aabb1.intersection(aabb2))
aabb1.merge(aabb2)
print(aabb1)
Box Prunning
import gimpact
aabb_set = gimpact.AABBSet(10)
print(len(aabb_set))
print(aabb_set.global_bounds)
for aabb in aabb_set:
aabb.bounds = (0., 0., 0., 0., 0., 0.)
for aabb in aabb_set:
print(aabb)
print(aabb_set.global_bounds)
pairs = aabb_set.find_intersections(aabb_set)
print(pairs)
del aabb_set
print(aabb.bounds)
Collision
import gimpact
import numpy as np
contacts = gimpact.trimesh_trimesh_collision(trimesh1, trimesh2)
contacts = gimpact.trimesh_sphere_collision(trimesh1, [0., 0., 0.], 1, True)
contacts = gimpact.trimesh_capsule_collision(trimesh1, np.array([0., 0., 0.]), np.array([1., 0., 0.]), 1, True)
contacts = gimpact.trimesh_plane_collision(trimesh1, [0., 0., 1., 0.], True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gimpact-1.0.0.tar.gz
(227.6 kB
view details)
Built Distributions
File details
Details for the file gimpact-1.0.0.tar.gz
.
File metadata
- Download URL: gimpact-1.0.0.tar.gz
- Upload date:
- Size: 227.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a988b63cce2519657494e9a10eeffc6001202d3967f9257f723675682ffac20 |
|
MD5 | b5897f123e7bd02a44d3db9ca2df5a31 |
|
BLAKE2b-256 | 176f4c7ddd338f378d6b663608f0e429220964d898ec8cf020ceb3c06df322fc |
File details
Details for the file gimpact-1.0.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: gimpact-1.0.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 136.7 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 812ad77a37c838ca1502fbc1304fb3babd75fe428c79222f9b950f1423e4ce64 |
|
MD5 | f3baa46f23106c866839ea841cfd5f8d |
|
BLAKE2b-256 | 56b9631d07e334ee34f5dff88d8f5a7a77eaf6d739b0e7793cc313349336ea18 |
File details
Details for the file gimpact-1.0.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: gimpact-1.0.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 136.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 769b884f5b6177564ae43056bbf2b5a102eac8b82ad43ee6294cfcd43a1e7efa |
|
MD5 | b88473fc036d497c5bbafc21651d32f4 |
|
BLAKE2b-256 | 1920e05c160d7a498926c8f062fc38ded290d4060b50bb285ca44cc438ef3a43 |