Created
May 19, 2021 16:26
-
-
Save behreajj/f25db245580aaa776ff3fb677b773b92 to your computer and use it in GitHub Desktop.
Easing Function Definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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