hex_walk API

← hex_walk · version 0.1.2

40 public items, in source order. Generated from the registry index, which re-derives them from the package source at publish time — so a signature here is the one that version actually ships.

pub struct Stretch { sr_ax: float, sr_ay: float, sr_bx: float, sr_by: float, sr_z0: float, sr_z1: float, sr_cx: float = 0.0, sr_cy: float = 0.0, sr_r: float = 0.0 }

A wall as a walking body meets it: a line on the plan from (sr_ax, sr_ay) to (sr_bx, sr_by), from height sr_z0 up to sr_z1 — or, with a radius sr_r over 0, the arc of the circle of that radius round (sr_cx, sr_cy) from the first end anticlockwise to the second, both on it.

pub fn stretch_near(k: const Stretch, px: float, py: float) -> (float, float)

@FR-HW-Arc: an arc stretch is met at its nearest point, as a line is The point of stretch k nearest (px, py) on the plan: on its line, or its arc, or at its nearer end.

pub fn stretch_dist(k: const Stretch, px: float, py: float) -> float

How far (px, py) lies from stretch k on the plan.

pub struct Walker { wk_radius: float, wk_step_up: float, wk_height: float, wk_pace: float, wk_sub: float, wk_ahead: float, wk_nudge: float, wk_ease: float, wk_climb: float, wk_turns: float, wk_hand: float, wk_swing: float, wk_look: float, wk_neck: float, wk_pitch: float, wk_settle: float }

How a body walks — every measure a player feels. walker_new answers the tile-world house review's, played and approved.

pub fn walker_new() -> Walker

A walking person at the tile-world game's pace: a tile (1.5 m) in 140 ms.

pub fn walk_stretches(q: const hex_edge::Quads, from: integer, passes: const vector<integer>) -> vector<Stretch>

@FR-HW-Stand: a face stops the body when it stands up — steeper than a foot stands on — at any height The stretches of q's faces from face from on: each face that stands up — steeper than FLOOR_STEEP, so neither stood on (walk_floors) nor a ceiling — however low or thin, as the line between its two corners furthest apart on the plan, from its lowest corner to its highest — or, for a face drawn flat for a circle (hex_edge::quad_bend), the arc of that circle between those corners. Whether one stops a body is the walker's to say, by its step and its height (walk_push_from): an arm or a rail at the chest stops it, a riser under a step does not, and the same faces drawn at any scale give the same stretches, scaled. A face whose part is in passes (a wall's top, glass, a ladder's rungs) stops nothing.

pub struct Floors { fl_xyz: vector<float>, fl_plane: vector<float>, fl_x0: float, fl_y0: float, fl_cell: float, fl_seam: float, fl_cols: integer, fl_rows: integer, fl_start: vector<integer>, fl_list: vector<integer> }

The floors of a built world as a walking body stands on them (walk_floors): its faces that face up, each a plane over its corners, kept on a grid of square cells so a point finds the faces over it without looking at the others.

pub fn walk_floors(q: const hex_edge::Quads, from: integer, cell: float, seam: float = FLOOR_SEAM) -> Floors

@FR-HW-Floor: a body stands on what is drawn — the faces facing up, no level declared beside them The floors of q's faces from face from on: every face facing up — wound counter-clockwise seen from above (hex_edge::quad_add), no steeper than FLOOR_STEEP — whatever its part, so a floor's top, a wall's top, a doorway's sill and a step's tread are all stood on, and a floor's underside and a hole a floor was opened by are not. Kept on cells cell wide; a point seam off a face's edge still stands on it.

pub fn floor_heights(fl: const Floors, x: float, y: float) -> vector<float>

@FR-HW-Floor The heights of every floor over (x, y): each face it lies on, or no further than its seam (walk_floors) off its edge, at the height of that face's plane there. Lowest first.

pub fn walk_floor(w: const Walker, fl: const Floors, x: float, y: float, from: float, more: const vector<float>) -> float

@FR-HW-Floor: of the floors under the feet, the highest a step up reaches, else the lowest (a fall) The height a body's feet stand at over (x, y), with them at from before: of the floors there (floor_heights) and the heights in more (a stair's slope through its steps' front edges, which the caller draws as steps), the highest no more than wk_step_up over from; else the lowest — the body falls; with none at all, from: where nothing is drawn the body is not let fall out of the world.

pub fn walk_push_from(w: const Walker, k: const Stretch, px: float, py: float, feet: float) -> (float, float)

The body at (px, py), its feet at feet, pushed out of stretch k: wk_radius from its line or arc, square from it or round its end. A stretch that does not span the body's height stops nothing.

