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
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-0.1.0.tar.gz
(233.4 kB
view details)
File details
Details for the file gimpact-0.1.0.tar.gz
.
File metadata
- Download URL: gimpact-0.1.0.tar.gz
- Upload date:
- Size: 233.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d805af048e31a1d5d25a1429bb6496bc9b3e04aee518b4534310ef716b1e2ff |
|
MD5 | 42850c4f71b2ca766de545ebcd3ee536 |
|
BLAKE2b-256 | 05220f70875e8bd0886f0e724410c9f8c1e3fda432c01978263b1c9f14752d45 |