Half sine?

» Thu Sep 09, 2010 6:35 am

Is there a way using an expression to get a half sine wave, point a to b, and back to a?
I thought about using a nested lerp...

lerp(.y,(lerp(original.y-100,original.y,blah*timedelta),blah*timedlta), but perhaps my timing was incorrect.
Anyway the idea was to do a movement within a single event, and if there is a way wouldn't this be a good system expression to have?
B
163
S
48
G
101
Posts: 7,463
Reputation: 72,548

» Thu Sep 09, 2010 6:43 am

hard in, smooth out? or smooth in/out?
I assume you want the sine to drive as an interpolator

I have no idea what I just said.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

» Thu Sep 09, 2010 6:59 am

Me neither, but yeah.

Course I guess some might actually not want a curve....
B
163
S
48
G
101
Posts: 7,463
Reputation: 72,548

» Thu Sep 09, 2010 7:57 am

a+abs(cosp(a-(b-a),b-a,t))
[url:3namh3fr]http://dl.dropbox.com/u/1013446/halfsine.cap[/url:3namh3fr]

if you want smooth in both directions, that's just cosp by itself
Spriter Dev
B
91
S
21
G
12
Posts: 3,246
Reputation: 16,573

» Thu Sep 09, 2010 9:43 am

That's close, but the half wave there has a two different high points.
Think of it basically like the sine behavior, only the start point is also the endpoint.
B
163
S
48
G
101
Posts: 7,463
Reputation: 72,548

» Thu Sep 09, 2010 11:17 am

Is this what you mean as a half sine? Fast at A and slow at B?
a.x+(b.x-a.x)*abs(sin(lerp(0,180,timer/1000)))
B
82
S
26
G
63
Posts: 4,856
Reputation: 45,752

» Thu Sep 09, 2010 5:21 pm

Yeah that's it. A standardized system expression that does this would be very useful.
It would be nice if you could choose to have the "smooth in", or constant speed, and even oscillating/ non-oscillating.
Just a very basic movement like a jump, boomerang, blah, etc, and it doesn't necessarily have to be for movement. It could be used for a lot of things like sound, color ramp, etc.
B
163
S
48
G
101
Posts: 7,463
Reputation: 72,548

» Fri Sep 10, 2010 12:43 am

Actually it would be useful to be able to store mathematical functions
Perhaps it's easy to do so with Python?
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

» Fri Sep 10, 2010 3:10 am

if you feed cosp a 2 itll return to the first value, since it uses cosine which is periodic, it wont continue into No man's land like lerp/qarp/cubic, since its essentially cos(t*180) or something like that controlling an interpolation

cosp(a,b,0)=a

cosp(a,b,1)=b

cosp(a,b,2)=a

but its a pure A-B-A sine loop, not a hard bounce like rojos, that would have to be a kinda ABScosp sysexp.

and to make rojos faster its better to just do

lerp(a.x,b.x,abs(sin(lerp(0,180,t))))

id imagine.
B
55
S
7
G
6
Posts: 1,949
Reputation: 7,693

» Fri Sep 10, 2010 4:45 am

[quote="madster":254amdtq]Actually it would be useful to be able to store mathematical functions
Perhaps it's easy to do so with Python?[/quote:254amdtq]

Yeah, a script would probably work nice. As I recall there is a folder for snippets somewhere.
Thanks guys
B
163
S
48
G
101
Posts: 7,463
Reputation: 72,548

Next