pub fn walk_push_out(w: const Walker, walls: const vector<Stretch>, more: const vector<Stretch>, x: float, y: float, feet: float) -> (float, float)

The body at (x, y), its feet at feet, pushed out of every stretch of walls and more, three times round (a corner pushes it from one into the other).

pub fn walk_fits(w: const Walker, ks: const vector<Stretch>, x: float, y: float, feet: float) -> boolean

Whether the body fits at (x, y), its feet at feet: none of ks pushes it.

pub fn walk_ease(w: const Walker, walls: const vector<Stretch>, x: float, y: float, feet: float, wx: float, wy: float) -> (float, float)

The sidestep a body walking from (x, y) along (wx, wy) (unit) eases by, and where its way is stopped: if a wall stops it within wk_ahead but a sidestep of at most wk_nudge frees it — on past the stop by wk_ahead again, a passage and not a notch — the smallest such sidestep, across the walk (positive to its right), found in twelfths of wk_nudge; else 0. (0, -1) when nothing stops it. Only the walls the look can reach are looked at.

pub struct Leaf { lf_rig: hex_body::Rig, lf_hx: float, lf_hy: float, lf_dir: float, lf_width: float, lf_z0: float, lf_z1: float, lf_thick: float, lf_mat: integer, lf_value: float, lf_to: float, lf_hand: float, lf_play: float, lf_top: vector<float> }

A door's leaf: a hex_body rig — the wall's way (lf_dir, turns) fixed, the leaf on its hinge at (lf_hx, lf_hy) turning from shut (0) to LEAF_OPEN, anticlockwise seen from above — lf_width wide from lf_z0 up to lf_z1, lf_thick thick to the right of its way; where it stands now (lf_value, turns open) and where it swings to (lf_to). A leaf of lf_hand -1 is its mirror: it turns clockwise, its thickness to the left of its way — the second leaf of a pair, hinged at the far post and shut back along the wall towards the first. It is drawn lf_play clear of its frame and of a second leaf (hex_edge::LEAF_PLAY), and a walk meets it over that play too: a body cannot pass a gap of millimetres, and meeting two leaves' ends apart would push it sideways off them. Its top runs along lf_top: (distance from its hinge, height) pairs from its hinge to its free edge, lf_z1 its highest — a square leaf's top is level, an arched leaf's follows its arch.

pub fn leaf_of(fl: (float, float, float, float, float, float, float), thick: float, mat: integer, hand: float = 1.0, play: float = hex_edge::LEAF_PLAY, top: vector<float> = []) -> Leaf

A door's leaf as hex_edge::feature_leaf answers it — (hinge x, hinge y, the wall's unit way x and y, width, z0, z1) — thick thick, of material mat, shut; turning anticlockwise (hand 1) or, its mirror, clockwise (-1); play clear of what is round it at either end; its top along top, the (distance from its hinge, height) pairs of an arched leaf's, or level at z1 when none are given.

pub fn leaf_set(l: Leaf, v: float)

