addRope関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Lays a rope of pieces links from (ax, ay) to (bx, by): the first node is pinned and the last is the node end if
one is given (its place is moved to the rope's end), and the nodes between are light. Gives back the indices of the
rope's nodes from the pinned end to the other and of its links.
インポート
import { addRope } from "@johnmorrisdotca/karakuri/physics";
定義
function addRope(rig: Rig, ax: number, ay: number, bx: number, by: number, pieces: number, end?: number): { nodes: number[]; links: number[]; }
引数
| 名前 | 型 | 説明 |
|---|---|---|
rig | Rig | The mutable native rope nodes, constraints and static geometry. |
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. |
pieces | number | The positive number of rope segments to create. |
end (省略可) | number | undefined | Optional existing native node index used as the rope’s far endpoint. |
戻り値
{ nodes: number[]; links: number[]; }
Lays a rope of pieces links from (ax, ay) to (bx, by): the first node is pinned and the last is the node end if one is given (its place is moved to the rope's end), and the nodes between are light. Gives back the indices of the rope's nodes from the pinned end to the other and of its links.
例
import { addRope, createRig, length } from "@johnmorrisdotca/karakuri/physics";
console.log(addRope(createRig({gravity:0}),0,0,10,0,2).links.length);2出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。