本文へ移動

Meikyuu迷宮

シード付きの迷路と矢印パズルを作り、番号付きの問題を進め、平面や立体表面で遊べます。

「迷宮」は迷路のように入り組んだ場所を表す言葉です。 名前について(英語)

目次

リファレンス · 立体表面の規則と形

SolidGrid型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A surface cell graph, neighbouring faces, vertices, projected centres and shape geometry.

インポート

import type { SolidGrid } from "@johnmorrisdotca/meikyuu/3d";

定義

type SolidGrid = {
    readonly kind: SolidKind;
    readonly n: number;
    readonly shape: SolidKind;
    readonly w: number;
    readonly h: number;
    readonly cells: number;
    readonly neighbours: readonly (readonly number[])[];
    readonly corners: readonly (readonly number[])[];
    readonly vertices: readonly Vec3[];
    readonly centres: readonly Vec3[];
    readonly normals: readonly Vec3[];
    readonly radii: readonly number[];
    readonly faceOf: readonly number[];
    readonly edges: readonly SolidEdge[];
    readonly sideEdge: readonly (readonly number[])[];
    readonly hull: readonly Vec3[];
    readonly reach: number;
    readonly round: boolean;
    readonly convex: boolean;
    readonly upright: boolean;
};

メンバー

名前型説明
kindSolidKind
nnumber

The cut: cells along an edge of a face (cube, and the triangle solids), or the frequency of the globe (sphere).

shapeSolidKind

