Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. def cubic_dead_zone_func(dead_zone, expo_level):
  2. """
  3. Change input axis to be on "expo curve" with a dead zone. Makes the input somewhere
  4. between linear and cubic.
  5.  
  6. Args:
  7. dead_zone (float, [0, 1)): The amount of input for which there is 0 output.
  8. expo_level (float, [0, 1]): Interpolates between a linear and cubic curve. Cubic when
  9. expo_level is 0; linear when expo_level is 1.
  10. Returns:
  11. A function with a single argument (float, [-1, 1]) and output (float, [-1, 1])
  12. """
  13.  
  14. def func(x):
  15. sgn = -1 if x < 0 else 1
  16.  
  17. if abs(x) < dead_zone:
  18. return 0.
  19. scaled_x = sgn * (abs(x) - dead_zone) / (1. - dead_zone)
  20.  
  21. return expo_level * scaled_x + (1. - expo_level) * pow(scaled_x, 3)
  22.  
  23. return func
  24. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement