Skip to the content

Karakuriからくり

Play eight native puzzles, run bounded searches, step deterministic physics and mount a canvas player controlled by pointer or keyboard.

Karakuri is the Japanese word からくり for a mechanism or ingenious device. About the name

Contents

Reference · Deterministic 2D physics

distanceToSegmentfunction

How far (px, py) is from the segment a to b.

Import it

import { distanceToSegment } from "@johnmorrisdotca/karakuri/physics";

Definition

function distanceToSegment(px: number, py: number, ax: number, ay: number, bx: number, by: number): number

Parameters

NameTypeDescription
pxnumber

The horizontal coordinate of the point to test.

pynumber

The vertical coordinate of the point to test.

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.

Returns

number

How far (px, py) is from the segment a to b.

Examples

import { distanceToSegment } from "@johnmorrisdotca/karakuri/physics";

console.log(distanceToSegment(3,4,0,0,10,0));
4

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/karakuri 0.2.1.