The kind, as CellGraph has it (the algorithms read shape, w and h only to refuse Eller's, which needs rows).

wnumber
hnumber
cellsnumber
neighboursreadonly (readonly number[])[]

The cell across each side of each cell, in the order of the sides.

cornersreadonly (readonly number[])[]

Each cell's corners (indices into vertices), counter-clockwise seen from outside. Side k runs from corner k to corner k + 1.

verticesreadonly Vec3[]
centresreadonly Vec3[]

The middle of each cell, on the surface.

normalsreadonly Vec3[]

Which way each cell faces, of length one.

radiireadonly number[]

How far each cell reaches from its middle to the middle of its nearest side: the room for a mark in it.

faceOfreadonly number[]

Which of the solid's own faces each cell is on (the sphere has none to name: -1).

edgesreadonly SolidEdge[]
sideEdgereadonly (readonly number[])[]

For each cell and side, the edge it is (an index into edges).

hullreadonly Vec3[]

The corners of the solid itself, which decide how far it reaches whichever way it is turned (empty for the sphere, which reaches reach everywhere).

reachnumber

The farthest any part of the solid is from its middle.

roundboolean

Whether the solid is round (a silhouette that is a circle however it is turned).

convexboolean

Whether the solid is convex: no part of it can hide another, so the cells that face the viewer are the cells that are seen. A star, a cross, a ring or a heart is not, and is painted back to front.

uprightboolean

Whether the solid has a way up (a heart, a star): it is first seen upright.

例

import type { MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze } from "@johnmorrisdotca/meikyuu";
import type { SolidGrid, SolidRecipe } from "@johnmorrisdotca/meikyuu/3d";
import { buildSolidMaze } from "@johnmorrisdotca/meikyuu/3d";

const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const grid = maze.grid;
const solidRecipe: SolidRecipe = {kind:"cube",n:2,algorithm:"backtracker",seed:42};
const solid = buildSolidMaze(solidRecipe);
const solidGrid = solid.grid;
const value: SolidGrid = solidGrid;
console.log(value);
{
  kind: 'cube',
  n: 2,
  shape: 'cube',
  w: 2,
  h: 2,
  cells: 24,
  neighbours: [
    [ 21, 1, 2, 14 ],  [ 23, 10, 3, 0 ],
    [ 0, 3, 17, 15 ],  [ 1, 11, 19, 2 ],
    [ 6, 5, 20, 12 ],  [ 7, 8, 22, 4 ],
    [ 16, 7, 4, 13 ],  [ 18, 9, 5, 6 ],
    [ 5, 9, 10, 22 ],  [ 7, 18, 11, 8 ],
    [ 8, 11, 1, 23 ],  [ 9, 19, 3, 10 ],
    [ 14, 13, 4, 20 ], [ 15, 16, 6, 12 ],
    [ 0, 15, 12, 21 ], [ 2, 17, 13, 14 ],
    [ 13, 17, 18, 6 ], [ 15, 2, 19, 16 ],
    [ 16, 19, 9, 7 ],  [ 17, 3, 11, 18 ],
    [ 22, 21, 12, 4 ], [ 23, 0, 14, 20 ],
    [ 8, 23, 20, 5 ],  [ 10, 1, 21, 22 ]
  ],
  corners: [
    [ 0, 1, 2, 3 ],     [ 1, 4, 5, 2 ],
    [ 3, 2, 6, 7 ],     [ 2, 5, 8, 6 ],
    [ 12, 11, 10, 9 ],  [ 11, 14, 13, 10 ],
    [ 16, 15, 11, 12 ], [ 15, 17, 14, 11 ],
    [ 13, 14, 18, 19 ], [ 14, 17, 20, 18 ],
    [ 19, 18, 5, 4 ],   [ 18, 20, 8, 5 ],
    [ 22, 21, 12, 9 ],  [ 21, 23, 16, 12 ],
    [ 0, 3, 21, 22 ],   [ 3, 7, 23, 21 ],
    [ 16, 23, 24, 15 ], [ 23, 7, 6, 24 ],
    [ 15, 24, 20, 17 ], [ 24, 6, 8, 20 ],
    [ 10, 25, 22, 9 ],  [ 25, 1, 0, 22 ],
    [ 13, 19, 25, 10 ], [ 19, 4, 1, 25 ]
  ],
  vertices: [
    [ 1, -1, -1 ], [ 1, 0, -1 ],
    [ 1, 0, 0 ],   [ 1, -1, 0 ],
    [ 1, 1, -1 ],  [ 1, 1, 0 ],
    [ 1, 0, 1 ],   [ 1, -1, 1 ],
    [ 1, 1, 1 ],   [ -1, -1, -1 ],
    [ -1, 0, -1 ], [ -1, 0, 0 ],
    [ -1, -1, 0 ], [ -1, 1, -1 ],
    [ -1, 1, 0 ],  [ -1, 0, 1 ],
    [ -1, -1, 1 ], [ -1, 1, 1 ],
    [ 0, 1, 0 ],   [ 0, 1, -1 ],
    [ 0, 1, 1 ],   [ 0, -1, 0 ],
    [ 0, -1, -1 ], [ 0, -1, 1 ],
    [ 0, 0, 1 ],   [ 0, 0, -1 ]
  ],
  centres: [
    [ 1, -0.5, -0.5 ],  [ 1, 0.5, -0.5 ],
    [ 1, -0.5, 0.5 ],   [ 1, 0.5, 0.5 ],
    [ -1, -0.5, -0.5 ], [ -1, 0.5, -0.5 ],
    [ -1, -0.5, 0.5 ],  [ -1, 0.5, 0.5 ],
    [ -0.5, 1, -0.5 ],  [ -0.5, 1, 0.5 ],
    [ 0.5, 1, -0.5 ],   [ 0.5, 1, 0.5 ],
    [ -0.5, -1, -0.5 ], [ -0.5, -1, 0.5 ],
    [ 0.5, -1, -0.5 ],  [ 0.5, -1, 0.5 ],
    [ -0.5, -0.5, 1 ],  [ 0.5, -0.5, 1 ],
    [ -0.5, 0.5, 1 ],   [ 0.5, 0.5, 1 ],
    [ -0.5, -0.5, -1 ], [ 0.5, -0.5, -1 ],
    [ -0.5, 0.5, -1 ],  [ 0.5, 0.5, -1 ]
  ],
  normals: [
    [ 1, 0, 0 ],  [ 1, 0, 0 ],
    [ 1, 0, 0 ],  [ 1, 0, 0 ],
    [ -1, 0, 0 ], [ -1, 0, 0 ],
    [ -1, 0, 0 ], [ -1, 0, 0 ],
    [ 0, 1, 0 ],  [ 0, 1, 0 ],
    [ 0, 1, 0 ],  [ 0, 1, 0 ],
    [ 0, -1, 0 ], [ 0, -1, 0 ],
    [ 0, -1, 0 ], [ 0, -1, 0 ],
    [ 0, 0, 1 ],  [ 0, 0, 1 ],
    [ 0, 0, 1 ],  [ 0, 0, 1 ],
    [ 0, 0, -1 ], [ 0, 0, -1 ],
    [ 0, 0, -1 ], [ 0, 0, -1 ]
  ],
  radii: [
    0.5, 0.5, 0.5, 0.5, 0.5,
    0.5, 0.5, 0.5, 0.5, 0.5,
    0.5, 0.5, 0.5, 0.5, 0.5,
    0.5, 0.5, 0.5, 0.5, 0.5,
    0.5, 0.5, 0.5, 0.5
  ],
  faceOf: [
    0, 0, 0, 0, 1, 1, 1, 1,
    2, 2, 2, 2, 3, 3, 3, 3,
    4, 4, 4, 4, 5, 5, 5, 5
  ],
  edges: [
    { a: 0, b: 1, left: 0, right: 21 },
    { a: 1, b: 2, left: 0, right: 1 },
    { a: 2, b: 3, left: 0, right: 2 },
    { a: 0, b: 3, left: 0, right: 14 },
    { a: 1, b: 4, left: 1, right: 23 },
    { a: 4, b: 5, left: 1, right: 10 },
    { a: 2, b: 5, left: 1, right: 3 },
    { a: 2, b: 6, left: 2, right: 3 },
    { a: 6, b: 7, left: 2, right: 17 },
    { a: 3, b: 7, left: 2, right: 15 },
    { a: 5, b: 8, left: 3, right: 11 },
    { a: 6, b: 8, left: 3, right: 19 },
    { a: 11, b: 12, left: 4, right: 6 },
    { a: 10, b: 11, left: 4, right: 5 },
    { a: 9, b: 10, left: 4, right: 20 },
    { a: 9, b: 12, left: 4, right: 12 },
    { a: 11, b: 14, left: 5, right: 7 },
    { a: 13, b: 14, left: 5, right: 8 },
    { a: 10, b: 13, left: 5, right: 22 },
    { a: 15, b: 16, left: 6, right: 16 },
    { a: 11, b: 15, left: 6, right: 7 },
    { a: 12, b: 16, left: 6, right: 13 },
    { a: 15, b: 17, left: 7, right: 18 },
    { a: 14, b: 17, left: 7, right: 9 },
    { a: 14, b: 18, left: 8, right: 9 },
    { a: 18, b: 19, left: 8, right: 10 },
    { a: 13, b: 19, left: 8, right: 22 },
    { a: 17, b: 20, left: 9, right: 18 },
    { a: 18, b: 20, left: 9, right: 11 },
    { a: 5, b: 18, left: 10, right: 11 },
    { a: 4, b: 19, left: 10, right: 23 },
    { a: 8, b: 20, left: 11, right: 19 },
    { a: 21, b: 22, left: 12, right: 14 },
    { a: 12, b: 21, left: 12, right: 13 },
    { a: 9, b: 22, left: 12, right: 20 },
    { a: 21, b: 23, left: 13, right: 15 },
    { a: 16, b: 23, left: 13, right: 16 },
    { a: 3, b: 21, left: 14, right: 15 },
    { a: 0, b: 22, left: 14, right: 21 },
    { a: 7, b: 23, left: 15, right: 17 },
    { a: 23, b: 24, left: 16, right: 17 },
    { a: 15, b: 24, left: 16, right: 18 },
    { a: 6, b: 24, left: 17, right: 19 },
    { a: 20, b: 24, left: 18, right: 19 },
    { a: 10, b: 25, left: 20, right: 22 },
    { a: 22, b: 25, left: 20, right: 21 },
    { a: 1, b: 25, left: 21, right: 23 },
    { a: 19, b: 25, left: 22, right: 23 }
  ],
  sideEdge: [
    [ 0, 1, 2, 3 ],     [ 4, 5, 6, 1 ],
    [ 2, 7, 8, 9 ],     [ 6, 10, 11, 7 ],
    [ 12, 13, 14, 15 ], [ 16, 17, 18, 13 ],
    [ 19, 20, 12, 21 ], [ 22, 23, 16, 20 ],
    [ 17, 24, 25, 26 ], [ 23, 27, 28, 24 ],
    [ 25, 29, 5, 30 ],  [ 28, 31, 10, 29 ],
    [ 32, 33, 15, 34 ], [ 35, 36, 21, 33 ],
    [ 3, 37, 32, 38 ],  [ 9, 39, 35, 37 ],
    [ 36, 40, 41, 19 ], [ 39, 8, 42, 40 ],
    [ 41, 43, 27, 22 ], [ 42, 11, 31, 43 ],
    [ 44, 45, 34, 14 ], [ 46, 0, 38, 45 ],
    [ 26, 47, 44, 18 ], [ 30, 4, 46, 47 ]
  ],
  hull: [
    [ -1, -1, -1 ],
    [ -1, -1, 1 ],
    [ -1, 1, -1 ],
    [ -1, 1, 1 ],
    [ 1, -1, -1 ],
    [ 1, -1, 1 ],
    [ 1, 1, -1 ],
    [ 1, 1, 1 ]
  ],
  reach: 1.7320508075688772,
  round: false,
  convex: true,
  upright: false
}

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

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

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