Jump to content
  • Advertisement
Sign in to follow this  
ShadowMaster01

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


Link to 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


Link to 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


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

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!