Passed
Pull Request — master (#6)
by Erik
52s
created

pypen.utils.math.random()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 1
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
def random(x=1):
16
    return py_random() * x
17
18
19
def clamp(value, min, max):
20
    return (value <= min)*min + (value >= max)*max + value*(value > min and value < max)
21
22
23
def lerp_unclamped(start, end, t):
24
    return start + t*(end-start)
25
26
27
def lerp(start, end, t):
28
    value = lerp_unclamped(start, end, t)
29
    return clamp(value, start, end)
30
31
32
def mix(a, b, t):
33
    return lerp(a, b, t)
34