flat assembler
Message board for the users of flat assembler.

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

Author
Thread Post new topic Reply to topic
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
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 Very Happy http://www.agner.org/optimize/


Last edited by Madis731 on 12 Jul 2012, 12:13; edited 1 time in total
Post 07 May 2012, 10:13
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17474
Location: In your JS exploiting you and your system
revolution
Madis731 wrote:
What would define the graph above with the least effort?
Tan?
Post 07 May 2012, 10:46
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
Okay Smile 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.
Post 07 May 2012, 10:52
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17474
Location: In your JS exploiting you and your system
revolution
Madis731 wrote:
What would define the graph above with the least effort?
A lookup table. Very little effort needed.
Post 07 May 2012, 10:55
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
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.

EDIT: http://upload.wikimedia.org/wikipedia/commons/c/c1/Bezier_3_big.png
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.
Post 07 May 2012, 11:00
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
Yeah, Madis, taking a cubic parabola into consideration was a good idea, IMO. Smile 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. Smile
Post 07 May 2012, 12:56
View user's profile Send private message Visit poster's website Reply with quote
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. Wink

However I have myself used hyperbolic functions for the purposes of smooth UI, because they have many nice properties.
Post 07 May 2012, 13:02
View user's profile Send private message Visit poster's website Reply with quote
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. Wink

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. Wink

Image
Post 07 May 2012, 13:07
View user's profile Send private message Visit poster's website Reply with quote
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.
Post 07 May 2012, 13:12
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
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 Smile
http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf (2nd page, 1st paragraph and a graph just below that)
Post 12 Jul 2012, 12:12
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.