#### <sup>[Ollin](../../index.md) → [Examples](../index.md) → Physics</sup>

---

## Physics

| [![Blobs](https://media.ollin.art/examples/Physics/Blobs/still-640.jpg?v=020a9332)](blobs.md) | [![Burst](https://media.ollin.art/examples/Physics/Burst/still-640.jpg?v=081188b1)](burst.md) | [![Chain](https://media.ollin.art/examples/Physics/Chain/still-640.jpg?v=b17eb398)](chain.md) | [![Forces](https://media.ollin.art/examples/Physics/Forces/still-640.jpg?v=2509854b)](forces.md) |
|---|---|---|---|
| [Blobs](blobs.md) | [Burst](burst.md) | [Chain](chain.md) | [Forces](forces.md) |
| [![Joints](https://media.ollin.art/examples/Physics/Joints/still-640.jpg?v=cc45914b)](joints.md) | [![Packing](https://media.ollin.art/examples/Physics/Packing/still-640.jpg?v=abdd0bbc)](packing.md) | [![RigidBodies](https://media.ollin.art/examples/Physics/RigidBodies/still-640.jpg?v=dada2a72)](rigidbodies.md) |  |
| [Joints](joints.md) | [Packing](packing.md) | [RigidBodies](rigidbodies.md) |  |

These sketches get their motion from simulation. Physics lives in a separate library, so add `import OllinPhysics`. The library is built around one `World` with two sides. The **soft** side is a Verlet simulation of particles and the springs between them. The **rigid** side holds bodies, colliders, and joints. Both sides share the world's gravity, container, bounce, and drag. Build the world in `setup()`, `step` it each frame, and draw from its particles and bodies. See the [Physics reference](../../docs/simulation/physics.md). These examples use the 2D world. For rigid bodies inside the 3D scene, see the [3D physics examples](../3d/index.md#physics). The 3D group keeps the same scenarios on the 3D engine under their own names: [`3D/Physics/Stack`](../3d/physics/stack.md), [`Tumble`](../3d/physics/tumble.md), and [`Chain`](../3d/physics/chain.md). Here the first two are folded into the one `RigidBodies` sketch below.

| Example | What it shows |
|---|---|
| [Packing](packing.md) | 256 discs of mixed sizes drift with no gravity and bounce off the walls and each other. Each disc is drawn as a slowly spinning crosshair token, and the spin reacts to the disc's own speed. This is the main example for `World.particlesCollide`, a pairwise disk-collision pass. Gravity is off and `drag = 0`, so the motion never slows down (`World`, `Particle`, `collisions`). The scene composition follows @eaviles's sketch 2025.037. The physics is Ollin's own. |
| [Blobs](blobs.md) | Nine lumpy blobs in a box, each one `addSoftBody(from:)` call on a circle bent by looping noise. Gravity swings slowly from side to side, so the pile sloshes across the floor: the blobs squash against the walls and each other, keep their area, and spring back toward their own shapes. Move the mouse through them to shove them. Each is drawn as a smooth filled `drawCurve` through its own particles. This is the soft-body example (`addSoftBody`, `SoftBody`, `shapeMemory`). |
| [RigidBodies](rigidbodies.md) | A pyramid of rigid crates stacks, leans, and topples. Beside it, a rain of assorted shapes (boxes, disks, capsules, and random convex polygons) piles up against the floor. A click fires a heavy ball that knocks the stack into the heap, and space clears and rebuilds the scene. This is the rigid-body example. It shows orientation and resting contact, which the particle side cannot do. Every shape is one `addBody` call with a different `Collider`, and each is drawn straight from its `position` and `angle` (`addBody`, `Collider`, `Body`). |
| [Chain](chain.md) | Hanging chains of capsule links, hinged by free-swinging revolute joints and ending in heavy balls. Click a link to grab and fling it through a cursor-drag mouse joint, click again to let go, and press space to reset. This is the joints example (`connect`, `JointKind.revolute`, `grab`). |
| [Joints](joints.md) | All four joint kinds side by side, each as one labeled rig hung from a static anchor: a revolute pendulum, a distance ball on a springy rope, a weld tee that swings as one rigid piece, and a prismatic slider that can only travel along its rail. Click a piece to grab and fling it, and press space to reset (`JointKind`, `Body.kind = .static`). |
| [Forces](forces.md) | The force API in one windy yard. A gust pushes on every loose shape through `applyForce`, so the leaves scatter while the crates only shuffle. A click kicks the nearest shape with `applyImpulse`. A paddle spun by `applyTorque` hits whatever drifts through it, and a kinematic sweeper pushes along the floor, which nothing can stop. A pinned lattice colors its springs by `Spring.strain`, and `World.unitsPerMeter` is bound to a parameter (`applyForce`, `applyImpulse`, `applyTorque`, `Spring.pin()`). |
| [Burst](burst.md) | Fruit thrown up through the frame, each one breaking at the top of its arc into pieces that tumble back down. Nobody cuts them: a shape lets go on its own, and what falls is exactly what went up. A click breaks the nearest one early, and space clears the frame. Shows `Shape.fractured` around the point where it gave way, each piece's `centroid` becoming a body of its own (`fractured`, `centroid`, `addBody`, `World.remove`). |

Run one with `swift run Example-Physics-<Name>`, for example `swift run Example-Physics-Packing`.
