Created
August 4, 2015 15:34
-
-
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.
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 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