Discussion:
Reverse of a "slow-in" function?
(too old to reply)
Bint
2014-01-10 21:35:42 UTC
Permalink
This is more of a math question but maybe someone knows the answer.
Sometimes I have a value which ranges from 0-1, and I want to take a linear
value and remap it to a "slow-in" or "slow-out" value.

The "slow-in" value is just a squared curve, so if r is between 0 and 1,
then the "slow-in" version is r*r. And the reverse of that is sqrt(r).

The "slow-out" value is more complicated: 1.0-(1.0-r)*(1.0-r)

My question is, what is the equivalent inverse of this function, as sqrt(r)
is to r*r?

Thanks!
B
Hans-Bernhard Bröker
2014-01-10 22:46:17 UTC
Permalink
Post by Bint
The "slow-out" value is more complicated: 1.0-(1.0-r)*(1.0-r)
My question is, what is the equivalent inverse of this function, as sqrt(r)
is to r*r?
Simple algegra yields

1 - sqrt(1-r)
Bint
2014-01-10 23:32:50 UTC
Permalink
Thanks for answering my question!
B
Daniel Pitts
2014-01-10 23:20:37 UTC
Permalink
Post by Bint
This is more of a math question but maybe someone knows the answer.
Sometimes I have a value which ranges from 0-1, and I want to take a linear
value and remap it to a "slow-in" or "slow-out" value.
The "slow-in" value is just a squared curve, so if r is between 0 and 1,
then the "slow-in" version is r*r. And the reverse of that is sqrt(r).
The "slow-out" value is more complicated: 1.0-(1.0-r)*(1.0-r)
My question is, what is the equivalent inverse of this function, as sqrt(r)
is to r*r?
Thanks!
B
Someone else told you algebra solved it for you. Here's how it works:

Original function so:
a) so=1.0-(1.0-r)*(1.0-r)
Do the multiplication.
b) so=1.0 - (1.0 - 2r + r²)
Distribute the minus
c) so=1.0 - 1.0 + 2r - r²
Combine like terms
d) so=-r² +2r
Since there is an r², you know its quadratic. Get a 0 on one side:
e) r² - 2r - so = 0
Apply the quadratic equation:
f) r = (-(-2)±√((-2)² -4(1*so))/2(1)
Simplify
g) r = (2±√(4 - 4so))/2
Factor out a 4
h) r = (2±√4(1 - 1so))/2
Square root of n²*x is n*√x
h) r = (2±2√(1 - 1so))/2
Do the divide
i) r = 1±√(1 - 1so)

Two different r values could correspond to your slow-out value, however,
you know it must be between 0 and 1, and that √(1 - 1so) must be
positive. Since you have a 1± a positive number, you'll need to choose
- to keep it below 1.


Yay, algebra is fun.
Bint
2014-01-13 23:59:07 UTC
Permalink
It turns out that the square function does not give me as much of a slow
down at the beginning as I would like.

I'm sorry, I'm not very good at algebra -- is it as easy to find the inverse
of the function if I add a third (1.0-r)? So, y = 1.0 -
(1.0-r)*(1.0-r)*(1.0-r)?

Thanks
B
Post by Daniel Pitts
Post by Bint
This is more of a math question but maybe someone knows the answer.
Sometimes I have a value which ranges from 0-1, and I want to take a linear
value and remap it to a "slow-in" or "slow-out" value.
The "slow-in" value is just a squared curve, so if r is between 0 and 1,
then the "slow-in" version is r*r. And the reverse of that is sqrt(r).
The "slow-out" value is more complicated: 1.0-(1.0-r)*(1.0-r)
My question is, what is the equivalent inverse of this function, as sqrt(r)
is to r*r?
Thanks!
B
a) so=1.0-(1.0-r)*(1.0-r)
Do the multiplication.
b) so=1.0 - (1.0 - 2r + r²)
Distribute the minus
c) so=1.0 - 1.0 + 2r - r²
Combine like terms
d) so=-r² +2r
e) r² - 2r - so = 0
f) r = (-(-2)±√((-2)² -4(1*so))/2(1)
Simplify
g) r = (2±√(4 - 4so))/2
Factor out a 4
h) r = (2±√4(1 - 1so))/2
Square root of n²*x is n*√x
h) r = (2±2√(1 - 1so))/2
Do the divide
i) r = 1±√(1 - 1so)
Two different r values could correspond to your slow-out value, however,
you know it must be between 0 and 1, and that √(1 - 1so) must be
positive. Since you have a 1± a positive number, you'll need to choose
- to keep it below 1.
Yay, algebra is fun.
Scott Hemphill
2014-01-15 00:22:45 UTC
Permalink
Post by Bint
It turns out that the square function does not give me as much of a slow
down at the beginning as I would like.
I'm sorry, I'm not very good at algebra -- is it as easy to find the inverse
of the function if I add a third (1.0-r)? So, y = 1.0 -
(1.0-r)*(1.0-r)*(1.0-r)?
[snip]

Re-write your equation as:

1-y = (1-r)^3

So (1-y)^(1/3) = 1-r, and

r = 1 - (1-y)^(1/3)

The same steps work for higher powers, too.

Scott
--
Scott Hemphill ***@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
M.F.
2014-01-15 01:05:12 UTC
Permalink
Post by Bint
This is more of a math question but maybe someone knows the answer.
Sometimes I have a value which ranges from 0-1, and I want to take a linear
value and remap it to a "slow-in" or "slow-out" value.
The "slow-in" value is just a squared curve, so if r is between 0 and 1,
then the "slow-in" version is r*r. And the reverse of that is sqrt(r).
The "slow-out" value is more complicated: 1.0-(1.0-r)*(1.0-r)
My question is, what is the equivalent inverse of this function, as sqrt(r)
is to r*r?
Thanks!
B
The mapping between your "slow-in" version and "slow-out" version is
(x, y) => (t=1-x, z=1-y)

Given y = f(x), you want to find the relation z=g(t). It is trivial,
z=1-y=1-f(x)=1-f(1-t). You can see the pattern from the aforementioned
squared curve.

As a relatively more complicated example, when the "slow-in" function is
f(x)= x^(1/4)+x^(1/3)+x(1/2),
it follows immediately that the "slow-out" version is
g(t)=1-(1-t)^(1/4)-(1-t)^(1/3)-(1-t)^(1/2).

Loading...