Reference · Framing, geometry and quiz tools
segmentMeetsRingfunction
Whether a straight line from one point to another passes over the land inside a ring.
Import it
import { segmentMeetsRing } from "@johnmorrisdotca/chizu";
Definition
function segmentMeetsRing(ax: number, ay: number, bx: number, by: number, ring: MapRing): boolean
Parameters
| Name | Type | Description |
|---|---|---|
ax | number | The first segment endpoint’s horizontal map coordinate. |
ay | number | The first segment endpoint’s vertical map coordinate. |
bx | number | The second segment endpoint’s horizontal map coordinate. |
by | number | The second segment endpoint’s vertical map coordinate. |
ring | MapRing | A closed outline ring in native map units. |
Returns
boolean
Whether a straight line from one point to another passes over the land inside a ring.
Examples
import { parseMapRings, segmentMeetsRing } from "@johnmorrisdotca/chizu";
const [square] = parseMapRings("M0,0L10,0L10,10L0,10Z");
console.log(segmentMeetsRing(-5, 5, 15, 5, square!), segmentMeetsRing(-5, 20, 15, 20, square!));
// true falsetrue falseWhat it prints (run when this page was built)