2

I'm developing a control program for a Quadrocopter (AR Drone) under C# I want to ease the input from keyboards (Which do not have axes like joysticks)...

So i need a collection of methods that the user can choose from with different kind of easings.

slezadav
  • 6,104
  • 7
  • 40
  • 61
Anders
  • 17,306
  • 10
  • 76
  • 144
  • What is your problem/question? Easing functions are not hard to write. What did you try? – Emond May 26 '11 at 08:52
  • Yeahx, offcourse i can. I have made a few, a sinuscurve one, a linear one. But it would be cool with some others i thought maybe there were a colletion somewhere :) – Anders May 26 '11 at 13:03

2 Answers2

2

Made these simplified algorithms to filter any kind of normalized signal.

http://github.com/eppz/eppz.easing

enter image description here

// Linear
y = x

// Ease_In
y = x^2

// Ease_In_2
y = x^3

// Ease_In_3
y = x^8

// Ease_Out
y = 1-(1-x)^2

// Ease_Out_2
y = 1-(1-x)^3

// Ease_Out_3
y = 1-(1-x)^8

// Ease_In_Out
y = (x<0.5) ? (2x)^2/2 : 0.5+(1-(2(1-x))^2)/2
y = (x<0.5) ? 2x^2 : -2x^2+4x-1

// Ease_In_Out_2
y = (x<0.5) ? (2x)^3/2 : 0.5+(1-(2(1-x))^3)/2
y = (x<0.5) ? 4x^3 : 4x^3-12x^2+12x-3

// Ease_In_Out_3
y = (x<0.5) ? (2x)^8/2 : 0.5+(1-(2(1-x))^8)/2
y = (x<0.5) ? 128x^8 : 0.5+(1-(2(1-x))^8)/2

// Ease_In_Circular
y = 1-sqrt(1-x^2)

// Ease_Out_Circular
y = sqrt(1-(1-x)^2)
y = sqrt(-(x-2)x)

// Ease_In_Out_Circular
y = (x<0.5) ? (1-sqrt(1-(2x)^2))/2 : 0.5+sqrt(1-((2(1-x))^2))/2
y = (x<0.5) ? 0.5(1-sqrt(1-4x^2)) : 0.5(sqrt(-4(x-2)x-3)+1)

// Ease_In_Bounce
y = 2x^3-x^2
y = x^2(2x-1)

// Ease_In_Bounce_2
y = 3x^3-2x^2
y = x^2(3x-2)

// Ease_In_Bounce_3
y = 4x^3-3x^2
y = x^2(4x-3)

// Ease_Out_Bounce
y = 1-(2(1-x)^3-(1-x)^2)
y = x(x(2x-5)+4)

// Ease_Out_Bounce_2
y = 1-(3(1-x)^3-2(1-x)^2)
y = x(x(3x-7)+5)

// Ease_Out_Bounce_3
y = 1-(4(1-x)^3-3(1-x)^2)
y = x(x(4x-9)+6)

// Ease_In_Out_Bounce
y = (x<0.5) ? (2(2x)^3-(2x)^2)*0.5 : 1-(2(2(1-x))^3-(2(1-x))^2)*0.5
y = (x<0.5) ? 8x^3-2x^2 : 8x^3-22x^2+20x-5

// Ease_In_Out_Bounce_2
y = (x<0.5) ? (3(2x)^3-2(2x)^2)*0.5 : 1-(3(2(1-x))^3-2(2(1-x))^2)*0.5
y = (x<0.5) ? 12x^3-4x^2 : 12x^3-32x^2+28x-7

// Ease_In_Out_Bounce_3
y = (x<0.5) ? (4(2x)^3-3(2x)^2)*0.5 : 1-(4(2(1-x))^3-3(2(1-x))^2)*0.5
y = (x<0.5) ? 16x^3-6x^2 : 16x^3-42x^2+36x-9
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
  • Percentages (0-1), but matter of implementation anyway. Easily convert output from 0..1 to -1..1 by `output = output*2-1`. I more often find myself working with percentages under the hood, (0..1) then convert it to any kind of output. – Geri Borbás Dec 04 '14 at 14:01
  • Just to be clear, Lets say we have input from -1000 to 1000 before sending that into your functions I should convert to 0 to 1. correct? :D Also, some of these have two functions i guess the first is in and the second is out? thanks – Anders Dec 04 '14 at 14:40
  • Yap. `normalizedInput = (input + 1000) / 2000; output = normalizedOutput * 2000 - 1000`. – Geri Borbás Dec 04 '14 at 17:06
  • In_Out equations has the two half. Could be combined into a single function, but would be slower with no real payout. – Geri Borbás Dec 04 '14 at 17:07
  • See https://github.com/eppz/eppz.easing/blob/master/Assets/EPPZEasing.cs for actual implementation. `x` is always meant to be 0-1. – Geri Borbás Dec 04 '14 at 17:08
  • Planning to hook in "amount" parameters instead of preset functions, also will implement sinusoidal easings sooner or later. – Geri Borbás Dec 04 '14 at 17:10
  • Second one is a bit simplified, bit less multiplication, result is just the same. You can always check each equation at http://fooplot.com/plot/48rvdgwpwj – Geri Borbás Dec 05 '14 at 15:29
1

iTween has quite a few of them and it's under the MIT license. You could try borrowing some from there.

Asgeir
  • 1,092
  • 1
  • 7
  • 11