pointInPolygon関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Whether (px, py) is inside the polygon (an even-odd test over its vertices, in order).
インポート
import { pointInPolygon } from "@johnmorrisdotca/karakuri/physics";
定義
function pointInPolygon(px: number, py: number, polygon: readonly Vec[]): boolean
引数
| 名前 | 型 | 説明 |
|---|---|---|
px | number | The horizontal coordinate of the point to test. |
py | number | The vertical coordinate of the point to test. |
polygon | readonly Vec[] | The polygon’s native vertices, in outline order. |
戻り値
boolean
Whether (px, py) is inside the polygon (an even-odd test over its vertices, in order).
例
import { pointInPolygon } from "@johnmorrisdotca/karakuri/physics";
console.log(pointInPolygon(2,2,[{x:0,y:0},{x:5,y:0},{x:5,y:5},{x:0,y:5}]));true出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。