Collision Functions

gimpact.trimesh_trimesh_collision()

Determines contacts of a trimesh-trimesh collision.

Parameters:
  • trimesh1 (Trimesh) – first triangle mesh
  • trimesh2 (Trimesh) – second triangle mesh
  • first_only (bool) – flag that indicates only first contact is required
Returns:

a list of Contacts

Return type:

List[Contact]

gimpact.trimesh_sphere_collision()

Determines contacts of a trimesh-sphere collision

Parameters:
  • trimesh (Trimesh) – triangle mesh
  • center (Array[float]) – center of the sphere
  • radius (float) – radius of the sphere
  • first_only (bool) – flag that indicates only first contact is required
Returns:

a list of Contacts

Return type:

List[Contact]

gimpact.trimesh_capsule_collision()

Determines contacts of a trimesh-capsule collision.

Parameters:
  • trimesh (Trimesh) – triangle mesh
  • point1 (Array[float]) – first end-point of the capsule
  • point2 (Array[float]) – second end-point of the capsule
  • radius (float) – radius of the sphere
  • first_only (bool) – flag that indicates only first contact is required
Returns:

a list of Contacts

Return type:

List[Contact]

gimpact.trimesh_plane_collision()

Determines contacts of a trimesh-plane collision.

Parameters:
  • trimesh (Trimesh) – triangle mesh
  • plane (Array[float]) – plane parameters (a, b, c, d) in form of ax + by + cz + d = 0
  • first_only (bool) – flag that indicates only first contact is required
Returns:

a list of tuples containing point and penetration depth

Return type:

List[Tuple[Array[float], float]]

gimpact.trimesh_ray_collision()

Determines contact of a trimesh-ray collision. Collision is considered valid only when the ray collides with the front faces of the trimesh

Parameters:
  • trimesh (Trimesh) – triangle mesh
  • origin (Array[float]) – origin point of ray
  • direction (Array[float]) – direction vector of ray
  • tmax (float) – max distance param for ray.
Returns:

random contact if ray collides else None

Return type:

Union[Contact, None]

gimpact.trimesh_ray_closest_collision()

Determines closest contact of a trimesh-ray collision. Collision is considered valid only when the ray collides with the front faces of the trimesh

Parameters:
  • trimesh (Trimesh) – triangle mesh
  • origin (Array[float]) – origin point of ray
  • direction (Array[float]) – direction vector of ray
  • tmax (float) – max distance param for ray.
Returns:

closest contact if ray collides else None

Return type:

Union[Contact, None]