Reference · Framing, geometry and quiz tools
segmentCrossesBoxfunction
Whether a straight leader from a to b passes through this box.
Import it
import { segmentCrossesBox } from "@johnmorrisdotca/chizu";
Definition
function segmentCrossesBox(a: readonly [number, number], b: readonly [number, number], box: CalloutObstacle): boolean
Parameters
| Name | Type | Description |
|---|---|---|
a | readonly [number, number] | The first point or segment endpoint, in native map units. |
b | readonly [number, number] | The second point or segment endpoint, in native map units. |
box | CalloutObstacle | The window in native map units, or the inset destination specified by this signature. |
Returns
boolean
Whether a straight leader from a to b passes through this box.
Examples
import { segmentCrossesBox } from "@johnmorrisdotca/chizu";
const box = { minX: 10, minY: 10, maxX: 20, maxY: 20 };
console.log(segmentCrossesBox([0, 15], [30, 15], box), segmentCrossesBox([0, 0], [30, 0], box));
// true falsetrue falseWhat it prints (run when this page was built)