Calculating the Velocity of a Sine Wave

Hi Everyone!
I was wondering if anyone knew how I could calculate the velocity of a sine wave at any give time. I’m using a sine wave to calculate a characters jump motion and need to get the velocity from that curve.
I woudn’t usually calulate a jump this way but the project I’m working on requires this method for accuracy and predictability.

I have tried just comparing the changes between each frame and calculating it that way but I need a true velocity not an average between the last 2 points.

//Get Current Progress Of Jump (0.0f - 1.0f)
float fJumpProgess = (Time.fixedTime - fJumpStart) / (fJumpEnd - fJumpStart);

//Make Sure We Don't Go Too Far
fJumpProgess = Mathf.Min (fJumpProgess, 1.0f);

//Apply A Sine Curve To Y Axis
position = new Vector3(0.0f, Mathf.Sin (fJumpProgess * Mathf.PI ) * fJumpMagnitude, 0.0f);

Any advice would be usefull to me!
Thanks in advance!

David

Velocity is just change in position. If you mean the derivative of sine, that’s easy :wink:

So,

velocity = Mathf.Cos(fJumpProgess * Mathf.PI);

Technically that’s the y component of a Vector3, but I left that out so it’s clearer.

Thanks for your help!
I’m not sure why I couldn’t figure this out myself. I really need to build my understanding of the underlying concepts of these things.
This should have just jumped out at me.

Thanks again!
David

No worries ;p

Might be good to have a cheat sheet with trig identities and vector operations. Classical equations of motion are handy too.

Thanks for the advice!
I’ll do that!

David