Skip to content

Instantly share code, notes, and snippets.

@viktorasm
Created November 12, 2020 18:47
Show Gist options
  • Save viktorasm/11f11c2fe29ad615702075ea51575cb7 to your computer and use it in GitHub Desktop.
Save viktorasm/11f11c2fe29ad615702075ea51575cb7 to your computer and use it in GitHub Desktop.
linear-to-smooth curve mapping, based on a paper https://arxiv.org/abs/2010.09714
def curve_mapping(x, s, t):
"""
provides a linear-to-smooth curve mapping
based on a paper https://arxiv.org/abs/2010.09714
"""
epsilon = 0.000001
if x < 0:
return 0
if x > 1:
return 1
if x < t:
return (t * x) / (x + s * (t - x) + epsilon)
return ((1 - t) * (x - 1)) / (1 - x - s * (t - x) + epsilon) + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment