Reference · Deterministic 2D physics
capsulesAlongfunction
A capsule chain for a drawn line: one capsule between each pair of neighbouring points.
Import it
import { capsulesAlong } from "@johnmorrisdotca/karakuri/physics";
Definition
function capsulesAlong(points: readonly { x: number; y: number; }[], radius: number): CapsuleShape[]
Parameters
| Name | Type | Description |
|---|---|---|
points | readonly { x: number; y: number; }[] | Ordered native points forming a polyline. |
radius | number | The capsule radius in native world units. |
Returns
CapsuleShape[]
A capsule chain for a drawn line: one capsule between each pair of neighbouring points.
Examples
import { capsulesAlong } from "@johnmorrisdotca/karakuri/physics";
console.log(capsulesAlong([{x:0,y:0},{x:10,y:0}],2));[ { kind: 'capsule', ax: 0, ay: 0, bx: 10, by: 0, r: 2 } ]What it prints (run when this page was built)