A huge numebr of math functions to complement crayta Api.

Many functions are made for animation with support for easing curves and functions to mix , modify and chain them together.

To access it from every script using Ly.Math LyFramework with properly setupped LyRequire is needed.

After installing you need to add it to LyFramework subfolder lib see LyRequire Documentation.

**toDeg**(rad)

converts radians to degrees

**toRad**(deg)

converts degrees to radians

**sinByRate**(val)

continuous sin curve -1 to 1 more conventient than simple sin as it loops at integer values.

**cosByRate**(val)

same as sin but offsetted using cos in place of sin cosByRate(0) == sinByRate(0.25)

more conventient than simple cos as it loops at integer values.

**roundBy**(by,val)

snaps to the nearest multiple of 1 / by

**snapTo**(to,val)

snaps to the nearest multiple of to

**map**(val, fromMin, fromMax, toMin, toMax)

remaps ranges from to

**fitTo01**(val, min, max)

it clamps to min and max and maps to 0 1

**revert**(val)

nearestCardinal(deg)

smoothstep(t)

**hsl2Color**(h, s, l, a)

convert hsl color to Color hsl is more flexible in animation than rgb

Easing in out and InOut for

sin, quad, cubic quartic , quintic , expo , circ , back, bounce, elastic

```
local m = Ly.Math
local newZ = m.lerp(startZ, endZ, m.backInOut(t))
```

Anim and Interpolation Modifiers.

- lerp(t, from, to) – include due to different args order and to ease jit inlining, but you can still use math.lerp(from, to, t)
- inverseLerp(val, from, to)
- loop(t, from, to)
- shake(rate, center, [rndFunc = math.random])
- mix(t, f1, f2, [w = 0.5])
- crossFade(t, f1, f2, wf, w1, w2)
- chain(t, f1, f2, mergePoint, mergeValue)
- switch(t, f1, f2, [switchPoint = 0.5])
- yoyo(t, f)
- zigzag(t, f)