closestOnSegment関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The point on the segment a to b nearest to (px, py), and how far along the segment it is (0 to 1).
インポート
import { closestOnSegment } from "@johnmorrisdotca/karakuri/physics";
定義
function closestOnSegment(px: number, py: number, ax: number, ay: number, bx: number, by: number): { x: number; y: number; t: number; }
引数
| 名前 | 型 | 説明 |
|---|---|---|
px | number | The horizontal coordinate of the point to test. |
py | number | The vertical coordinate of the point to test. |
ax | number | The first segment endpoint’s horizontal coordinate. |
ay | number | The first segment endpoint’s vertical coordinate. |
bx | number | The second segment endpoint’s horizontal coordinate. |
by | number | The second segment endpoint’s vertical coordinate. |
戻り値
{ x: number; y: number; t: number; }
The point on the segment a to b nearest to (px, py), and how far along the segment it is (0 to 1).
例
import { closestOnSegment } from "@johnmorrisdotca/karakuri/physics";
console.log(closestOnSegment(3,4,0,0,10,0));{ x: 3, y: 0, t: 0.3 }出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。