Guest User

Untitled

a guest
May 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public float Smooth(float start, float end, float amount)
  2. {
  3. // Clamp to 0-1;
  4. amount = (amount > 1f) ? 1f : amount;
  5. amount = (amount < 0f) ? 0f : amount;
  6.  
  7. // Cubicly adjust the amount value.
  8. amount = (amount * amount) * (3f - (2f * amount));
  9.  
  10. return (start + ((end - start) * amount));
  11. }
  12.  
  13. amount = (amount * amount) * (3f - (2f * amount));
  14.  
  15. cubic(t) = cubic interpolation
  16. linear(t) = linear interpolation
  17. cubic_to_linear(t) = linear(t)*t + cubic(t)*(1-t)
  18. linear_to_cubic(t) = cubic(t)*t + linear(t)*(1-t)
Add Comment
Please, Sign In to add comment