UnitIntervalModule

PackageReified.Refinements
Operations over proportions between zero and one.

Summary

NameSignatureSynopsis
boundsUnitInterval.bounds The interval this type is confined to.
constraint'UnitInterval.constraint' The portable constraint admitting only values in [0, 1].
refinementUnitInterval.refinement No description available.
valueUnitInterval.value inputReturns the underlying value.
createUnitInterval.create valueAdmits a proportion, rejecting anything outside [0, 1] including NaN.
zeroUnitInterval.zero Zero, the lower bound.
oneUnitInterval.one One, the upper bound and the multiplicative identity.
halfUnitInterval.half The midpoint.
clampUnitInterval.clamp valueRestricts any double into [0, 1].
complementUnitInterval.complement inputReturns the distance to one.
multiplyUnitInterval.multiply left rightMultiplies two proportions.
minUnitInterval.min left rightReturns the smaller proportion.
maxUnitInterval.max left rightReturns the larger proportion.
saturatingAddUnitInterval.saturatingAdd left rightAdds, clamping at one.
saturatingSubtractUnitInterval.saturatingSubtract left rightSubtracts, clamping at zero.
lerpUnitInterval.lerp low high proportionInterpolates between two values by this proportion.
lerpIntervalUnitInterval.lerpInterval interval proportionInterpolates across an interval, landing inside it by construction.
inverseLerpUnitInterval.inverseLerp low high valueReturns the proportion a value sits at between two bounds — the inverse of lerp.
inverseLerpIntervalUnitInterval.inverseLerpInterval interval valueReturns the proportion a value sits at within an interval.
toFiniteFloatUnitInterval.toFiniteFloat inputWidens to a finite double.

bounds

UnitInterval.bounds
Member
The interval this type is confined to.

Returns

Interval<float>

constraint'

UnitInterval.constraint'
Member
The portable constraint admitting only values in [0, 1].

Returns

Constraint<float>

refinement

UnitInterval.refinement
Member

Returns

Refinement<float, UnitInterval>

value

UnitInterval.value input
Member
Returns the underlying value.

Parameters

NameTypeDescription
inputUnitInterval

Returns

float

create

UnitInterval.create value
Member
Admits a proportion, rejecting anything outside [0, 1] including NaN.

Parameters

NameTypeDescription
valuefloat

Returns

Result<UnitInterval, Violation>

zero

UnitInterval.zero
Member
Zero, the lower bound.

Returns

UnitInterval

one

UnitInterval.one
Member
One, the upper bound and the multiplicative identity.

Returns

UnitInterval

half

UnitInterval.half
Member
The midpoint.

Returns

UnitInterval

clamp

UnitInterval.clamp value
Member
Restricts any double into [0, 1]. Total, including for NaN, which clamps to zero because it has no meaningful position in the range.

Parameters

NameTypeDescription
valuefloat

Returns

UnitInterval

complement

UnitInterval.complement input
Member
Returns the distance to one. Total and closed.

Parameters

NameTypeDescription
inputUnitInterval

Returns

UnitInterval

multiply

UnitInterval.multiply left right
Member
Multiplies two proportions. Total and closed — this is the operation the type exists for, and the only closed multiplication in the package.

Parameters

NameTypeDescription
leftUnitInterval
rightUnitInterval

Returns

UnitInterval

min

UnitInterval.min left right
Member
Returns the smaller proportion. Total.

Parameters

NameTypeDescription
leftUnitInterval
rightUnitInterval

Returns

UnitInterval

max

UnitInterval.max left right
Member
Returns the larger proportion. Total.

Parameters

NameTypeDescription
leftUnitInterval
rightUnitInterval

Returns

UnitInterval

saturatingAdd

UnitInterval.saturatingAdd left right
Member
Adds, clamping at one. Total — the range is not closed under addition.

Parameters

NameTypeDescription
leftUnitInterval
rightUnitInterval

Returns

UnitInterval

saturatingSubtract

UnitInterval.saturatingSubtract left right
Member
Subtracts, clamping at zero. Total.

Parameters

NameTypeDescription
leftUnitInterval
rightUnitInterval

Returns

UnitInterval

lerp

UnitInterval.lerp low high proportion
Member
Interpolates between two values by this proportion. Total, and guaranteed to stay within the two endpoints because the proportion cannot leave [0, 1].

Parameters

NameTypeDescription
lowfloat
highfloat
proportionUnitInterval

Returns

float

lerpInterval

UnitInterval.lerpInterval interval proportion
Member
Interpolates across an interval, landing inside it by construction.

Parameters

NameTypeDescription
intervalInterval<float>
proportionUnitInterval

Returns

float

inverseLerp

UnitInterval.inverseLerp low high value
Member
Returns the proportion a value sits at between two bounds — the inverse of lerp. Clamped into range, so it is total. Degenerate bounds, where the two are equal, give zero rather than dividing by it.

Parameters

NameTypeDescription
lowfloat
highfloat
valuefloat

Returns

UnitInterval

inverseLerpInterval

UnitInterval.inverseLerpInterval interval value
Member
Returns the proportion a value sits at within an interval. Total.

Parameters

NameTypeDescription
intervalInterval<float>
valuefloat

Returns

UnitInterval

toFiniteFloat

UnitInterval.toFiniteFloat input
Member
Widens to a finite double. Total — every proportion is finite.

Parameters

NameTypeDescription
inputUnitInterval

Returns

FiniteFloat