Half sine?

This forum is currently in read-only mode.
0 favourites
  • 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?

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

  • Me neither, but yeah.

    Course I guess some might actually not want a curve....

  • if I get your question:

    a+abs(cosp(a-(b-a),b-a,t))

    http://dl.dropbox.com/u/1013446/halfsine.cap

    if you want smooth in both directions, that's just cosp by itself

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

  • 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)))

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Actually it would be useful to be able to store mathematical functions

    Perhaps it's easy to do so with Python?

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

  • Actually it would be useful to be able to store mathematical functions

    Perhaps it's easy to do so with Python?

    Yeah, a script would probably work nice. As I recall there is a folder for snippets somewhere.

    Thanks guys

  • You know, you guys could always just use functions. Name the function object F, make an on function abscosp and set the return value to:

    lerp(.Param(1),.Param(2),abs(sin(lerp(0,180,.Param(3)))))

    Then you can use it with F.abscosp(a,b,t) anywhere you want.

  • You know, you guys could always just use functions. Name the function object F, make an on function abscosp and set the return value to:

    lerp(.Param(1),.Param(2),abs(sin(lerp(0,180,.Param(3)))))

    Then you can use it with F.abscosp(a,b,t) anywhere you want.

    While you're right in general, the difference to using Python is that once written you can use the very same script/module etc in every project without the need of rewriting it. You can literally build your own library, and as long as Construct does not support "outsorcing", Python would be the only way.

  • Care to show us a graph of your interpretation of this "half sine"? I'm confused.

  • <img src="http://www.geofex.com/effxfaq/d101_06.gif">

    As you can see a full wave would go below the start point. Just like how the sine behavior works.

    I'm just trying to do the hump, with an option to have it oscillate, along a single axis that is.

    It's relatively easy for a non math wiz like me to get interpolation from point a to b. Its not that hard to have it do the inverse using some sort of state machine. But that's not very elegant, as it would take more than one event, and a pv or two.

  • Uh... that looks like |sin(x)| to me. Yes, absolute value.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)