# @ferret/physics-response: API

142 exports. Generated from the source (`packages/physics-response/src`), so it matches the code.

## Classes

### AirCushion

*class* · `packages/physics-response/src/cushion.ts:22`

```ts
class AirCushion
```

- `readonly halfX: number`
- `readonly halfZ: number`
- `readonly corner: number`
- `gap: number`
- `readonly rho: number`
- `readonly cd: number`
- `readonly edge: number`
- `x: number`
- `z: number`
- `yaw: number`
- `force: number`
- `constructor(o: CushionOptions)`
- `place(x: number, z: number, yaw: number, force: number): void` — where the craft is, which way it points (yaw: forward = (sin, cos)) and the force the cushion carries, N
- `get area(): number` — the footprint's area, m2
- `get pressure(): number` — the pressure of the air under the craft above the outside air, Pa
- `get escape(): number` — the speed of the air leaving through the gap, m/s
- `edgeAt(x: number, z: number): { d: number; nx: number; nz: number }` — the signed distance from the footprint's edge (negative inside) and the outward direction there (world x, z)
- `perimeter(n: number): Array<{ x: number; z: number; nx: number; nz: number; length: number }>` — n points evenly along the skirt's edge, with the outward direction and the length of edge each stands for (world x, z), for the host to place effects on
- `pressureAt(x: number, z: number): number` — the pressure on the water at x, z, Pa: the cushion's inside the footprint, falling to zero over `edge` at its border
- `airAt(x: number, z: number): [number, number]` — the air along the surface outside the skirt at x, z, m/s (zero under the craft): the wall jet of the air that left through the gap

### BedWash

*class* · `packages/physics-response/src/bedwash.ts:12`

```ts
class BedWash
```

- `readonly size: number`
- `readonly cell: number`
- `origin: [number, number]`
- `readonly height: number`
- `readonly dh: Float64Array` — the change of the bed's height this step, m
- `readonly load: Float64Array`
- `readonly theta: Float64Array`
- `lost: number`
- `constructor(o: BedWashOptions)`
- `step(dt: number, at: (x: number, z: number) => BedCell): void`
- `netVolume(porosity = 0.4): number` — the volume of solid the height changes add up to, m3 (zero while nothing leaves the grid)

### FlakePool

*class* · `packages/physics-response/src/flakes.ts:17`

```ts
class FlakePool
```

- `readonly flakes: Flake[]`
- `constructor(readonly world: FlakeWorld, seed = 1)`
- `add(x: number, z: number, kind: FlakeKind, o: { wet?: number; y?: number } = {}): Flake`
- `static liftOff(k: FlakeKind, wet = 0): number` — the lift-off speed of a flake (the law), m/s along the ground
- `static regime(k: FlakeKind)` — the regime of a flake's fall
- `static terminal(k: FlakeKind)` — the terminal velocity of a flake in still air, m/s (positive down)
- `step(dt: number, t: number): void`

### FlowMap

*class* · `packages/physics-response/src/flowmap.ts:28`

```ts
class FlowMap
```

- `readonly size: number`
- `readonly cell: number`
- `readonly lowHeight: number`
- `readonly highHeight: number`
- `readonly publisher: string`
- `readonly deflect: number`
- `readonly data: Float32Array` — the grid: size*size cells of FLOW_MAP_CHANNELS floats, row z, column x
- `originX: number` — the world x, z of the grid's corner (cell 0,0) as of the last update
- `originZ: number`
- `active: boolean` — true when the last update found any motion at all: the draw code may skip the map when it is false
- `peak: number` — the fastest speed in the map (m/s) at the last update
- `version: number` — incremented at every update: a texture uploads when it changed
- `constructor(o: FlowMapOptions = {})`
- `get extent(): number` — the width of the covered square, metres
- `update(field: FlowField, cx: number, cz: number, t: number, stride = 1): void` — fill the grid round (cx, cz) at time t; the origin snaps to whole cells so a static source does not shimmer while the centre moves
- `sample(x: number, z: number, heightAboveGround = this.lowHeight): [number, number]` — the horizontal velocity of the map at a world point and height above the ground, bilinear in the grid, blended between the layers; zero outside

### FlowMapService

*class* · `packages/physics-response/src/flowmap.ts:98`

```ts
class FlowMapService
```

the flow map as a world service named `flow-map`: the level loader hands it to the foliage-wind plugin of the level it loads

- `readonly name: "flow-map"`
- `constructor(readonly map: FlowMap)`

### GroundWash

*class* · `packages/physics-response/src/ground.ts:13`

```ts
class GroundWash
```