The leaf stood v turns open, and left there (its joint's limits keep v in them).

pub fn leaf_ends(l: const Leaf, v: float) -> (float, float, float, float)

The leaf at v turns open on the plan — hex_body's pose of its rig: its hinge and its free end.

pub fn leaf_stretch(l: const Leaf, v: float) -> Stretch

The leaf at v as a walking body meets it: the line down its middle, on over its play at both ends.

pub fn leaf_clear(w: const Walker, l: const Leaf, v: float, x: float, y: float, feet: float) -> boolean

Whether the body at (x, y), its feet at feet, stands clear of the leaf at v.

pub fn leaves_stretches(ls: const vector<Leaf>) -> vector<Stretch>

Every leaf where it stands, as the walk meets it.

pub fn leaves_quads(ls: const vector<Leaf>, q: hex_edge::Quads) -> vector<Stretch>

Every leaf where it stands into q, part PART_LEAF: a slice between each two points of its top, its thickness to the right of its way (the left for a mirrored leaf), the slices composed so the faces between them are not drawn, and one picture laid over the whole leaf (hex_edge::quads_lay) from its hinge's foot to its free edge and its highest top, which turns with it. Answers the stretches the walk meets.

pub fn leaf_turn(l: const Leaf, hx: float, hy: float, mx: float, my: float) -> float

How a walk (mx, my) with the body touching the leaf at (hx, hy) turns it about its hinge: the sine of the walk's angle to the arm from the hinge to that point, positive turning it open.

pub fn leaf_in_hand(w: const Walker, l: const Leaf, x: float, y: float, fx: float, fy: float) -> boolean

Whether the body at (x, y) looking along (fx, fy) has its hand on the leaf: where its eye meets the leaf within wk_hand, or the leaf's nearest point within wk_hand and within 45 degrees of where it looks — an open door's edge, seen end on, is taken too.

pub fn leaf_pull_way(l: const Leaf, x: float, y: float) -> float

Which way a pull turns the leaf, the body at (x, y): towards the body — the sine of the body's angle to the leaf about its hinge, positive turning it open.

pub fn walk_pull(w: const Walker, pl: Place, b: const Body) -> integer

A pull by the body, its hand where its head looks: the nearest leaf of the place in hand (leaf_in_hand) is sent swinging towards the body — open from behind a shut door, shut from in front of an open one. Answers its number, -1 for none in hand.

pub fn leaves_swing(w: const Walker, pl: Place, b: const Body, dt: float, through: boolean) -> boolean

Every leaf of the place swung on for dt seconds towards where it was sent, its joint keeping it in its limits; one that would swing into the body stops against it until the body stands clear (unless through: a body that passes through walls, flying). Answers whether any moved.

pub struct Ladder { ld_x: float, ld_y: float, ld_z: float, ld_nx: float, ld_ny: float, ld_width: float, ld_h: float }

A ladder: its foot's middle (ld_x, ld_y) at height ld_z, climbed ld_h up from the side (ld_nx, ld_ny) faces (unit), ld_width wide.

pub fn ladder_at(ls: const vector<Ladder>, x: float, y: float, feet: float) -> integer

The ladder (its number) the body at (x, y), its feet at feet, is on: in front of it between its foot and its top, or over the edge behind its top with its feet there; -1 for none.

pub struct Place { pl_walls: vector<Stretch>, pl_leaves: vector<Leaf>, pl_ladders: vector<Ladder> }

What a body walks among: the walls, the door leaves (where each stands and is swinging to) and the ladders.

pub fn place_new(walls: const vector<Stretch>) -> Place

A place of these walls, no leaves and no ladders yet.

pub struct Body { bd_x: float, bd_y: float, bd_feet: float, bd_yaw: float, bd_head: float, bd_pitch: float }

A walking body: where it stands (bd_x, bd_y) and its feet's height; its yaw (degrees from north towards the east), the way it walks; its head's turn from that (degrees, as far as wk_neck) and its pitch (degrees up), the way it looks.

pub fn body_new(x: float, y: float, feet: float, yaw: float) -> Body

A body standing at (x, y) with its feet at feet, facing yaw, looking straight ahead.

pub fn body_way(b: const Body) -> (float, float)

The way the body walks, on the plan, of unit length.

pub fn body_view(b: const Body) -> (float, float)

The way the body's head looks, on the plan, of unit length.

pub fn walk_step(w: const Walker, pl: Place, b: Body, go: float, dt: float, floor: fn(float, float, float) -> float) -> boolean

One frame's walk, dt seconds of it, by the body its own way, forward (go 1), back (-1) or standing (0), in the place, its feet on floor(x, y, from). On a ladder, walking into it climbs it and away from it climbs down. Else the walk eases into a free way it is a little off, is swept in steps of at most wk_sub, pushes the leaves it walks into, and is pushed out of every wall and leaf after each step; a step up higher than wk_step_up ends it. Moves the body; answers whether a leaf moved.

pub fn walk_look(w: const Walker, b: Body, dx: float, dy: float)

The body's head after the pointer moved (dx, dy) pixels: it turns wk_look degrees a pixel, up to wk_neck either way of the body — past that the body turns with it (no neck turns free), its yaw kept within -180 .. 180 — and looks up and down as far as wk_pitch.

pub fn walk_settle(w: const Walker, b: Body, dt: float)

The body's head settling as the body walks or turns, dt seconds of it: its turn from the body eases back to straight ahead, a part 1 - e^(-dt / wk_settle) of it a frame, so after a while of moving it looks the way it goes without the pointer moving (owner, 2026-12-04). Its pitch stays: a walk may look down a stair it goes down. A caller settles the head only while the body moves — standing, a head keeps looking where it was turned.

pub fn look_way(yaw: float, pitch: float) -> (float, float, float)

The way an eye looks yaw degrees from north towards the east and pitch up, of unit length.

pub fn look_ray(yaw: float, pitch: float, field: float, px: integer, py: integer, w: integer, h: integer) -> (float, float, float)

The way through window pixel (px, py) of a w x h window, from an eye looking yaw and pitch (as look_way) with a view field degrees high, of unit length.