Half sine?

For questions about using Classic.

Post » 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?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » 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

Post » Thu Sep 09, 2010 6:59 am

Me neither, but yeah.

Course I guess some might actually not want a curve....
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Sep 09, 2010 7:57 am

if I get your question:
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
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » 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.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » 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
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » 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.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Sep 10, 2010 12:43 am

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

Post » 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
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Fri Sep 10, 2010 4:45 am

[quote="madster":254amdtq]Actually it would be useful to be able to store mathematical functions :P
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
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests