# Calculus Help

This topic is 3966 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I need a bit of help with my calculus. I need to find the current angle of my player in his jump graph. The graph is a normal cartesian plane with positive up and right. I have tried various approaches to find the angle but have failed misserably, my calculus isn't advanced enough. I have 2 functions I calculate with: x = (mFromX + aTimeDelta * mSpeedX) y = (mFromY + aTimeDelta * (mVelocityInitial + 0.5 * aTimeDelta * sGravityVelocity)) Here are the definitions of the variables: mFromX = the X start pos of the jump. mFromY = the Y start pos of the jump. mSpeedX = a value calculated at the start of the jump, basicly a constant. mVelocityInitial = also a value calculated at the start of the jump, also just a constant. sGravityVelocity = also just a constant. sTicksInSecond = just a constant that says how many updates a second. mStartTime = the time the jump started, in update counts not seconds. mCurrentTime = the current time, in update counts not seconds. aTimeDelta = (mCurrentTime - mStartTime) / sTicksInSecond This is for my game for a South African Compo, TypingTower. Read more about it at http://forums.tidemedia.co.za/viewtopic.php?f=15&t=2815.

##### Share on other sites
I'm not sure what you intend for the angle to represent in this context, but here's one way you might proceed: compute the tangent to the curve at t, and then compute the angle from the tangent vector (e.g. by using atan2()).

##### Share on other sites
The tangent of the graph is dy/dx. You have two functions x(t) and y(t) and you can find dy/dx like this:
    dy/dx = dy/dt / dx/dt    dy/dt = mVelocityInitial + sGravityVelocity * t    dx/dt = mSpeedX    dy/dx = ( mVelocityInitial + sGravityVelocity * t ) / mSpeedX
You can find the angle from the tangent:
    angle = tan-1 dy/dx

##### Share on other sites
Thanks for the help and showing how to do it.

• 22
• 10
• 19
• 14
• 20