Total Complexity | 6 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from math import sin, cos, tan |
||
2 | from math import asin, acos, atan |
||
3 | from math import sinh, cosh, tanh |
||
4 | from math import asinh, acosh, atanh |
||
5 | from math import atan2 |
||
6 | |||
7 | from math import sqrt |
||
8 | |||
9 | from math import pi as PI |
||
10 | from math import tau as TAU |
||
11 | from math import e as E |
||
12 | |||
13 | from random import random as py_random |
||
14 | |||
15 | |||
16 | def random(x=1): |
||
17 | return py_random() * x |
||
18 | |||
19 | |||
20 | def clamp(value, min, max): |
||
21 | return (value <= min)*min + (value >= max)*max + value*(value > min and value < max) |
||
22 | |||
23 | |||
24 | def lerp_unclamped(start, end, t): |
||
25 | return start + t*(end-start) |
||
26 | |||
27 | |||
28 | def lerp(start, end, t): |
||
29 | value = lerp_unclamped(start, end, t) |
||
30 | return clamp(value, start, end) |
||
31 | |||
32 | |||
33 | def mix(a, b, t): |
||
34 | return lerp(a, b, t) |
||
35 | |||
36 | |||
37 | def remap(n, start1, stop1, start2, stop2): |
||
38 | return ((n-start1)/(stop1-start1))*(stop2-start2)+start2 |
||
39 |