Reference · Deterministic 2D physics
contactsBetweenfunction
The contacts between two bodies whose shapes are within margin of each other.
Import it
import { contactsBetween } from "@johnmorrisdotca/karakuri/physics";
Definition
function contactsBetween(a: Body, b: Body, margin: number): Contact[]
Parameters
| Name | Type | Description |
|---|---|---|
a | Body | The first body or native node index specified by the signature. |
b | Body | The second body or native node index specified by the signature. |
margin | number | The native contact distance within which shapes are tested. |
Returns
Contact[]
The contacts between two bodies whose shapes are within margin of each other.
Examples
import type { BodySpec } from "@johnmorrisdotca/karakuri/physics";
import { contactsBetween, createBody, length } from "@johnmorrisdotca/karakuri/physics";
const spec: BodySpec={id:"ball",shapes:[{kind:"circle",x:0,y:0,r:3}],x:0,y:0};
const body=createBody(spec);
const other=createBody({...spec,id:"other",x:4});
console.log(contactsBetween(body,other,0).length);1What it prints (run when this page was built)