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

segmentsIntersectfunction

Whether the segments a1 to a2 and b1 to b2 cross or touch.

Import it

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

Definition

function segmentsIntersect(a1x: number, a1y: number, a2x: number, a2y: number, b1x: number, b1y: number, b2x: number, b2y: number): boolean

Parameters

NameTypeDescription
a1xnumber

The first segment’s starting horizontal coordinate.

a1ynumber

The first segment’s starting vertical coordinate.

a2xnumber

The first segment’s ending horizontal coordinate.

a2ynumber

The first segment’s ending vertical coordinate.

b1xnumber

The other segment’s starting horizontal coordinate.

b1ynumber

The other segment’s starting vertical coordinate.

b2xnumber

The other segment’s ending horizontal coordinate.

b2ynumber

The other segment’s ending vertical coordinate.

Returns

boolean

Whether the segments a1 to a2 and b1 to b2 cross or touch.

Examples

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

console.log(segmentsIntersect(0,0,10,10,0,10,10,0));
true

What it prints (run when this page was built)

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