Wraps value into the range [min, max), looping around at either end. repeat is the min = 0 special case. Expects min < max.
value
[min, max)
repeat
min = 0
min < max
A value already inside the range is returned unchanged, bit for bit.
wrap(370, 0, 360) // 10wrap(-10, 0, 360) // 350wrap(4, -Math.PI, Math.PI) // 4 - 2π Copy
wrap(370, 0, 360) // 10wrap(-10, 0, 360) // 350wrap(4, -Math.PI, Math.PI) // 4 - 2π
Inspired by Godot's wrapf: https://godot-rust.github.io/docs/gdext/master/godot/global/fn.wrapf.html
wrapf
Wraps
valueinto the range[min, max), looping around at either end.repeatis themin = 0special case. Expectsmin < max.A value already inside the range is returned unchanged, bit for bit.