mathWrap

Wraps a value within a range using modulo. Takes value (value to wrap), min (minimum bound), max (maximum bound). Returns the value wrapped into the range [min, max) using modulo arithmetic.

Mathematics

Parameters & Returns

Parameters

value Double
min Double
max Double

Returns

Double

Quick Summary

Wraps a value within a range using modulo. Takes value (value to wrap), min (minimum bound), max (maximum bound). Returns the value wrapped into the range [min, max) using modulo arithmetic.

Technical Exegesis...

Wraps value into the range [min, max) using modulo arithmetic. When value exceeds max, it wraps back to min. When value is below min, it wraps to near max.

Returns min if min equals max. Commonly used for circular coordinates, wrapping screen positions, or cyclic values like angles.

Example

Example.bam
; No example implemented yet