# Math for ease in/out?

### » Sat Jan 09, 2010 8:55 pm

I want to use lerp to move from point a to b - but it results in instant accelleration/deceleration. I want to have something accellerated smoothly until 50% of larp and decellerate smoothly to 100%. Anyone know the math for this?
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

### » Sat Jan 09, 2010 9:04 pm

The way I achieve this is by using Cubic(a, b, c, d, x) instead of Lerp(a, b, x). Just set "a" and "b" in Cubic to what you set "a" to in Lerp and "c" and "d" to what you set "b" to and you should get the smooth movement you want. So basically:

Cubic(a, a, b, b, x).

I hope I explained that well enough.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

### » Sat Jan 09, 2010 9:12 pm

Wow - what a nice solution! I thought it would be some crazy math. Thanks!
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

### » Sat Jan 09, 2010 9:42 pm

Or Cosine. It only needs two points.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

### » Sat Jan 09, 2010 10:40 pm

...

I really shouldn't be surprised anymore when I find out construct already has something built in. Yet it keeps surprising me. Awesome!
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

### » Sun Jan 10, 2010 2:26 am

cosp()
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

### » Sun Jan 10, 2010 9:57 am

[quote="Davioware":3da4l6re]cosp()[/quote:3da4l6re]

?

Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461