Reference · Deterministic 2D physics
addLinkfunction
Links two nodes at their present distance (or at length) and gives back the link's index.
Import it
import { addLink } from "@johnmorrisdotca/karakuri/physics";
Definition
function addLink(rig: Rig, a: number, b: number, length_?: number): number
Parameters
| Name | Type | Description |
|---|---|---|
rig | Rig | The mutable native rope nodes, constraints and static geometry. |
a | number | The first body or native node index specified by the signature. |
b | number | The second body or native node index specified by the signature. |
length_ (optional) | number | undefined | Optional rest length; omitted uses the current distance between nodes. |
Returns
number
Links two nodes at their present distance (or at length) and gives back the link's index.
Examples
import { addLink, addRope, createRig } from "@johnmorrisdotca/karakuri/physics";
const rig=createRig({gravity:0,iterations:1});
addRope(rig,0,0,10,0,2);
console.log(addLink(rig,0,2));2What it prints (run when this page was built)