Expand description
Functionsยง
- abs_sub
- Saturating subtraction:
max(0, a - b). - bilinear
- Bilinear interpolation between four corner values.
- cbrt
- Cube root of
x. - clamp
- Clamp
xinto[lo, hi]. - clamp01
- Clamp
xinto[0, 1]. - clamp11
- Clamp
xinto[-1, 1]. - copysign
- Copy the sign of
bto the magnitude ofa. - cumprod
- Cumulative product of a slice. Returns an empty vector for an empty input.
- cumsum
- Cumulative sum of a slice. Returns an empty vector for an empty input.
- deg_
to_ grad - Convert degrees to gradians.
- deg_
to_ rad - Convert degrees to radians.
- distance
- Distance between two values:
|a - b|. - dot_
product - Dot product of two slices. Returns
T::zero()if either is empty. Truncates to the shorter length if they differ. - frac
- Fractional part toward zero:
x - trunc(x). - fract
- Fractional part:
x - floor(x). Negative inputs give[0, 1). - grad_
to_ deg - Convert gradians to degrees (1 gradian = 0.9 degrees).
- grad_
to_ rad - Convert gradians to radians.
- hypot2
- Overflow-safe
sqrt(a^2 + b^2), generic over reals. - hypot3
- Overflow-safe
sqrt(a^2 + b^2 + c^2), generic over reals. - integer_
part - Integer part:
floor(x). - inv_
lerp - Inverse linear interpolation: find
tsuch thatlerp(a, b, t) == x. - is_
between - Returns
trueifxis within[lo, hi](inclusive). - is_
sorted - Check if a slice is sorted in non-decreasing order.
- lerp
- Linear interpolation between
aandb. - lerp_
angle - Shortest-path angular interpolation between
aandbin radians. - lerp_
clamped - Linear interpolation with
tclamped to[0, 1]. - lerp_
inv - Inverse linear interpolation: find
tsuch thatlerp(a, b, t) == x. - map_
range - Map a value from one range to another.
- max_
value - Maximum value in a slice. Returns
Nonefor an empty slice. - mean
- Mean (average) of a slice. Returns
Nonefor an empty slice. - midpoint
- Overflow-safe midpoint:
(a + b) / 2without intermediate overflow. - min_
value - Minimum value in a slice. Returns
Nonefor an empty slice. - normalize
- Normalize a vector (represented as a slice) to unit length.
- nth_
root n-th root ofx(any realn).- ping_
pong - Ping-pong: triangle wave between 0 and
length. - product
- Product of a slice. Returns
T::one()for an empty slice. - rad_
to_ deg - Convert radians to degrees.
- rad_
to_ grad - Convert radians to gradians.
- remap
- Remap
xfrom range[in_lo, in_hi]to[out_lo, out_hi]. - remap_
clamped - Remap
xfrom[in_lo, in_hi]to[out_lo, out_hi]with output clamped. - repeat
- Repeat
xinto[0, length). - sign
- Sign as integer: -1, 0, or 1.
- smootherstep
- Smootherstep: C2 interpolation with zero derivatives at both ends.
- smoothstep
- Smoothstep: C1 interpolation with zero derivatives at both ends.
- smoothstep_
between - Parameterized smoothstep: C1 interpolation between
edge0andedge1. - snap
- Snap
xto the nearest multiple ofstep. - step
- Heaviside step function:
0ifx < edge,1ifx >= edge. - sum
- Sum of a slice. Returns
T::zero()for an empty slice. - trunc
- Truncate toward zero.
- wrap
- Wrap
xinto the half-open interval[lo, hi). - wrap_
angle - Normalize an angle in radians to
[-pi, pi]. - wrap_
angle_ positive - Wrap angle in radians to
[0, 2pi).