Jump to content
• Advertisement

# Calculus Help

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

If you intended to correct an error in the post then please contact us.

## 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 this post

##### Share on other sites
Advertisement
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 this post

##### 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 this post

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

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5
JoeJ
19
• Advertisement

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
633000
• Total Posts
3009815
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!