Paclet Resource

ArnoudBuzing/PhysicsModelLink

Rigid body physics simulation and visualization for standard Wolfram Language 3D primitives

Contributed By: Arnoud Buzing

PhysicsModelLink provides a high-level interface for creating and simulating rigid body physics in the Wolfram Language. It lets you wrap standard 3D graphics primitives—such as spheres, cuboids, cylinders, cones, and capsules—as dynamic or fixed bodies, run time-stepped physics simulations with gravity and collisions, and visualize or animate the results as Graphics3D scenes.

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall[ResourceObject["https://wolfr.am/1DvZZLuE7"]]


To load the code after installation, evaluate this code:
Needs["ArnoudBuzing`PhysicsModelLink`"]

Details

PhysicsModelLink provides rigid body physics simulation for standard Wolfram Language 3D graphics primitives including Sphere, Cuboid, Cylinder, Cone, and CapsuleShape.
The underlying physics engine is the Rapier 3D physics library (Rust crate rapier3d), accessed via LibraryLink.
Simulations are stateful: CreatePhysicsModel allocates a persistent physics world in memory, and DestroyPhysicsModel frees it. Each world is identified by a unique integer handle.
Bodies are classified as either DynamicBody (affected by gravity and collisions) or FixedBody (immovable obstacles/floors).
Each body has physical material properties that can be set via options: "Density" (default 1.0), "Restitution" (bounciness, default 0.5), and "Friction" (default 0.5).
Initial velocities can be assigned to dynamic bodies using the "Velocity" option.
Body orientations are tracked internally as quaternions and converted to/from 3×3 rotation matrices for compatibility with GeometricTransformation.
Time evolution is performed with PhysicsModelIterate, which steps the simulation by a given number of substeps at a fixed time increment dt. Smaller dt values yield more accurate results.
PhysicsModelEvolve is a convenience function that collects a sequence of PhysicsModelObject frames for animation.
PhysicsModelPlot renders the current state as a Graphics3D scene, automatically applying positions and rotations returned by the engine.
PhysicsBoundaryBox generates six invisible FixedBody walls to confine objects within a bounding region.
PhysicsModelVideo produces an AnimationVideo from a list of simulation frames.
The Rapier library is compiled as a platform-specific shared library (.dylib on macOS,.so on Linux,.dll on Windows) and loaded from the paclet's LibraryResources/$SystemID/ directory at package initialization.

Paclet Guide

Examples

Disclosures

  • Portions of the paclet code were interactively generated with the help of LLMs.

Paclet Source