Finite
SourceConstructor for Finite.
Data Structures
Validated scalar brands and pure scalar helpers.
This module is the numeric foundation for the branded geometry helpers. Plain number values enter through explicit constructors such as Finite and NonNegative. Once validated, downstream helpers operate only on branded values.
In game code this is useful whenever "just a number" is too weak: viewport sizes, speeds, distances, durations, and geometry values often need explicit non-negative or finite guarantees before they should be stored in the world.
// Validate raw numbers before geometry or gameplay code relies on them.
const speed = Scalar.Finite.result(12)
const limit = Scalar.Finite.result(8)
if (!speed.ok || !limit.ok) return
// Operate on the branded values after the boundary has been crossed.
const clamped = Scalar.clamp(speed.value, limit.value, speed.value)
Clamps one finite value between two finite bounds.
lerpInterpolates between two finite values by one finite amount.
approachMoves one finite value toward a target by at most one non-negative delta.
inverseLerpReturns the interpolation amount of one value within a finite input range.
remapRemaps one finite value from one input range to one output range.
Non-throwing validation boundaries for finite and constrained scalar values.
Pure scalar combinators that preserve branding after validation.
Clamps one finite value between two finite bounds.
The result stays branded because valid branded scalar input cannot produce an invalid scalar output.
Interpolates between two finite values by one finite amount.
The amount is not clamped. This stays a pure interpolation primitive rather than mixing interpolation with policy.
Moves one finite value toward a target by at most one non-negative delta.
Use this for explicit interpolation-style updates where overshooting the target should be impossible.
Returns the interpolation amount of one value within a finite input range.
Fails explicitly when the input range has zero size.
Remaps one finite value from one input range to one output range.
Fails explicitly when the input range has zero size.