Computer Science Canada Trajectory help :D |
Author: | berrberr [ Sun Oct 22, 2006 5:57 pm ] |
Post subject: | Trajectory help :D |
Hello everyone. Im currently trying to come up with some formula in turing that will calulate and display the trajectory of an object being shot, given an angle an amount of power and the force of gravity. (Kinda like in pocket tnaks or gunbound I guess). Combining my suckyness in math and physics I havent gotten very far ![]() |
Author: | Ultrahex [ Sun Oct 22, 2006 10:04 pm ] |
Post subject: | |
Its much easier if you seperate the X and Y components, search up Projectile Motion Online For Physics Formulas, This Will Probably Help-A-Lot Basically d=v1t+1/2at^2 for your y v1 is equal to initial Vertical Speed so if the angle is 40 at a power of 100 then v1 is 100*sin(40) hope this helps a little -- Will Get Back to you tomorrow with better answer. |
Author: | Ultrahex [ Mon Oct 23, 2006 3:01 pm ] |
Post subject: | |
Assuming No Friction! dy= viy * t + 0.5gt^2 viy = intial vertical velocity g = gravity (normally -9.8) dy = distance travelled verticall (or vertical position at time) t = current time dx=vix * t vix = intial horizontal velocity dx = current horizontal position t = current time Use SOH CAH TOA To Get viy, and vix vix = cos(angle) * power viy = sin(angle) * power |
Author: | berrberr [ Mon Oct 23, 2006 7:45 pm ] |
Post subject: | |
Ok well I understand the formulas (gr 11 physics ftw ![]() ![]() ![]() |
Author: | do_pete [ Tue Oct 24, 2006 9:45 am ] | ||
Post subject: | |||
You don't really need physics. Something like this would do:
|
Author: | [Gandalf] [ Tue Oct 24, 2006 3:30 pm ] |
Post subject: | |
do_pete wrote: You don't really need physics.
Well, what if you want to specifically set the angle and force? Using simple x and y velocities you are basically going in a random direction hoping for a parabolic trajectory. If you add a bit of trigonometry in there you can precisely set the angle the object is going in, as well as some other stuff. Particularily useful in games, for one. |
Author: | berrberr [ Tue Oct 24, 2006 4:49 pm ] | ||
Post subject: | |||
do_pete wrote: You don't really need physics. Something like this would do:
Thanks for the reply! The problem with that code is that the x and y Speed dont controll the speed at all but rather the hight and length of the curve. The code does make a ball travel in an arc and does factor in gravity, but it doesnt include angles and power which is what I am trying to add into the code. Any other ideas ? |
Author: | Cervantes [ Tue Oct 24, 2006 5:36 pm ] |
Post subject: | |
This code will work fine with angles and power. You just need to convert your polar value (length and angle, corresponding to power and angle) into cartesian coordinates (representing x velocity and y velocity). To do that, you need simple grade ten trig. |
Author: | do_pete [ Wed Oct 25, 2006 8:30 am ] | ||
Post subject: | |||
Like so:
|
Author: | berrberr [ Thu Oct 26, 2006 4:11 pm ] |
Post subject: | |
Thanks alot do_pete! Exactly what I wanted, and I understand it now. Thanks ![]() |