flat assembler
Message board for the users of flat assembler.

 Index > Heap > [SOLVED] Help defining function from an image.
Author

Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
http://jext.free.fr/display1.png

I need to interpolate (but not lerp) a number (a coordinate) at timesteps from 0 to 1.
What would define the graph above with the least effort?

Simple description: a point (x) starts to move from, lets say, 100 and arrives at 200. It should move the fastest at 150 and the slowest at 100 and 200.

Thanks!

PS. What I gather from the image and wiki, I need at least 4 points and interpolate between them.

_________________
My updated idol http://www.agner.org/optimize/

Last edited by Madis731 on 12 Jul 2012, 12:13; edited 1 time in total
07 May 2012, 10:13
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17474
revolution
What would define the graph above with the least effort?
Tan?
07 May 2012, 10:46

Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Okay I correct my mistake and define a bit further. I wish for a polynomial function and I don't think tangent is continuous at -inf / +inf. I'm scared the tangent solution is too astable.
07 May 2012, 10:52
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17474
revolution
What would define the graph above with the least effort?
A lookup table. Very little effort needed.
07 May 2012, 10:55

Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Yes, I thought about the lookup-table. If my timeframe is one second and I assume my eyes cannot see beyond 24Hz, then a simple 40ms timer and a 25-length lookup will do.

I think the 4-point Bezier-curve implementation will not be simpler or better performing.

EDIT2: This is interesting, but I don't think its steep enough.
http://www.wolframalpha.com/input/?i=y+%3D+%282x-1%29%5E3%2B1+from+0+to+1

EDIT3: ...or the other way: http://www.wolframalpha.com/input/?i=y+%3D+xx%283-2x%29+from+0+to+1
Seems to be called "ease-in/ease-out" what I was looking for - http://forums.create.msdn.com/forums/p/15365/80653.aspx - answer is somewhere in the middle.
07 May 2012, 11:00
MHajduk

Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
Yeah, Madis, taking a cubic parabola into consideration was a good idea, IMO. But I would go even further - to approximate the given curve I would consider functions of the form

f(x) = x^(2k + 1)

where exponent 2k+1 is always odd for every natural k. The bigger exponent you'll take, the more "squared" ("angular" - I don't know how to describe it properly) curve you will obtain. Surely, you have to translate these parabolas along x and y axes.

I suggest you to consider properly translated f(x) = x^5 or f(x) = x^7 parabolas.
07 May 2012, 12:56
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7755
Location: Kraków, Poland
Tomasz Grysztar
I would propose a hyperbolic tangent, however it is not a polynomial, so I won't.

However I have myself used hyperbolic functions for the purposes of smooth UI, because they have many nice properties.
07 May 2012, 13:02
MHajduk

Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
Tomasz Grysztar wrote:
I would propose a hyperbolic tangent, however it is not a polynomial, so I won't.

However I have myself used hyperbolic functions for the purposes of smooth UI, because they have many nice properties.
Area tangent looks good, but it also isn't polynomial.

07 May 2012, 13:07
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7755
Location: Kraków, Poland
Tomasz Grysztar
I think I did actually mean the hyperbolic sine. At least that's the one I've been really using.
07 May 2012, 13:12

Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Just to post some finishing thoughts and not leave this topic hanging.

I actually ended up with 3t²-2t³ and forgot about it until today, reading again about the Simplex Noise topic and Googleing around, I found the same formula defined a long time ago
http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf (2nd page, 1st paragraph and a graph just below that)
12 Jul 2012, 12:12
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum