本文へ移動

Karakuriからくり

8つの標準のパズルで遊び、探索や再現できる物理を使い、ポインターやキーボードで操作する盤を表示できます。

「からくり」は、仕組みや工夫した装置を表す言葉です。 名前について(英語)

目次

リファレンス · 再現できる2D物理

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[]; }

引数

名前型説明
rigRig

The mutable native rope nodes, constraints and static geometry.

axnumber

The first segment endpoint’s horizontal coordinate.

aynumber

The first segment endpoint’s vertical coordinate.

bxnumber

The second segment endpoint’s horizontal coordinate.

bynumber

The second segment endpoint’s vertical coordinate.

piecesnumber

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/karakuri 0.2.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。