flat assembler
Message board for the users of flat assembler.
Index
> Heap > [SOLVED] Help defining function from an image. 
Author 

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. Last edited by Madis731 on 12 Jul 2012, 12:13; edited 1 time in total 

07 May 2012, 10:13 

revolution
Madis731 wrote: What would define the graph above with the least effort? 

07 May 2012, 10:46 

revolution
Madis731 wrote: What would define the graph above with the least effort? 

07 May 2012, 10:55 

Madis731
Yes, I thought about the lookuptable. If my timeframe is one second and I assume my eyes cannot see beyond 24Hz, then a simple 40ms timer and a 25length lookup will do.
EDIT: http://upload.wikimedia.org/wikipedia/commons/c/c1/Bezier_3_big.png I think the 4point Beziercurve 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+%282x1%29%5E3%2B1+from+0+to+1 EDIT3: ...or the other way: http://www.wolframalpha.com/input/?i=y+%3D+xx%2832x%29+from+0+to+1 Seems to be called "easein/easeout" 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
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
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
Tomasz Grysztar wrote: I would propose a hyperbolic tangent, however it is not a polynomial, so I won't. 

07 May 2012, 13:07 

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 

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 http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf (2nd page, 1st paragraph and a graph just below that) 

12 Jul 2012, 12:12 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar. Also on YouTube, Twitter.
Website powered by rwasa.