18

I am trying to create a nice ease-in-out function that given values from 0 - 1 produces an output of 0 - 1 which accelerates slowly up to full speed then slows down again as it nears 1.

I currently have a function using sine, in the form...

y=(sin(πx/2))2

This works ok, and gives me results in the range I require however it is too quick to reach the terminal velocity, I am looking for something which has a more gradual start / end and a steeper center (if that makes sense).

Any help would be appreciated!

CC BY-SA 3.0
3
  • You mean y=(sin(πx/2))2?
    – joriki
    Mar 18, 2012 at 15:43
  • Yes, this is from code hence the difference :) Have updated the question, thanks.
    – Simon Lee
    Mar 18, 2012 at 16:01
  • You get the right formatting for sin using \sin. If you just type sin, TEX interprets that as juxtaposed variable names and italicizes them. Also, you get equations in display style by using double dollar signs instead of single dollar signs.
    – joriki
    Mar 18, 2012 at 16:16

2 Answers 2

31

Something to try would be the parametrized function

fα(x)=xαxα+(1x)α
f1(x)=x and f2(x) looks like this

curve

As α gets bigger, the slope in the middle becomes greater and the ends at x=0 and x=1 become flatter. As α, the curve tends toward a step function.

These functions have the nice property that fafb=fab. Thus, fa and f1/a are inverses.

CC BY-SA 4.0
9
  • So much more intuitive than the "famous" Penner solutions! And can be coded much more succinctly, too! Thank you!
    – SMBiggs
    Apr 8, 2015 at 6:45
  • Is there a way to make similar function for "ease-in" effect, withiut "out"?
    – raacer
    Aug 9, 2015 at 19:29
  • @raacer: how would you like the function to look? I am not sure what you mean by "ease-in without ease-out".
    – robjohn
    Aug 10, 2015 at 14:08
  • @robjohn: I mean it should be exactly the same from 0 to 0.5, and then it should be continued as a straight line in the top right direction from 0.5 to the infinity.
    – raacer
    Aug 10, 2015 at 18:18
  • 1
    Note for use in software: Using this for ease in/out of a camera animation, I found even α = 2 to be too much easing. Rather than compute a fractional power such as 1.5, I did linear interpolation between x and f2(x): (1-w) * x + w * f2(x), where w is in (0..1) to give a range of functions with increasing amount of ease-in/out. Apr 20, 2018 at 9:50
8

You could also use a polynomial that's 0 at 0, 1 and 1 and has zero derivative at both ends; the unique polynomial of degree 3 with those properties is y=x2(32x).

In both of those functions, you can replace x by

u=12+arctan(α(x12))2arctanα2

and choose α to achieve the desired steepness, with α0 corresponding to u=x and α corresponding to a step function.

CC BY-SA 3.0
2
  • Perfect, many thanks for your help (with question formatting and answer!)
    – Simon Lee
    Mar 18, 2012 at 16:25
  • 1
    @Simon: if you think the answer is useful (and since you've accepted it, it seems you do), you might also want to upvote it (you can only accept one answer, but you can upvote as many as you like).
    – robjohn
    Mar 18, 2012 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .