Skip to content

Instantly share code, notes, and snippets.

@rhoadster91
Created August 4, 2015 15:34
Show Gist options
  • Select an option

  • Save rhoadster91/9da0d45dcf53fea4c4fa to your computer and use it in GitHub Desktop.

Select an option

Save rhoadster91/9da0d45dcf53fea4c4fa to your computer and use it in GitHub Desktop.
Interpolator that tends to (but never reaches) specified asymptotic value. Easing factor specifies how quickly it should approach the asymptote.
import android.view.animation.Interpolator;
public class TangentialInterpolator implements Interpolator {
private float asymptote = 1f;
private float easing = 1f;
public TangentialInterpolator(float asymptote, float easing) {
this.asymptote = asymptote;
this.easing = easing;
}
@Override
public float getInterpolation(float input) {
return asymptote * onPiByTwoScale(tanInverse(input));
}
private float onPiByTwoScale(float value) {
return (float) (value / (Math.PI / 2));
}
private float tanInverse(float value) {
return (float) Math.atan(easing * value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment