Useful Functions: Difference between revisions

From David's Wiki
Created page with "Some basic math functions used for graphics. ===Lerp/Mix=== <syntaxhighlight lang="python"> def lerp(a, b, x): return (1.0 - x) * a + x * b def inv_lerp(a, b, t): r..."
 
 
Line 2: Line 2:




===Lerp/Mix===
===Lerp or Mix===
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
def lerp(a, b, x):
def lerp(a, b, x):

Latest revision as of 15:30, 24 May 2021

Some basic math functions used for graphics.


Lerp or Mix

def lerp(a, b, x):
    return (1.0 - x) * a + x * b

def inv_lerp(a, b, t):
    return (t - a) / (b - a)