Skip to content

trusty.contact

IPC contact configuration + builders.

ContactStencils

X property

X: ndarray[float64, (N, M)]

E property

E: ndarray[int32, (N, M)]

F property

F: ndarray[int32, (N, M)]

cand_ee property

cand_ee: ndarray[int32, (N, M)]

cand_fv property

cand_fv: ndarray[int32, (N, M)]

active_vv property

active_vv: ndarray[int32, (N, M)]

active_ev property

active_ev: ndarray[int32, (N, M)]

active_ee property

active_ee: ndarray[int32, (N, M)]

active_fv property

active_fv: ndarray[int32, (N, M)]

active_pv property

active_pv: ndarray[int32, (N,)]

ContactReport

n_surf_verts property

n_surf_verts: int

n_surf_edges property

n_surf_edges: int

n_surf_faces property

n_surf_faces: int

n_pt_broadphase property

n_pt_broadphase: int

n_ee_broadphase property

n_ee_broadphase: int

n_pv_broadphase property

n_pv_broadphase: int

n_vv_active property

n_vv_active: int

n_ev_active property

n_ev_active: int

n_ee_active property

n_ee_active: int

n_fv_active property

n_fv_active: int

n_pv_active property

n_pv_active: int

barrier_energy property

barrier_energy: float

min_distance property

min_distance: float

Smallest barrier clearance (m) over the active stencils: unsigned distance minus the pair's contact-offset sum. +inf when none is active.

stencils property

stencils: ContactStencils

StepSizeReport

alpha_pv property

alpha_pv: float

alpha_min property

alpha_min: float

ContactObserver

wants_stencils

wants_stencils() -> bool

on_prepare

on_prepare(report: ContactReport) -> None

on_step_size

on_step_size(report: StepSizeReport) -> None

BroadphaseKind

Bases: Enum

FlatQbvh class-attribute instance-attribute

FlatQbvh = 0

TwoLevel class-attribute instance-attribute

TwoLevel = 1

AffineRelative class-attribute instance-attribute

AffineRelative = 2

Config

dhat property writable

dhat: float

kappa property writable

kappa: float

epsv property writable

epsv: float

project_positive_definite property writable

project_positive_definite: bool

prune_ccd_by_rigid_motion property writable

prune_ccd_by_rigid_motion: bool

broadphase property writable

broadphase: BroadphaseKind

MeshBvh

closest_points

closest_points(
    P: ndarray[float64, (N, 3)],
) -> tuple[
    ndarray[float64, (N,)],
    ndarray[int32, (N,)],
    ndarray[float64, (N, 3)],
]

Unsigned closest point on the mesh for each query row of P. Returns (sqrD, face, closest): squared distance, closest triangle index, and closest-point coordinates -- parallel over P, matching igl.point_mesh_squared_distance.

enable

enable(
    world: World,
    config: Config = ...,
    *,
    observer: ContactObserver | None = None,
) -> None

Run IPC contact on this world, with config as its settings. Contact is the one module nothing in the world activates -- every body publishes a boundary surface whether or not it should collide -- so this call is that intent. observer is an optional ContactObserver debug hook the IPC term reports to; keep a reference to a Python subclass alive for the simulation. Calling it again replaces the settings and the observer. Call before the first step().

add_plane

add_plane(
    world: World,
    origin: ndarray[float64, (3,)],
    normal: ndarray[float64, (3,)],
    *,
    friction_mu: float = 0.0,
) -> int

Add an infinite contact plane (a half-space through origin with outward normal) as a new world entity, which is returned. friction_mu is the plane's Coulomb coefficient (>= 0); 0 (the default) is frictionless. A contact uses the average of the plane's and the body's coefficients. Point-plane friction is CPU/Accelerate only. Requires trusty.contact.enable(world).

add_wall

add_wall(
    world: World,
    name: str,
    V: ndarray[float64, (N, M)],
    F: ndarray[int32, (N, M)],
    *,
    friction_mu: float = 0.0,
) -> int

Add a static triangle-mesh collider (V (N, 3) vertices, F (M, 3) triangles) as a new world entity, which is returned. IPC contact and mpm.attach_wall_noslip both treat it as a fixed surface. friction_mu is the wall's Coulomb coefficient (>= 0); 0 (the default) is frictionless. Requires trusty.contact.enable(world), or MPM particles with mpm.attach_wall_noslip.

exclude_body_pair

exclude_body_pair(
    world: World, body_a: int, body_b: int
) -> None

Bar all contact between body_a and body_b (whole-body, both directions). The exclusion dies with body_a. Call before the first step. Raises ValueError if body_a and body_b are the same body; use set_self_contact to stop a body colliding with itself.

set_self_contact

set_self_contact(
    world: World, body: int, enabled: bool
) -> None

Turn body's contact with itself on or off, for any body type. Every body self-collides by default except affine bodies, which start with it off. Contact with other bodies is unaffected. The setting lives on the body and dies with it. Call before the first step.

exclude_body_from_contact

exclude_body_from_contact(world: World, body: int) -> None

Exclude body from contact entirely (it collides with nothing, planes included): the IPC builder drops its surface, so the geometry never enters the broadphase. Cheaper than pairing it against every other body. Contact policy only -- the surface stays in the neutral surface registry, so surface loads on this body still work. Call before the first world.step().

set_body_friction

set_body_friction(
    world: World, body: int, friction_mu: float
) -> None

Override the Coulomb friction coefficient for all contact touching body (a collision uses the average of the two bodies' coefficients), overwriting what add_*(..., friction_mu=) set. Applies to mesh-vs-mesh and point-plane contact; a plane carries its own (add_plane). Call before the first world.step(); a later call raises on the next step. Raises if a positive friction_mu is given for a body with no contact surface.