phyz-collision 0.4.0

GJK/EPA collision detection, ray casting, and broad-phase spatial hashing for phyz
Documentation
  • Coverage
  • 100%
    75 out of 75 items documented0 out of 28 items with examples
  • Size
  • Source code size: 112.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.0 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 24s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ecto/phyz
    27 3 6
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ecto

phyz-collision

GJK/EPA collision detection for phyz.

Narrow-phase distance and penetration between convex shapes, plus a sweep-and-prune broad phase.

Function Purpose
gjk_distance, gjk_distance_rot separating distance between disjoint convex shapes
epa_penetration, epa_penetration_rot penetration depth and normal when they overlap
sweep_and_prune broad-phase AABB pair pruning

Shapes are described by Geometry (Sphere, Capsule, Box, Cylinder, Mesh, Plane) and bounded by AABB. Results come back as Collision records that phyz-contact turns into forces.

Example

use phyz_collision::{AABB, Geometry, gjk_distance, sweep_and_prune};
use phyz_math::Vec3;

let a = Geometry::Sphere { radius: 0.5 };
let b = Geometry::Sphere { radius: 0.5 };

let d = gjk_distance(&a, &b, &Vec3::zeros(), &Vec3::new(2.0, 0.0, 0.0));

// Broad phase over a set of AABBs.
let boxes = vec![
    AABB::new(Vec3::new(-1.0, -1.0, -1.0), Vec3::new(0.0, 0.0, 0.0)),
    AABB::new(Vec3::new(-0.5, -0.5, -0.5), Vec3::new(0.5, 0.5, 0.5)),
];
let pairs = sweep_and_prune(&boxes);

Part of phyz

phyz is an open-source differentiable multi-physics simulation workspace in pure Rust. Each crate is independent — adding this one does not pull in the rest.

Licensed under MIT.