UnitIntervalModule
PackageReified.Refinements
Operations over proportions between zero and one.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| bounds | UnitInterval.bounds | The interval this type is confined to. |
| constraint' | UnitInterval.constraint' | The portable constraint admitting only values in [0, 1]. |
| refinement | UnitInterval.refinement | No description available. |
| value | UnitInterval.value input | Returns the underlying value. |
| create | UnitInterval.create value | Admits a proportion, rejecting anything outside [0, 1] including NaN. |
| zero | UnitInterval.zero | Zero, the lower bound. |
| one | UnitInterval.one | One, the upper bound and the multiplicative identity. |
| half | UnitInterval.half | The midpoint. |
| clamp | UnitInterval.clamp value | Restricts any double into [0, 1]. |
| complement | UnitInterval.complement input | Returns the distance to one. |
| multiply | UnitInterval.multiply left right | Multiplies two proportions. |
| min | UnitInterval.min left right | Returns the smaller proportion. |
| max | UnitInterval.max left right | Returns the larger proportion. |
| saturatingAdd | UnitInterval.saturatingAdd left right | Adds, clamping at one. |
| saturatingSubtract | UnitInterval.saturatingSubtract left right | Subtracts, clamping at zero. |
| lerp | UnitInterval.lerp low high proportion | Interpolates between two values by this proportion. |
| lerpInterval | UnitInterval.lerpInterval interval proportion | Interpolates across an interval, landing inside it by construction. |
| inverseLerp | UnitInterval.inverseLerp low high value | Returns the proportion a value sits at between two bounds — the inverse of lerp. |
| inverseLerpInterval | UnitInterval.inverseLerpInterval interval value | Returns the proportion a value sits at within an interval. |
| toFiniteFloat | UnitInterval.toFiniteFloat input | Widens to a finite double. |
The portable constraint admitting only values in
[0, 1].Returns
Constraint<float>
Returns the underlying value.
Parameters
| Name | Type | Description |
|---|---|---|
| input | UnitInterval |
Returns
float
Admits a proportion, rejecting anything outside
[0, 1] including NaN.Parameters
| Name | Type | Description |
|---|---|---|
| value | float |
Returns
Result<UnitInterval, Violation>
Restricts any double into
[0, 1]. Total, including for NaN, which
clamps to zero because it has no meaningful position in the range.
Parameters
| Name | Type | Description |
|---|---|---|
| value | float |
Returns
UnitInterval
Returns the distance to one. Total and closed.
Parameters
| Name | Type | Description |
|---|---|---|
| input | UnitInterval |
Returns
UnitInterval
Multiplies two proportions. Total and closed — this is the operation the type
exists for, and the only closed multiplication in the package.
Parameters
| Name | Type | Description |
|---|---|---|
| left | UnitInterval | |
| right | UnitInterval |
Returns
UnitInterval
Returns the smaller proportion. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| left | UnitInterval | |
| right | UnitInterval |
Returns
UnitInterval
Returns the larger proportion. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| left | UnitInterval | |
| right | UnitInterval |
Returns
UnitInterval
Adds, clamping at one. Total — the range is not closed under addition.
Parameters
| Name | Type | Description |
|---|---|---|
| left | UnitInterval | |
| right | UnitInterval |
Returns
UnitInterval
Subtracts, clamping at zero. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| left | UnitInterval | |
| right | UnitInterval |
Returns
UnitInterval
Interpolates between two values by this proportion. Total, and guaranteed to stay
within the two endpoints because the proportion cannot leave
[0, 1].
Parameters
| Name | Type | Description |
|---|---|---|
| low | float | |
| high | float | |
| proportion | UnitInterval |
Returns
float
Interpolates across an interval, landing inside it by construction.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<float> | |
| proportion | UnitInterval |
Returns
float
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
| Name | Type | Description |
|---|---|---|
| low | float | |
| high | float | |
| value | float |
Returns
UnitInterval
Returns the proportion a value sits at within an interval. Total.
Parameters
| Name | Type | Description |
|---|---|---|
| interval | Interval<float> | |
| value | float |
Returns
UnitInterval