Math Utilities
Math Utilities
Numeric helpers Verse lacks out of the box: Modulo, ClampInt/Float, SafeDivide, RoundTo, LerpFloat, and a zero-safe vector SafeNormalize.
Original, compile-verified Verse by Bizanator (Biloxi Studios). Clean-room sample you can drop into a UEFN project and adapt.
-
# Math Utilities — Biloxi Studios Inc. # # Generic numeric helpers Verse doesn't ship out of the box: integer modulo, # clamping, safe division, rounding to N decimals, linear interpolation, and a # zero-safe vector normalize. Dependency-free. # # Teaches: <decides>/<transacts> effects, Int[]/Round[]/Floor[] failable casts, # guarding division by zero, and basic vector math. using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/SpatialMath } math_utils<public> := module: # Integer modulo (remainder). Verse has no `%` operator, so we derive it from # integer division. Returns 0 when Divisor is 0 rather than failing. Modulo<public>(Dividend:int, Divisor:int)<transacts>:int = if (Divisor <> 0, Q := Quotient[Dividend, Divisor]): return Dividend - Q * Divisor 0 # Clamp an int into [Low, High]. ClampInt<public>(Value:int, Low:int, High:int)<transacts>:int = Max(Low, Min(Value, High))
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.