an.stage.support#

Supports: what a body rests on, and how far it is from resting there (an#519, catalogue A1).

A support joint (an.ir.schema.JointSpec, type: support) says a body’s contact points rest on a surface: ground (the shot’s floor line), <body>@surface[@f] (a body’s supporting segment, the hold layer’s grammar) or a world@x,y segment with end. This module is the pure measurement under the support check (an.verify.support):

  • contacts_of(): the named points of an entity that touch what it stands on, by one fallback chain: the entity kind’s hook (an.genres.EntityKind.contacts: a character’s feet), else the descriptor’s metadata.contacts ({name: [u, v]}, fractions of the root part’s drawing), else the rig’s declared origin when a part rests on it (an#601’s rule: where the rig stands, not where it is held), else the lowest point of its root parts’ ink: ink when a raster’s alpha hull was read, box when only the corners of its box were (SVG art), which is measured for a declared support but never makes an entity be taken to stand.

  • supports_at(): every declared support of a compiled shot, and every entity taken to stand on its floor, as SupportState records per instant: each contact’s signed distance to the surface along its normal (an.stage.surface_line.lowest_on()’s sign: positive above, negative sunk), whether it is a limb’s (on a part that is not one of the body’s roots), where its foot on the surface lies along it (along, in the surface’s own frame) and how far that foot slid along it since the grid instant before while the contact was held there (the skate check’s measure, an#519 PR 2), with the references that do not resolve returned as (where, message).

A named point (cup@base, paul@foot_l) is resolved by the solve’s own resolver (an.stage.solve.locate_point()), so a pin and a support naming one contact name one point (an.stage.solve.contact_point()); a <body>@surface is the hold layer’s segment (an.stage.surface_line.body_surface()).

Tolerances are fractions of the entity’s height with a pixel floor (support_tolerance()): a wide and a close-up agree, and a small prop is not held to a gap below what a frame shows.

>>> support_tolerance(200.0), support_tolerance(30.0)
(4.0, 2.0)

Module Attributes

CONTACT_SOURCES

Where an entity's contacts come from, in the order the chain tries them.

CONTACTS_KEY

The descriptor's metadata key that names a prop's contacts.

SUPPORT_TOLERANCE

How far a contact may be off its surface, either way, as a fraction of the entity's height (4 px on a 200 px figure).

SUPPORT_FLOOR_PX

the solver's own rejoin blend (an.kinematics.solver.DFLT_REJOIN_BLEND_PX), below which it calls two points joined; a small prop is not held tighter than a joint.

SKATE_TOLERANCE

How fast a held contact's foot may move along its surface, in the surface's own frame, as a fraction of the entity's height PER SECOND (24 px/s on a 200 px figure: 1 px a frame at 24 fps, 0.4 px at 60).

SKATE_FLOOR_PX

The least skate speed tolerance, in px per second (half a pixel a frame at 24 fps: a fraction of a small body's height is less).

SKATE_DRIFT_TOLERANCE

How far a held contact's foot may drift along its surface over one stance (from where it was planted, while it stays held), as a fraction of the entity's height (6 px on a 200 px figure): a slow skate under the speed tolerance still adds up to a foot that is not where it was put down.

SKATE_DRIFT_FLOOR_PX

the support's own floor (SUPPORT_FLOOR_PX), below which two points are one.

SKATE_LIFT

A step between two instants whose foot moves along the surface's normal by more than this fraction of how far it moves along the surface is a lift-off or a landing (a foot leaving the floor while still within the support tolerance of it), not a slide: it is not measured for skate.

Functions

support_tolerance(height, *[, tolerance, floor])

How far a contact of an entity height px tall may be off its surface: tolerance of its height, never under floor px.

skate_tolerance(height, *[, tolerance, floor])

How fast (px per second) a held contact of an entity height px tall may slide along its surface: tolerance of its height per second, never under floor.

skate_drift_tolerance(height, *[, ...])

How far (px) a held contact of an entity height px tall may drift along its surface over one stance: tolerance of its height, never under floor.

contacts_of(entity, mall, *[, rig, ...])

entity's contacts, by the chain: the kind's hook, metadata.contacts, the rig's origin (when a root part's painted bottom rests on it, read in doc), else the lowest ink of its root parts: ink when doc shows a raster whose alpha hull was read, else box.

contacts_on_parts(entity, desc, *, rig)

The contacts the chain names on a part of entity's rig (the hook's, else metadata.contacts, a root-part fraction put on the first root): what the point resolver (an.stage.solve.locate_point()) names after a rig's landmarks, so a joint, a verb or a support may name paul@foot_l as it names paul@hand_l.

supports_at(doc, shot, mall, *[, times, ...])

Every declared support of shot in its compiled document doc at every instant of times (default: the solve's frame grid, an.stage.solve.frame_times()), joined or not; and, with inferred, every entity taken to stand on the shot's floor (solve: {ground: y}) as it opens: its lowest contact within support_tolerance() (tolerance of its height, floor px at least) of the floor then, measured at that instant and its rest instants (rest_only, the support check's rule) or at every instant (the skate check's, which judges a stance while it moves).

Classes

Contacts(source, points[, note])

An entity's contacts and where the chain found them.

ContactState(name, part, at, above[, limb, ...])

One contact at one instant.

SupportState(entity, joint, where, frame, t, ...)

One support (declared, or a stance taken as the shot opens) at one instant.

an.stage.support.CONTACTS_KEY: str = 'contacts'#

The descriptor’s metadata key that names a prop’s contacts.

an.stage.support.CONTACT_SOURCES: tuple[str, ...] = ('hook', 'metadata', 'origin', 'ink', 'box')#

Where an entity’s contacts come from, in the order the chain tries them.

class an.stage.support.ContactState(name, part, at, above, limb=False, along=0.0, slid=None)[source]#

Bases: object

One contact at one instant.

above: float#

Its signed distance to the surface along the normal (+ above, - sunk).

along: float = 0.0#

where the foot of its normal falls along the surface from a point fixed in it, in the surface’s units (a body’s surface: its own units from the segment’s first end, so it neither moves nor flips with the body; the floor and a stage segment: stage px from the floor’s (0, y) or the segment’s a).

Type:

Its foot parameter along the surface, in the surface’s own frame

at: tuple[float, float]#

Its stage point (the lowest of its points, for ink or box).

limb: bool = False#

its node is not the entity’s own nor one of its root parts (a leg hinged to the body, a hoof), so it moves relative to the body and can skate. A body’s own stance point (its origin, the ink of its roots, a prop’s base, a bone on a root part) cannot: a body that glides or is pushed slides on it by right.

Type:

Whether it is a limb’s

part: str#

The node path that carries it.

slid: float | None = None#

How far (stage px, signed along the surface) its foot moved along the surface, in the surface’s own frame, since the grid’s previous instant (so a body carried by what it stands on does not move); None unless it was held at both (its support joined, within the support tolerance of the surface) and the step was not a lift-off or a landing (SKATE_LIFT).

class an.stage.support.Contacts(source, points, note='')[source]#

Bases: object

An entity’s contacts and where the chain found them.

>>> Contacts("origin", {"origin": ("", None)}).names
('origin',)
note: str = ''#

Why a kind’s hook gave nothing it could use (it raised), else "".

an.stage.support.SKATE_DRIFT_FLOOR_PX: float = 2.0#

the support’s own floor (SUPPORT_FLOOR_PX), below which two points are one.

Type:

The least drift tolerance, in px

an.stage.support.SKATE_DRIFT_TOLERANCE: float = 0.03#

How far a held contact’s foot may drift along its surface over one stance (from where it was planted, while it stays held), as a fraction of the entity’s height (6 px on a 200 px figure): a slow skate under the speed tolerance still adds up to a foot that is not where it was put down.

an.stage.support.SKATE_FLOOR_PX: float = 12.0#

The least skate speed tolerance, in px per second (half a pixel a frame at 24 fps: a fraction of a small body’s height is less).

an.stage.support.SKATE_LIFT: float = 0.25#

A step between two instants whose foot moves along the surface’s normal by more than this fraction of how far it moves along the surface is a lift-off or a landing (a foot leaving the floor while still within the support tolerance of it), not a slide: it is not measured for skate.

an.stage.support.SKATE_TOLERANCE: float = 0.12#

How fast a held contact’s foot may move along its surface, in the surface’s own frame, as a fraction of the entity’s height PER SECOND (24 px/s on a 200 px figure: 1 px a frame at 24 fps, 0.4 px at 60). A speed, so one slide gets one verdict at any frame rate or step rate.

an.stage.support.SUPPORT_FLOOR_PX: float = 2.0#

the solver’s own rejoin blend (an.kinematics.solver.DFLT_REJOIN_BLEND_PX), below which it calls two points joined; a small prop is not held tighter than a joint.

Type:

The least tolerance, in px

an.stage.support.SUPPORT_TOLERANCE: float = 0.02#

How far a contact may be off its surface, either way, as a fraction of the entity’s height (4 px on a 200 px figure).

class an.stage.support.SupportState(entity, joint, where, frame, t, surface, surface_ref, contacts, joined, height, source, named='', world_floor=False)[source]#

Bases: object

One support (declared, or a stance taken as the shot opens) at one instant.

>>> s = SupportState("cup", None, "entities", 0, 0.0, ((0.0, 0.0), (1.0, 0.0)), "ground",
...     (ContactState("base", "cup", (0.0, -3.0), 3.0),), True, 30.0, "metadata")
>>> s.lowest, s.inferred
(3.0, True)
contacts: tuple[ContactState, ...]#

The contacts measured (one past a bounded surface’s ends is not).

frame: int#

The instant’s index on the shot’s frame grid, and its time.

height: float#

what its tolerance is a fraction of.

Type:

The entity’s height as the shot opens (px)

joint: str | None#

The support’s id; None when inferred.

property lowest: float | None#

The least distance of a contact above the surface; None, none measured.

named: str = ''#

The contact named in the reference, or "" for all of them.

source: str#

Where its contacts came from (CONTACT_SOURCES; a point named by bone, landmark or fraction is point).

where: str#

Where it is declared (joints/0, entities/1/joints/0, …).

world_floor: bool = False#

Whether the surface is the world’s floor (World.ground) as the camera projects it under the entity, measured along from a point held in the frame the entity stands in (an#519 PR 4), not a stage floor.

an.stage.support.contacts_of(entity, mall, *, rig=None, descriptor=None, doc=None)[source]#

entity’s contacts, by the chain: the kind’s hook, metadata.contacts, the rig’s origin (when a root part’s painted bottom rests on it, read in doc), else the lowest ink of its root parts: ink when doc shows a raster whose alpha hull was read, else box.

>>> from types import SimpleNamespace as NS
>>> contacts_of(NS(kind="prop", store=None, ref="x"), {}, descriptor={"origin": [0, 0]})
Contacts(source='origin', points={'origin': ('', None)}, note='')
>>> contacts_of(NS(kind="prop", store=None, ref="x"), {}).source
'box'
Return type:

Contacts

an.stage.support.contacts_on_parts(entity, desc, *, rig)[source]#

The contacts the chain names on a part of entity’s rig (the hook’s, else metadata.contacts, a root-part fraction put on the first root): what the point resolver (an.stage.solve.locate_point()) names after a rig’s landmarks, so a joint, a verb or a support may name paul@foot_l as it names paul@hand_l.

>>> from types import SimpleNamespace as NS
>>> contacts_on_parts(NS(kind="prop"), {"metadata": {"contacts": {"base": [0.5, 1]}}}, rig=NS(roots=("body",)))
{'base': ('body', (0.5, 1.0))}
Return type:

dict[str, tuple[str, tuple[float, float] | None]]

an.stage.support.skate_drift_tolerance(height, *, tolerance=0.03, floor=2.0)[source]#

How far (px) a held contact of an entity height px tall may drift along its surface over one stance: tolerance of its height, never under floor.

>>> skate_drift_tolerance(200.0), skate_drift_tolerance(40.0)
(6.0, 2.0)
Return type:

float

an.stage.support.skate_tolerance(height, *, tolerance=0.12, floor=12.0)[source]#

How fast (px per second) a held contact of an entity height px tall may slide along its surface: tolerance of its height per second, never under floor.

>>> skate_tolerance(200.0), skate_tolerance(40.0)
(24.0, 12.0)
Return type:

float

an.stage.support.support_tolerance(height, *, tolerance=0.02, floor=2.0)[source]#

How far a contact of an entity height px tall may be off its surface: tolerance of its height, never under floor px.

>>> support_tolerance(500.0), support_tolerance(500.0, tolerance=0.05, floor=30.0)
(10.0, 30.0)
Return type:

float

an.stage.support.supports_at(doc, shot, mall, *, times=None, inferred=True, rest_only=True, tolerance=0.02, floor=2.0, lift=0.25)[source]#

Every declared support of shot in its compiled document doc at every instant of times (default: the solve’s frame grid, an.stage.solve.frame_times()), joined or not; and, with inferred, every entity taken to stand on the shot’s floor (solve: {ground: y}) as it opens: its lowest contact within support_tolerance() (tolerance of its height, floor px at least) of the floor then, measured at that instant and its rest instants (rest_only, the support check’s rule) or at every instant (the skate check’s, which judges a stance while it moves).

A contact is held at an instant its support is joined and it is within that tolerance of the surface; its slid is how far (stage px) its foot parameter along the surface (along, in the surface’s own frame) changed since the grid’s previous instant, when it was held at both and its motion along the surface’s normal was at most lift of that (more is a foot leaving or meeting the surface). An entity is not measured at an instant it is not seen (its alpha at most an.base.UNSEEN_ALPHA: a member the world hides outside its on-screen window, a fade’s end), the rule the solidity check applies, so a slide is never measured across one. Returns the states and (where, message) for each reference that does not resolve (no state is made for it).

Return type:

tuple[list[SupportState], list[tuple[str, str]]]