Expand description
phyz — Multi-physics differentiable simulation engine.
This crate is a thin umbrella over the rigid-body stack: every type and
function below lives in one of the focused phyz-* crates and is
re-exported here, so cargo add phyz gives you that stack behind a single
dependency. The re-exported modules are aliases, not copies, so a fix in
phyz-collision is a fix for phyz::collision by construction. sim is
the one module with code of its own: the time loop, which none of the
focused crates own.
It does not cover the whole workspace. phyz-gpu, phyz-particle,
phyz-lbm, phyz-em, phyz-md and the rest are separate crates you add
explicitly.
§Features
collision(default) — GJK/EPA narrow phase and broad-phase spatial hashing.contact(default) — soft/penalty contact dynamics; impliescollision.diff(default) — per-step Jacobians and the trajectory adjoint. Only the adjoint (diff::adjoint_rollout_gradient) and the symbolic path are derivative-exact; seephyz_difffor which is which.
math, model, and rigid are always present.
Re-exports§
pub use sim::Rk4Solver;pub use sim::SemiImplicitEulerSolver;pub use sim::Simulator;pub use sim::Solver;pub use phyz_math;pub use phyz_model;pub use phyz_rigid;pub use phyz_math as math;pub use phyz_model as model;pub use phyz_rigid as rigid;pub use phyz_collision;pub use phyz_collision as collision;pub use phyz_contact;pub use phyz_contact as contact;pub use phyz_diff;
Modules§
- aba
- Articulated Body Algorithm (ABA) – O(n) forward dynamics.
- crba
- Composite Rigid Body Algorithm (CRBA) – mass matrix computation.
- determinism
- Tools for checking that a rollout reproduces, and for telling chaos from bugs when it does not.
- diff
- Differentiation: Jacobians of the dynamics and the trajectory adjoint.
- rnea
- Recursive Newton-Euler Algorithm (RNEA) — inverse dynamics.
- sim
- Integrated time stepping: the
Simulatordriver and its solvers.
Structs§
- AABB
- Axis-aligned bounding box.
- Actuator
- An actuator attached to a joint.
- Body
- A rigid body in the kinematic tree.
- Body
Kinematics - Body transforms, velocities, and accelerations from a full kinematics pass.
- Collision
- Result of a collision query between two geometries.
- Contact
Material - Material properties for contact interactions.
- Contact
Problem - The assembled convex contact problem.
- Contact
Solver Config - Tuning for the contact solve.
- Geom
Instance - A geometry placed at an offset within a body frame.
- IkConfig
- Solver settings.
IkConfig::defaultis tuned for robot-arm-sized problems: metres and radians, goals within reach, a seed that is not exactly at a singularity. - IkGoal
- A single kinematic goal.
- IkSolution
- What
solve_ikfound. - Joint
- A joint connecting two bodies.
- Model
- Static model describing the topology and parameters of a physical system.
- Model
Builder - Builder for constructing models.
- Ray
- A ray with a normalized direction.
- RayHit
- A ray/shape intersection.
- State
- Mutable simulation state.
Enums§
- Geometry
- Collision geometry types (mirrors
phyz-collision’s shapes for convenience). - IkGoal
Kind - The two things a goal can ask for.
- Joint
Type - Joint type enumeration.
Constants§
Functions§
- aba
- Run the Articulated Body Algorithm.
- aba_
with_ external_ forces - Run ABA with optional external spatial forces applied to each body.
- body_
wrenches - Net spatial wrench transmitted through each body’s joint.
- crba
- Compute the joint-space mass matrix M(q) using CRBA.
- epa_
penetration - Compute penetration depth and contact normal using EPA.
- epa_
penetration_ rot - EPA with rotation matrices. Runs GJK to obtain a valid seed simplex.
- find_
contacts - Find all body-body contacts in the current state.
- find_
ground_ contacts - Find contacts against a horizontal ground plane at
z = ground_height. - forward_
kinematics - Compute forward kinematics: body transforms and spatial velocities.
- forward_
kinematics_ acc - Forward kinematics extended with accelerations, for a given
qdd. - gjk_
distance - Compute signed distance between two geometries.
- gjk_
distance_ rot - Signed distance with rotation matrices:
+separationwhen disjoint,-depthwhen overlapping. - ray_
cast - Cast a ray against many placed geometries, returning the nearest hit within
max_distancealong with the index of the geometry that was hit. - ray_
intersect - Intersect a ray with a geometry placed at
poswith orientationrot. - rnea
- Run RNEA: compute inverse dynamics torques.
- skew
- Cross-product matrix [v]× such that [v]× w = v × w
- solve_
contacts - Solve the convex contact problem from a cold start (zero impulses).
- solve_
ik - Solve for a configuration satisfying
goals, starting fromseed. - sweep_
and_ prune - Sweep-and-prune broad phase collision detection.
Type Aliases§
- DMat
- Dynamic matrix.
- DVec
- Dynamic vector.
- Mat3
- 3x3 matrix alias.
- Mat4
- 4x4 matrix alias.
- Quat
- Unit quaternion for 3D rotations (scalar
w, vectorv). - Spatial
Inertia - Spatial inertia of a rigid body about its center of mass.
- Spatial
Mat - 6x6 spatial matrix stored as four 3x3 blocks.
- Spatial
Transform - Plucker transform: rigid body transformation acting on spatial vectors.
- Spatial
Vec - 6D spatial vector – either a motion vector (twist) or force vector (wrench).
- Vec3
- 3D vector alias.