- `readonly size: number`
- `readonly cell: number`
- `origin: [number, number]`
- `readonly height: number`
- `readonly dh: Float64Array` — the change of the ground's height this step, m (positive: deposit), per cell, row z
- `readonly flux: Float64Array` — the flux that leaves each cell, kg/m/s, and its friction velocity and threshold (for tests and the inspector)
- `readonly ustar: Float64Array`
- `readonly threshold: Float64Array`
- `lost: number` — the mass blown off the grid in all steps so far, kg (the edge cells' outflow)
- `constructor(o: GroundWashOptions)`
- `step(dt: number, at: (x: number, z: number) => GroundCell): DustEvent[]` — one step: fill `dh`; returns the dust thrown up. `at(x, z)` gives the air and the grains of a cell.
- `netMass(bulk: number): number` — the mass the height changes of this step add up to over the grid, kg, with the bulk density given (zero when nothing left the grid)

### PhysicsResponseService

*class* · `packages/physics-response/src/registry.ts:97`

```ts
class PhysicsResponseService
```

The overrides of the game. `source(id).set({ on, scale })`; `material(name).set(block | false)`; `law(class, impl)`; the events
`response:*` a game may handle and cancel. A game that sets nothing gets the defaults.

- `readonly name: "physics-response"`
- `constructor(private emit?: (name: string, payload: unknown) => void)`
- `source(id: string)`
- `sourceScale(id: string): number` — the multiplier of a source: 0 when it is off
- `material(name: string)`
- `responseOf(m: MaterialInfo & { response?: ResponseBlock | false }): ResponseBlock | false` — the response of a material: the game's block, else the material's own, else the derived one
- `law(cls: ResponseClassName, impl: LawImpl): void`
- `lawOf(cls: ResponseClassName): LawImpl | undefined`
- `on<K extends ResponseEventName>(name: K, fn: (e: ResponseEvents[K]) => void): () => void`
- `raise<K extends ResponseEventName>(name: K, e: Omit<ResponseEvents[K], 'cancel'>): boolean` — raise an event; returns false when a handler cancelled it (the engine then does not do the default)

### PropulsorSet

*class* · `packages/physics-response/src/propulsors.ts:57`

```ts
class PropulsorSet
```

- `readonly states: Map<string, PropulsorState>`
- `scale: number`
- `constructor(readonly field: FlowField, private o: PropulsorSetOptions)`
- `add(init: PropulsorInit): void`
- `remove(id: string): void`
- `jetName(id: string)` — the name of a propulsor's jet source in the field, and of its wall jet
- `wallName(id: string)`
- `thrustOf(it: PropulsorInit): { thrust: number; fromActuator: boolean }` — the thrust of one propulsor: from the actuator when the physics gives it, else its share of the weight in hover
- `update(): void` — Publish the jets of every propulsor as they are now. Call once a step, after the actuators have run.
- `dispose(): void` — take every source of the set out of the field

### ResponseBudget

*class* · `packages/physics-response/src/budget.ts:8`

```ts
class ResponseBudget
```

- `readonly name: "response-budget"`
- `constructor(private o: ResponseBudgetOptions = {})`
- `get mapEvery(): number` — run the map's raster every this many frames
- `get mapStride(): number` — ask the field at every this many cells of the map each way (`FlowMap.update` stride)
- `get waterStride(): number` — ask the field at every this many cells of the water's grid and fill the rest by the nearest
- `get groundEvery(): number` — step the ground wash every this many frames
- `get flakeShare(): number` — the share of the flakes stepped each frame, 0..1 (the others keep their place this frame)
- `level(id: 'map' | 'water' | 'ground' | 'flakes'): number`
- `qualityKnobs(): QualityKnob[]`

### SprayEmitter

*class* · `packages/physics-response/src/spray.ts:23`

```ts
class SprayEmitter
```

- `constructor(private o: SprayOptions = {})`
- `update(dt: number, samples: SpraySample[]): SprayEvent[]` — the events of dt seconds over the samples

### WaterResponseMap

*class* · `packages/physics-response/src/waterview.ts:21`

```ts
class WaterResponseMap
```

- `readonly size: number`
- `readonly cell: number`
- `originX: number`
- `originZ: number`
- `readonly data: Float32Array`
- `active: boolean`
- `version: number`
- `readonly rings: RingField` — the centimetre rings of drops and bodies falling in (drawn per pixel by the water shader from these sources; the grid keeps the coarse waves)
- `time: number` — the clock of the rings (s), advanced by update
- `constructor(readonly surface: WaterSurface, o: WaterResponseOptions = {})`
- `update(dt = 0, wind?: WindOver): void` — copy the surface into the grid (call after `surface.step`); the map is inactive while the surface is flat

### WaterResponseService

*class* · `packages/physics-response/src/waterview.ts:70`

```ts
class WaterResponseService
```

the water's response map as a world service named `water-response`

- `readonly name: "water-response"`
- `constructor(readonly map: WaterResponseMap)`

## Functions

### airOnWater

*function* · `packages/physics-response/src/water.ts:27`

```ts
function airOnWater(field: FlowField, surface: ForcedSurface, t: number, o: WaterForcingOptions = {}): (x: number, z: number) => [number, number, number]
```

the forcing function of the air on a water surface at time t, for `surface.forcing(...)`

### bedLoad

*function* · `packages/physics-response/src/laws/bed.ts:24`

```ts
function bedLoad(theta: number, thetaC: number, d: number, rhoS = RHO_SAND, rho = RHO_WATER): number
```

bed load, m2/s of solid volume per metre of width, Meyer-Peter and Muller: q = 8 (theta - theta_c)^1.5 sqrt((s - 1) g d^3)

### bedOf

*function* · `packages/physics-response/src/registry.ts:82`

```ts
function bedOf(m: MaterialInfo): ResponseBlock
```

the bed class of a ground material, for the water side (the same grain as its wind side)

### bedShear

*function* · `packages/physics-response/src/laws/bed.ts:8`

```ts
function bedShear(u: number, z: number, d: number, rho = RHO_WATER): number
```

the bed shear stress of a flow of speed u at height z over a bed of grain d: tau = rho (kappa u / ln(z / z0))^2, z0 = d / 30

### breakingSpeed

*function* · `packages/physics-response/src/laws/slender.ts:25`

```ts
function breakingSpeed(d: number, L: number, strength: number, cd = 1.0, rho = RHO_AIR): number
```

the wind speed at which a uniformly loaded round stem (diameter d, length L, drag per length 1/2 rho Cd d v^2) breaks at its root: sigma_u = M c / I with M = w L^2 / 2

### cantileverFrequency

*function* · `packages/physics-response/src/laws/slender.ts:19`

```ts
function cantileverFrequency: (L: number, E: number, I: number, massPerLength: number) => number
```

the first natural frequency of a cantilever, Hz: (1.875^2 / 2 pi) sqrt(EI / (m' L^4)), m' the mass per length

### cantileverTipPoint

*function* · `packages/physics-response/src/laws/slender.ts:16`

```ts
function cantileverTipPoint: (F: number, L: number, E: number, I: number) => number
```

the tip deflection of a cantilever of length L: point load at the tip F L^3 / 3EI; uniform load w (N/m) w L^4 / 8EI

### cantileverTipUniform

*function* · `packages/physics-response/src/laws/slender.ts:17`

```ts
function cantileverTipUniform: (w: number, L: number, E: number, I: number) => number
```

### capillaryHold

*function* · `packages/physics-response/src/laws/flakes.ts:17`

```ts
function capillaryHold: (wet: number, gap?: number, gamma?: number) => number
```

the capillary pressure that holds a wet flake to a surface: 2 gamma / gap, scaled by the wet share (0 dry .. 1 wet)

### columnHeight

*function* · `packages/physics-response/src/laws/liquid.ts:21`

```ts
function columnHeight: (v: number, D: number, a?: number) => number
```

the height of the Worthington column rising from the closing cavity: H = a D sqrt(Fr) = a v sqrt(D / g), a = 0.5 (a tunable fit of the order of magnitude of the experiments)

### craterRadius

*function* · `packages/physics-response/src/laws/liquid.ts:17`

```ts
function craterRadius: (E: number) => number
```

the radius of the crater an impact of energy E makes: R = 0.5 (E / rhoW g)^(1/4) (the scaling `water.splash` uses)

### cushionSpray

*function* · `packages/physics-response/src/spray-droplets.ts:54`

```ts
function cushionSpray(c: AirCushion, n: number, water: (x: number, z: number) => number | null, carrier: [number, number, number], law: SprayLaw = {}): DropletEmitter[]
```

The shedding lines of a cushion's skirt over water: `n` pieces of the edge, each where `water(x, z)` gives a level (else none), at the escape speed of the
cushion through its gap; `carrier` is the craft's velocity.

### dentDepth

*function* · `packages/physics-response/src/laws/liquid.ts:13`

```ts
function dentDepth: (q: number) => number
```

the depth of the dent a steady pressure q makes in a still surface: q / (rhoW g)

### deriveResponse

*function* · `packages/physics-response/src/registry.ts:63`

```ts
function deriveResponse(m: MaterialInfo): ResponseBlock | false
```

the response a material has when it carries no block: from what it is and its numbers

### dimensionlessGrain

*function* · `packages/physics-response/src/laws/bed.ts:15`

```ts
function dimensionlessGrain: (d: number, rhoS?: number, rho?: number, nu?: number) => number
```

the dimensionless grain size D* = d (g (s - 1) / nu^2)^(1/3)

### dropEnergy

*function* · `packages/physics-response/src/spray.ts:21`

```ts
function dropEnergy: (speed: number) => number
```

drop energy at an air speed: half a 0.2 g drop at that speed

### fallRegime

*function* · `packages/physics-response/src/laws/flakes.ts:15`

```ts
function fallRegime: (massRatio: number) => "flutter" | "tumble"
```

`'flutter'` (a light, wide plate: side to side), `'tumble'` (a heavy one: end over end)

### firstToGo

*function* · `packages/physics-response/src/laws/rigid.ts:10`

```ts
function firstToGo: (b: RestingBody, rho?: number) => { speed: number; mode: "slide" | "tip"; }
```

which comes first

### floatDrift

*function* · `packages/physics-response/src/bedwash.ts:48`

```ts
function floatDrift(current: [number, number], dir: [number, number], a: number, k: number, immersion = 0): [number, number]
```

the drift of a float on a regular wave of amplitude a and wave number k with a current: its velocity is the current plus the Stokes drift at its depth (a float rides the surface, depth 0)

### floatShare

*function* · `packages/physics-response/src/laws/bed.ts:37`

```ts
function floatShare: (rho0: number, rho?: number) => number
```

the share of a float of density rho0 below the surface: rho0 / rho (it floats while that is below 1)

### flutterFrequency

*function* · `packages/physics-response/src/laws/slender.ts:21`

```ts
function flutterFrequency: (v: number, d: number, st?: number) => number
```

the flutter frequency of a leaf or a stem of width d in a flow v: f = St v / d, St = 0.2

### frictionVelocity

*function* · `packages/physics-response/src/laws/granular.ts:11`

```ts
function frictionVelocity: (u: number, z: number, z0: number) => number
```

the friction velocity of a flow of speed `u` at height `z` over a rough surface of roughness length `z0`: u* = kappa u / ln(z / z0)

### grainRoughness

*function* · `packages/physics-response/src/laws/granular.ts:13`

```ts
function grainRoughness: (d: number) => number
```

the roughness length of a bed of grains of diameter d: z0 = d / 30 (Nikuradse)

### groupSpeed

*function* · `packages/physics-response/src/laws/liquid.ts:26`

```ts
function groupSpeed: (k: number) => number
```

the group speed d omega / d k: where the rings run

### impactFroude

*function* · `packages/physics-response/src/laws/liquid.ts:19`

```ts
function impactFroude: (v: number, D: number) => number
```

the Froude number of an impact of a body of diameter D at speed v: Fr = v^2 / (g D)

### impactOnWater

*function* · `packages/physics-response/src/impact.ts:11`

```ts
function impactOnWater(surface: DisturbableSurface, i: Impact): ImpactResult
```

### isbashSpeed

*function* · `packages/physics-response/src/laws/bed.ts:33`

```ts
function isbashSpeed: (D: number, rhoS?: number, rho?: number, C?: number) => number
```

the speed a stone of diameter D starts to move at (Isbash): V_c = C sqrt(2 g D (rhoS - rho) / rho), C = 0.86 exposed .. 1.2 embedded

### jetFlux

*function* · `packages/physics-response/src/melt.ts:8`

```ts
function jetFlux(j: HotJet, r: number): { h: number; flux: number }
```

the heat transfer coefficient (W/m2/K) and the flux (W/m2) at radius r from the stagnation point; zero when the jet meets no surface

### jetHeatTransfer

*function* · `packages/physics-response/src/laws/heat.ts:12`

```ts
function jetHeatTransfer(v: number, D: number, r: number, H: number, k = K_AIR, nu = NU_AIR): number
```

the heat transfer coefficient h = Nu k / D, W/m2/K, of a jet of exit speed v and diameter D at the radius r on a surface H away

### jetOf

*function* · `packages/physics-response/src/propulsors.ts:48`

```ts
function jetOf(d: ModelPropulsor, thrust: number): { velocity: number; diameter: number }
```

The jet of a propulsor of thrust T: an open rotor or propeller of disc area A has the induced velocity v_i = sqrt(T / 2 rho A) at the disc and a wake of twice
that over half the area (momentum theory); a ducted fan, a nozzle and an exhaust leave at v_e = sqrt(T / rho A_e).

### liftOffSpeed

*function* · `packages/physics-response/src/laws/flakes.ts:20`

```ts
function liftOffSpeed(p: LiftOff, rho = RHO_AIR): { lift: number; slide: number; start: number }
```

the wash speed that lifts a lying piece: 1/2 rho v^2 Cl = sigma g + hold; it slides at 1/2 rho v^2 Cd = mu (sigma g + hold) with Cd for the edge of a plate; the smaller is the speed it starts to move at

### martinNusselt

*function* · `packages/physics-response/src/laws/heat.ts:6`

```ts
function martinNusselt(Re: number, r: number, D: number, H: number, Pr = PR_AIR): number
```

Martin's correlation, Nu = Pr^0.42 F(Re) G(r/D, H/D) with F = 2 sqrt(Re) sqrt(1 + 0.005 Re^0.55), G = (D/r)(1 - 1.1 D/r) / (1 + 0.1 (H/D - 6) D/r); r the radius from the stagnation point, H the nozzle height; valid 2000 < Re < 400000, 2.5 < r/D < 7.5, 2 < H/D < 12 (used beyond as the same trend)

### meltRate

*function* · `packages/physics-response/src/laws/heat.ts:17`

```ts
function meltRate: (h: number, dT: number) => number
```

the melt rate of ice or snow at the melting point under a flux h dT, kg/m2/s

### moistureFactor

*function* · `packages/physics-response/src/laws/granular.ts:20`

```ts
function moistureFactor(wetPercent: number): number
```

the factor wet grains raise the threshold by (Hotta et al.): 1.8 + 0.6 log10(w), w the gravimetric moisture in percent, rising from 1 at dry

### nearestSurface

*function* · `packages/physics-response/src/surface.ts:27`

```ts
function nearestSurface: (...qs: SurfaceQuery[]) => SurfaceQuery
```

The nearest of several surface queries.

### orbitalSpeed

*function* · `packages/physics-response/src/laws/liquid.ts:30`

```ts
function orbitalSpeed: (a: number, k: number, depth?: number) => number
```

the orbital speed at the surface of a deep water wave of amplitude a and wave number k: a omega; and the Stokes drift omega k a^2 (decaying as exp(2 k z) with depth z below the surface)

### phaseSpeed

*function* · `packages/physics-response/src/laws/liquid.ts:24`

```ts
function phaseSpeed: (k: number) => number
```

### planeSurface

*function* · `packages/physics-response/src/surface.ts:18`

```ts
function planeSurface(y: number, kind: SurfaceHit['kind'] = 'ground', material?: string): SurfaceQuery
```

A horizontal plane as a surface (the still water, a flat floor) for tests and simple scenes.

### plateMassRatio

*function* · `packages/physics-response/src/laws/flakes.ts:11`

```ts
function plateMassRatio: (rhoS: number, h: number, d: number, rho?: number) => number
```

the dimensionless mass of a plate of density rhoS, thickness h, diameter d in a fluid of density rho: I* = rhoS h / (rho d)

### ringWaveNumber

*function* · `packages/physics-response/src/laws/liquid.ts:28`

```ts
function ringWaveNumber: (R: number) => number
```

the wave number a ring of crater radius R is carried by: k = pi / R

### rootStress

*function* · `packages/physics-response/src/laws/slender.ts:23`

```ts
function rootStress: (M: number, d: number) => number
```

the root bending stress of a round stem of diameter d under the moment M: sigma = M (d / 2) / I

### roundSecondMoment

*function* · `packages/physics-response/src/laws/slender.ts:14`

```ts
function roundSecondMoment: (d: number) => number
```

the second moment of area of a round section of diameter d

### saltationFlux

*function* · `packages/physics-response/src/laws/granular.ts:26`

```ts
function saltationFlux(ustar: number, ustarT: number, d: number, rho = RHO_AIR, C = 1.8): number
```

the saltation flux, kg per metre of width per second: q = C sqrt(d / D) (rho / g) u*^3 (1 - (u*_t / u*)^2) above the threshold, else 0 (Bagnold; the bracket makes it vanish at the threshold)

### settlingVelocity

*function* · `packages/physics-response/src/laws/bed.ts:28`

```ts
function settlingVelocity(d: number, rhoS = RHO_SAND, rho = RHO_WATER, nu = NU_WATER, C1 = 18, C2 = 0.4): number
```

the settling velocity of a natural grain (Ferguson and Church 2004): w = (s - 1) g d^2 / (C1 nu + sqrt(0.75 C2 (s - 1) g d^3)), C1 = 18, C2 = 0.4

### shields

*function* · `packages/physics-response/src/laws/bed.ts:22`

```ts
function shields: (tau: number, d: number, rhoS?: number, rho?: number) => number
```

the Shields parameter of a shear stress: tau / ((rhoS - rho) g d)

### shieldsCritical

*function* · `packages/physics-response/src/laws/bed.ts:17`

```ts
function shieldsCritical(d: number, rhoS = RHO_SAND, rho = RHO_WATER, cohesion = 0): number
```

the critical Shields parameter (Soulsby and Whitehouse 1997): 0.30 / (1 + 1.2 D*) + 0.055 (1 - exp(-0.020 D*)); `cohesion` raises it (clay) by the factor 1 + cohesion

### slenderDrag

*function* · `packages/physics-response/src/laws/slender.ts:7`

```ts
function slenderDrag(v: number, area: number, cd = 1.0, rho = RHO_AIR, psi = 0, vRef = 1): number
```

drag of a slender thing: F = 1/2 rho Cd A v^2, with Vogel's reconfiguration: beyond `vRef` the drag grows as v^(2+psi) (psi in -1..0; 0: rigid)

### slidingSpeed

*function* · `packages/physics-response/src/laws/rigid.ts:6`

```ts
function slidingSpeed: (b: RestingBody, rho?: number) => number
```

the speed at which the drag passes the friction: 1/2 rho Cd A v^2 = mu m g

### snowMelted

*function* · `packages/physics-response/src/melt.ts:14`

```ts
function snowMelted(j: HotJet, r: number, dt: number, depth: number, rho = 300): number
```

the depth of snow (density rho, kg/m3) melted in dt seconds at radius r: flux dt / (rho L), limited by what is there

### soilToMaterial

*function* · `packages/physics-response/src/registry.ts:144`

```ts
function soilToMaterial(name: string, s: SoilLike, moisture = 0): MaterialInfo
```

a soil as a ground material: its grains and its glue, at a moisture 0..1 (the gravimetric share is taken as the moisture of the column)

### speciesToMaterials

*function* · `packages/physics-response/src/registry.ts:150`

```ts
function speciesToMaterials(s: SpeciesLike): { limb: MaterialInfo; leaf: MaterialInfo | undefined }
```

a tree as the plant material of its crown limbs (a twig of a tenth of the breast diameter) and the flake of its fallen leaves

### sprayDiameter

*function* · `packages/physics-response/src/spray-droplets.ts:39`

```ts
function sprayDiameter(u: number): number
```

the median diameter the drops leave with at air speed u: ligaments twice the Weber-stable size, at most 1.2 mm (the bulk of spray is fine: the big drops of a gale are the tail of the distribution, the log-normal sigma)

### sprayFlux

*function* · `packages/physics-response/src/spray-droplets.ts:31`

```ts
function sprayFlux(u: number, delta: number, law: SprayLaw = {}): number
```

the volume flux per metre of line (m^3/s/m) of air at speed u over water through a layer delta thick

### stokesDrift

*function* · `packages/physics-response/src/laws/liquid.ts:31`

```ts
function stokesDrift: (a: number, k: number, depth?: number) => number
```

### stokesSettling

*function* · `packages/physics-response/src/laws/granular.ts:31`

```ts
function stokesSettling: (d: number, rhoP: number, rho?: number, nu?: number) => number
```

the settling speed of dust of diameter d by Stokes' law (small grains): w = (rhoP - rho) g d^2 / (18 rho nu)

### stoneMoves

*function* · `packages/physics-response/src/bedwash.ts:45`

```ts
function stoneMoves: (speed: number, D: number, rhoS?: number, C?: number) => boolean
```

does a flow of this speed move a stone of this diameter (Isbash)?

### terminalVelocity

*function* · `packages/physics-response/src/laws/flakes.ts:9`

```ts
function terminalVelocity: (sigma: number, rho?: number, cd?: number) => number
```

the terminal velocity of a plate of mass per area `sigma` falling flat: v = sqrt(2 sigma g / (rho Cd))

### thresholdFrictionVelocity

*function* · `packages/physics-response/src/laws/granular.ts:15`

```ts
function thresholdFrictionVelocity(d: number, rhoP: number, rho = RHO_AIR, cohesion = false): number
```

Bagnold's threshold friction velocity of grains of diameter d and density rhoP: u*_t = A sqrt((rhoP - rho) / rho g d); with `cohesion` the interparticle force adds gamma / (rho d) under the root

### thrustOfForce

*function* · `packages/physics-response/src/propulsors.ts:119`

```ts
function thrustOfForce: (force: V3 | undefined, on?: boolean) => number | undefined
```

The thrust an actuator state gives: the length of its force. For `PropulsorInit.thrust` over `ActuatorsCapability.state(name)`.

### tippingSpeed

*function* · `packages/physics-response/src/laws/rigid.ts:8`

```ts
function tippingSpeed: (b: RestingBody, rho?: number) => number
```

the speed at which the drag's moment about the downstream bottom edge passes the weight's: F h / 2 = m g w / 2

### waterFrictionVelocity

*function* · `packages/physics-response/src/laws/liquid.ts:11`

```ts
function waterFrictionVelocity: (tau: number) => number
```

the friction velocity of the water side of a wind-driven surface: sqrt(tau / rhoWater)

### waterImpact

*function* · `packages/physics-response/src/waterview.ts:67`

```ts
function waterImpact(map: WaterResponseMap, x: number, z: number, mass: number, speed: number): void
```

something of mass m (kg) at speed v (m/s) fell into the water at x, z now: rings from it

### waterlogged

*function* · `packages/physics-response/src/laws/bed.ts:35`

```ts
function waterlogged: (rho0: number, rhoMax: number, k: number, t: number) => number
```

a float that takes water: its density after time t, from `rho0` toward `rhoMax` with the rate `k` (1/s)

### waveFrequency

*function* · `packages/physics-response/src/laws/liquid.ts:23`

```ts
function waveFrequency: (k: number) => number
```

the dispersion of gravity-capillary waves in deep water: omega^2 = g k + (gamma / rho) k^3

### waveOrbit

*function* · `packages/physics-response/src/bedwash.ts:53`

```ts
function waveOrbit: (a: number, k: number, depth?: number) => number
```

the peak orbital speed of the same wave at the surface, m/s: what a float bobs and surges by

### windDragCoefficient

*function* · `packages/physics-response/src/laws/liquid.ts:7`

```ts
function windDragCoefficient: (u10: number) => number
```

the drag coefficient of the sea surface by the wind at 10 m (Large and Pond): 1.2e-3 up to 11 m/s, then (0.49 + 0.065 U) e-3

### windSpray

*function* · `packages/physics-response/src/spray-droplets.ts:70`

```ts
function windSpray(map: FlowMap, water: (x: number, z: number) => number | null, o: { block?: number; max?: number; delta?: number; skip?: (x: number, z: number) => boolean } & SprayLaw = {}): DropletEmitter[]
```

The shedding lines of the air over water from a flow map's low layer: blocks of `block` x `block` cells whose mean speed is over the onset, each a line across
the flow; the strongest `max` are kept. `delta` is the thickness of the fast layer next to the water (m, default 0.1).

### windStress

*function* · `packages/physics-response/src/laws/liquid.ts:9`

```ts
function windStress: (u: number, rho?: number) => number
```

the wind stress tau = rho C_D U^2, Pa (signed with the wind)

## Interfaces

### BedCell

*interface* · `packages/physics-response/src/bedwash.ts:9`

```ts
interface BedCell
```

- `u: [number, number]`
- `depth: number`
- `grains: BedGrains | null`

### BedGrains

*interface* · `packages/physics-response/src/bedwash.ts:8`

```ts
interface BedGrains
```

- `d50: number`
- `density?: number`
- `cohesion?: number`
- `porosity?: number`

### BedWashOptions

*interface* · `packages/physics-response/src/bedwash.ts:10`

```ts
interface BedWashOptions
```

- `size: number`
- `cell: number`
- `origin: [number, number]`
- `height?: number`

### CushionOptions

*interface* · `packages/physics-response/src/cushion.ts:7`

```ts
interface CushionOptions
```

- `halfX: number` — half-sizes of the skirt's footprint along the craft's right and forward axes, m
- `halfZ: number`
- `corner?: number` — radius of the footprint's rounded corners, m (default a fifth of the smaller half-size)
- `gap?: number` — the height of the gap the air leaves through, m (default 0.05)
- `rho?: number` — air density, kg/m3 (default 1.225)
- `cd?: number` — discharge coefficient of the gap (default 0.6, a sharp-edged orifice)
- `edge?: number` — m over which the pressure falls to zero at the footprint's edge (default 0.3)

### DisturbableSurface

*interface* · `packages/physics-response/src/impact.ts:7`

```ts
interface DisturbableSurface
```

- `disturb(x: number, z: number, volume: number, radius?: number): void`

### DustEvent

*interface* · `packages/physics-response/src/ground.ts:11`

```ts
interface DustEvent
```

- `at: [number, number]`
- `mass: number`

### Flake

*interface* · `packages/physics-response/src/flakes.ts:10`

```ts
interface Flake
```

- `x: number`
- `y: number`
- `z: number`
- `vx: number`
- `vy: number`
- `vz: number`
- `kind: FlakeKind`
- `wet: number`
- `airborne: boolean`
- `phase: number`
- `age: number`

### FlakeKind

*interface* · `packages/physics-response/src/flakes.ts:9`

```ts
interface FlakeKind
```

- `sigma: number`
- `mu?: number`
- `thickness?: number`
- `density?: number`
- `size?: number`

### FlakeWorld

*interface* · `packages/physics-response/src/flakes.ts:11`

```ts
interface FlakeWorld
```

- `air(x: number, y: number, z: number, t: number): [number, number, number]` — the air velocity at a point, m/s
- `ground(x: number, z: number): number` — the ground height at x, z
- `solid?(x: number, y: number, z: number): boolean` — true where a point is inside a solid (walls, bodies): a flake that enters it stops there

### FlowMapOptions

*interface* · `packages/physics-response/src/flowmap.ts:8`

```ts
interface FlowMapOptions
```

- `size?: number` — cells per side (default 64)
- `cell?: number` — metres per cell (default 1)
- `lowHeight?: number` — height above the ground of the low layer (default 0.4 m)
- `highHeight?: number` — height above the ground of the high layer (default 3 m)
- `ground?: (x: number, z: number) => number` — the ground height at x, z (default flat zero)
- `publisher?: string` — the publisher whose sources the map shows (default 'physics-response')
- `deflect?: number` — a vertical jet that meets the layer's height (a crown, a roof) turns outward along it, at this share of its speed (stagnation-point flow; a wall jet leaves an impinging jet at about half; default 0: off)

### ForcedSurface

*interface* · `packages/physics-response/src/water.ts:24`

```ts
interface ForcedSurface
```

- `level: number`
- `forcing(fn: ((x: number, z: number) => [number, number, number]) | null): void`

### GroundCell

*interface* · `packages/physics-response/src/ground.ts:9`

```ts
interface GroundCell
```

- `u: [number, number]`
- `grains: GroundGrains | null`

### GroundGrains

*interface* · `packages/physics-response/src/ground.ts:8`

```ts
interface GroundGrains
```

- `d50: number`
- `density: number`
- `bulk?: number`
- `wet?: number`
- `cohesive?: boolean`

### GroundWashOptions

*interface* · `packages/physics-response/src/ground.ts:10`

```ts
interface GroundWashOptions
```

- `size: number`
- `cell: number`
- `origin: [number, number]`
- `height?: number`

### HotJet

*interface* · `packages/physics-response/src/melt.ts:6`

```ts
interface HotJet
```

- `exitVelocity: number`
- `exitDiameter: number`
- `hitDistance: number | null`
- `excess: number`

### Impact

*interface* · `packages/physics-response/src/impact.ts:8`

```ts
interface Impact
```

- `x: number`
- `z: number`
- `mass: number`
- `speed: number`
- `diameter: number`

### ImpactResult

*interface* · `packages/physics-response/src/impact.ts:9`

```ts
interface ImpactResult
```

- `energy: number`
- `craterRadius: number`
- `craterVolume: number`
- `columnHeight: number`
- `splash: { mass: number; speed: number; energy: number }`

### LiftOff

*interface* · `packages/physics-response/src/laws/flakes.ts:18`

```ts
interface LiftOff
```

- `sigma: number`
- `mu?: number`
- `wet?: number`
- `cl?: number`
- `cd?: number`

### MaterialInfo

*interface* · `packages/physics-response/src/registry.ts:10`

```ts
interface MaterialInfo
```

what the engine knows of a material or a surface to derive its response from; every field is optional

- `name?: string`
- `surface?: 'ground' | 'water' | 'plant' | 'cloth' | 'flake' | 'rigid' | 'stone' | 'float'` — what the thing is: a ground layer, a water surface, a plant, cloth, a loose flake, a rigid body
- `density?: number`
- `youngs?: number`
- `strength?: number`
- `d50?: number` — a grain size, m (soil, sand, gravel) and the share of fines 0..1
- `fines?: number`
- `cohesion?: number`
- `wet?: number`
- `diameter?: number` — a plant's stem or leaf: diameter, length, mass per length or per area
- `length?: number`
- `sigma?: number`

### PropulsorInit

*interface* · `packages/physics-response/src/propulsors.ts:15`

```ts
interface PropulsorInit
```

- `id: string`
- `def: ModelPropulsor`
- `pose: () => PropulsorPose` — where it is now and which way it throws (the node's world transform applied to the model's `position` and `axis`)
- `thrust?: () => number | undefined` — the force of the running actuator on the body, N (its length is the thrust); undefined when the physics is not running

### PropulsorPose

*interface* · `packages/physics-response/src/propulsors.ts:14`

```ts
interface PropulsorPose
```

- `position: V3`
- `axis: V3`

### PropulsorSetOptions

*interface* · `packages/physics-response/src/propulsors.ts:23`

```ts
interface PropulsorSetOptions
```

- `group: string` — the prefix of the names of the sources it publishes (one per model instance)
- `weight?: () => number` — the weight of the whole model, N (mass x g), for the hover fallback
- `surface?: SurfaceQuery`
- `scale?: number` — the multiplier of every jet of this set (the game's override); 0 switches them all off
- `onGroundEffect?: (id: string, extra: V3, at: V3) => void` — a force the ground adds to the body that carries a propulsor in ground effect (CPU, feeds the fixed step): the extra thrust along the axis' opposite, N, at the point

### PropulsorState

*interface* · `packages/physics-response/src/propulsors.ts:34`

```ts
interface PropulsorState
```

- `id: string`
- `thrust: number`
- `fromActuator: boolean`
- `exitVelocity: number` — the exit velocity and diameter of the jet, m/s and m
- `exitDiameter: number`
- `hitDistance: number | null` — the surface the jet meets: its distance, or null
- `groundEffect: number`

### ResponseBlock

*interface* · `packages/physics-response/src/registry.ts:20`

```ts
interface ResponseBlock
```

- `class: ResponseClassName`
- `[param: string]: unknown`

### ResponseBudgetOptions

*interface* · `packages/physics-response/src/budget.ts:7`

```ts
interface ResponseBudgetOptions
```

- `[k: string]: never`

### ResponseClassDef

*interface* · `packages/physics-response/src/registry.ts:22`

```ts
interface ResponseClassDef
```

- `name: ResponseClassName`
- `summary: string`
- `defaults: Record<string, number | string | boolean>` — the parameters with their defaults
- `onset(block: ResponseBlock): number` — the speed (m/s) at which a thing of this block first responds to a flow, the number every class can give: a game and a test read it

### ResponseEvents

*interface* · `packages/physics-response/src/registry.ts:85`

```ts
interface ResponseEvents
```

- `'response:break': { entity?: string; at: [number, number, number]; cause: string; cancel(): void }`
- `'response:topple': { entity?: string; at: [number, number, number]; cancel(): void }`
- `'response:erode': { at: [number, number, number]; volume: number; cancel(): void }`
- `'response:spray': { at: [number, number, number]; energy: number; cancel(): void }`

### RestingBody

*interface* · `packages/physics-response/src/laws/rigid.ts:4`

```ts
interface RestingBody
```

- `mass: number`
- `area: number`
- `cd: number`
- `mu: number`
- `height: number`
- `width: number`

### SoilLike

*interface* · `packages/physics-response/src/registry.ts:142`

```ts
interface SoilLike
```

the shape of a `physics-terrain` Soil that the response reads (a structural type: this package does not depend on it)

- `density: number`
- `cohesion: number`
- `d50?: number`
- `fines?: number`
- `grainDensity?: number`

### SpeciesLike

*interface* · `packages/physics-response/src/registry.ts:148`

```ts
interface SpeciesLike
```

the shape of a `weather` TreeSpecies that the response reads

- `name: string`
- `dbh: number`
- `height: number`
- `mor: number`
- `mod: number`
- `leaf: number`
- `lma?: number`
- `cd: number`
- `vogel: number`

### SprayEvent

*interface* · `packages/physics-response/src/spray.ts:8`

```ts
interface SprayEvent
```

- `at: [number, number, number]`
- `energy: number`

### SprayLaw

*interface* · `packages/physics-response/src/spray-droplets.ts:17`

```ts
interface SprayLaw
```

- `onset?: number` — onset of spray, m/s (default 7)
- `eta?: number` — share of the air's momentum flux that goes into the water it throws (default 0.3)
- `elevation?: number` — angle the drops rise at, rad, and its spread (default 0.45, 0.25)
- `elevationSpread?: number`
- `parcelsPerMetre?: number` — parcels per metre of line per second at the onset speed doubled (the drawing's resolution, not the physics: the volume is the same)
- `life?: number` — the longest a parcel lives, s (default 3)

### SprayOptions

*interface* · `packages/physics-response/src/spray.ts:9`

```ts
interface SprayOptions
```

- `onset?: number` — the speed where spray starts (default 7 m/s, Monahan)
- `rate?: number` — events per second per square metre at 10 m/s above the onset (default 0.1)
- `cell?: number` — the cell area of one sample, m2
- `cap?: number` — at most this many events per update (default 8)
- `seed?: number`

### SpraySample

*interface* · `packages/physics-response/src/spray.ts:7`

```ts
interface SpraySample
```

- `x: number`
- `z: number`
- `speed: number`
- `y: number`

### SurfaceHit

*interface* · `packages/physics-response/src/surface.ts:5`

```ts
interface SurfaceHit
```

What a ray meets: the ground, the water or a body. `kind` says what to ask next (the soil, the wave field, the body's material).

- `distance: number` — distance along the ray, m
- `point: V3` — the point and the normal out of the surface
- `normal: V3`
- `kind: 'ground' | 'water' | 'body'`
- `material?: string` — the name of the material (a ground layer, `water`, a body's physical material), for the classes that read it

### WaterForcingOptions

*interface* · `packages/physics-response/src/water.ts:10`

```ts
interface WaterForcingOptions
```

- `height?: number` — the height above the water where the air is read (default 0.3 m)
- `level?: (x: number, z: number) => number` — the water level at x, z (default the surface's `level`)
- `publisher?: string` — only the sources a publisher owns (`physics-response`: propulsors); default all sources, the weather's wind too
- `bounds?: [number, number, number, number]` — a box x0, z0, x1, z1 outside which the forcing is zero and the field is not asked
- `scale?: number` — 0 switches the air's action on the water off
- `cushion?: AirCushion` — an air cushion of a craft: under its footprint the water takes the cushion's pressure (the air of its rotors goes into the cushion, it does not dent the water on its own); outside, the air that leaves under the skirt adds to the field's

### WaterResponseOptions

*interface* · `packages/physics-response/src/waterview.ts:7`

```ts
interface WaterResponseOptions
```

- `foamFrom?: number` — height above rest (m) from which the surface shows foam (default 0.04)
- `foamFull?: number` — height above rest (m) at which the foam is full (default 0.14)
- `whitecapOnset?: number` — air speed over the water (m/s) from which foam is made, as the onset of spray (default 7, Monahan)
- `foamLife?: number` — seconds in which the foam fades to a third (default 2.5)

## Types

### LawImpl

*type* · `packages/physics-response/src/registry.ts:84`

```ts
type LawImpl = { cpu?: (...a: number[]) => number; wgsl?: string; glsl?: string }
```

### ResponseClassName

*type* · `packages/physics-response/src/registry.ts:8`

```ts
type ResponseClassName = typeof RESPONSE_CLASSES[number]
```

### ResponseEventName

*type* · `packages/physics-response/src/registry.ts:91`

```ts
type ResponseEventName = keyof ResponseEvents
```

### SurfaceQuery

*type* · `packages/physics-response/src/surface.ts:15`

```ts
type SurfaceQuery = (from: V3, dir: V3, maxDistance: number) => SurfaceHit | null
```

The question a propulsor asks of the world: the nearest surface along a ray from `from` in the unit direction `dir`, within `maxDistance`, or null. The host answers from the ground query, the water surface and the physics rays.

### WindOver

*type* · `packages/physics-response/src/waterview.ts:19`

```ts
type WindOver = (x: number, z: number) => number
```

the air speed over a cell: what makes foam besides the height of the water

## Constants

### BAGNOLD_A

*const* · `packages/physics-response/src/laws/granular.ts:6`

```ts
const BAGNOLD_A: 0.1
```

### BAGNOLD_REF_GRAIN

*const* · `packages/physics-response/src/laws/granular.ts:8`

```ts
const BAGNOLD_REF_GRAIN: 0.00025
```

### CLASSES

*const* · `packages/physics-response/src/registry.ts:33`

```ts
const CLASSES: Record<"rigid" | "elastic" | "membrane" | "granular" | "flake" | "liquid-surface" | "bed" | "stone" | "floating" | "heat", ResponseClassDef>
```

### FLOW_MAP_CHANNELS

*const* · `packages/physics-response/src/flowmap.ts:26`

```ts
const FLOW_MAP_CHANNELS: 4
```

channels per cell: low.x, low.z, high.x, high.z

### G

*const* · `packages/physics-response/src/laws/constants.ts:3`

```ts
const G: 9.80665
```

### GRAVITY

*const* · `packages/physics-response/src/propulsors.ts:12`

```ts
const GRAVITY: 9.80665
```

### INTERPARTICLE_FORCE

*const* · `packages/physics-response/src/laws/granular.ts:7`

```ts
const INTERPARTICLE_FORCE: 0.000165
```

### K_AIR

*const* · `packages/physics-response/src/laws/constants.ts:11`

```ts
const K_AIR: 0.0257
```

### KAPPA

*const* · `packages/physics-response/src/laws/constants.ts:4`

```ts
const KAPPA: 0.4
```

### LATENT_FUSION

*const* · `packages/physics-response/src/laws/constants.ts:12`

```ts
const LATENT_FUSION: 334000
```

### NU_AIR

*const* · `packages/physics-response/src/laws/constants.ts:7`

```ts
const NU_AIR: 0.0000146
```

### NU_WATER

*const* · `packages/physics-response/src/laws/constants.ts:8`

```ts
const NU_WATER: 0.00000114
```

### PLATE_CD

*const* · `packages/physics-response/src/laws/flakes.ts:7`

```ts
const PLATE_CD: 1.17
```

### PR_AIR

*const* · `packages/physics-response/src/laws/constants.ts:10`

```ts
const PR_AIR: 0.71
```

### RHO_AIR

*const* · `packages/physics-response/src/laws/constants.ts:5`

```ts
const RHO_AIR: 1.225
```

### RHO_SAND

*const* · `packages/physics-response/src/laws/bed.ts:6`

```ts
const RHO_SAND: 2650
```

