Jump to content
  • Advertisement
Sign in to follow this  
chwpornstr

Projetile Motion problem

This topic is 5036 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

Hi all, I am currently tryin to program a basketball game with a ball displaying the correct projectile motion. I searched all the threads AND my physics book, and they both display equations finding x and y positions,i.e. in 2D. But I am working in a 3D environment, meaning there is a Z position in account. How do I calculate the xyz positions? Thanks! I am using these equations to find X and Y: X = (v0cos(angle))t Y = (v0sin(angle))t - (1/2gt^2)

Share this post


Link to post
Share on other sites
Advertisement
Using the formula in your book, x is the horizontal direction and y is vertical, with gravity acting in the negative y direction.

For 3D, x and z are 2 horizontal directions. So...it turns out to be really, really simple to convert your equations over to 3D. You need another angle. Lets look at a top-down view of your situation, in 3D:


^
Z| /
| /
|/B
-------->X


Lets say that horizontally, the basketball moves approximately along that diagonal line, which makes angle B between the X and Z axes, horizontally. The angle B is measured in radian from X. As shown, its value is positive and its in the first quadrant.

To modify your equations, just include separate equations for X and Z, and leave the Y equation as is, with no change:

X = v0*cos(B)*cos(angle)*t
Z = v0*sin(B)*cos(angle)*t
Y = v0*sin(angle)*t - (1/2gt2)

All I've really done is convert your one horizontal direction X into a horizontal vector (X,Z).

Share this post


Link to post
Share on other sites
Hi, Thanks for the equations!
But I think I'm calculating angle B wrong. How I'm doing it is that I'm taking the difference between the ball's initial position and the position of the hoop(where I want it to go) to get the distance of ball's X and Z displacement. Then I just arctan(Zdisplacement/Xdisplacement) to get the angle B. I don't believe that is precise. Any help? Thanks!!

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!