Skip to content

Instantly share code, notes, and snippets.

@behreajj
Created May 19, 2021 16:26
Show Gist options
  • Save behreajj/f25db245580aaa776ff3fb677b773b92 to your computer and use it in GitHub Desktop.
Save behreajj/f25db245580aaa776ff3fb677b773b92 to your computer and use it in GitHub Desktop.
Easing Function Definitions
import bpy
import bmesh
import math
from mathutils import Vector
def lerp_vec_array(arr, step=0.5, easing_func=None):
len_arr = len(arr)
if len_arr == 0:
return Vector((0.0, 0.0, 0.0))
if len_arr == 1 or step <= 0.0:
return arr[0].copy()
if step >= 1.0:
return arr[len_arr - 1].copy()
t_scaled = step * (len_arr - 1)
i = int(t_scaled)
t = t_scaled - i
u = easing_func(t)
a = arr[i]
b = arr[i + 1]
return a.lerp(b, u)
def linear_step(t):
return t
def smooth_step(t):
return t * t * (3.0 - (t + t))
def smoother_step(t):
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment