Easing function definition

#1

Hi there!

I have to synchronize some sfx’s with a bouncing object. I am using “EASING_OUTBOUCE” as easing function. So I need the math definition of this easing function in order to play the sfx at the right moment… Do you know where to find such definition?

Thanks!

1 Like

#2

For the visual representation, there are images in the documentation.

As for the implementation, you’ll find the values here

2 Likes

#3

thanks @Mathias_Westerdahl

I need to know the times when value == final value. If I understand correctly this is when the number in the list you pointed me at is (about) 1.0. And it seems to me that there are 64 samples for each curves. Is this correct?

0 Likes

#4

Yes. 64 values, evenly spread out between t=0.0 and t=1.0

2 Likes

#5

And indeed it works perfectly! Just curious: where are you found those curves? Are them documented somewhere?

1 Like

#6

Good question.
I’ve always thought the were hand polished somehow (given some math function), but looking further, I found the gen_easing.cpp

Looking inside that old code, it indeed uses QEasingCurve

2 Likes

#7

Thanks! This explanation I found there:

Easing curve for a bounce (exponentially decaying parabolic bounce) function

exactly defines the function (up to some constants… to be honest… :slight_smile: )

0 Likes

#8

The easing functions were popularised in Flash by Robert Penner:

http://robertpenner.com/easing/

They can now be found everywhere and in many engines and frameworks. There are many sites which visualise the easing functions. Example: https://easings.net/

1 Like

#9

@britzl thank you so much! Following the page of Robert Penner you suggested I found some github code (https://github.com/jesusgollonet/ofpennereasing) with a c++ code that computes the easing functions. Of course the tables @Mathias_Westerdahl suggested is sufficient for my needs, but now I know how to generate these functions and their exact definitions. Very interesting!

0 Likes

#10

To avoid duplicating the code, it’s possible to get the t value, if you animate between 0 and 1, for the desired duration.

Here’s an example (Click View source to see the log output)

1 Like

#11

thanks @Mathias_Westerdahl but I am not sure I understand your suggestion… Here it is my code for the synchronization. It is quite hardwired but it seems to work:

    local T = 1.5
	go.animate(".", "position.y", go.PLAYBACK_ONCE_FORWARD, - 100.0, go.EASING_OUTBOUNCE, T)		
	local DTS = { 23, 46, 57, 63 }
	for i = 1, #DTS do
		local t = DTS[i] * t / 63.0
		timer.delay(t, false, function() print("Boing")  end)
	end

I have deduced the numbers 23, 46, 57, 63 form the table in the source you pointed me at! I know it is not an example of beautiful code… sorry :frowning: but it is quite simple…

1 Like