View Full Version : CALL TO ANY PHYSICS GENIUSES!!!!

iNsaNEiVaN

05-14-2001, 09:41 AM

Can you please tell me the equation of the motion of a cannonball taking into effect the speed and angle, gravity, and maybe wind?

please ;-p

[This message has been edited by iNsaNEiVaN (edited 05-14-2001).]

x(t) = x0 + v0x * t

y(t) = y0 + v0y * t - 0.5 * g * t^2

x0 = initial x position in meters or feet

v0x = initial x velocity in m/s or ft/s

y0 = initial y position

v0y = initial y velocity

g = magnitude of earth's gravity = 9.8 m/s^2

or 32 ft/s^2

t = time in seconds

Wind complicates things more than you may wish to deal with if you are asking this question http://www.opengl.org/discussion_boards/ubb/smile.gif

-- Zeno

iNsaNEiVaN

05-14-2001, 10:04 AM

Thats plenty fine, thanks a lot man

I assume that you want the trajectory equation of the cannonball. You can use the parametric equations

x(t) = v * t * cos(w)

y(t) = v * t * sin(w) - 0.5 * g * t^2

where

v = initial velocity of the cannonball

w = angle of cannon with the x-axis

t = time in seconds

g = 9.8 m/s^2 (i.e. gravity)

or you can use the non-parametric equation

y = tan(w) * x - (g / k) * x ^2

which is the equation of a parabola. In the above expression

k = 2 * v ^ 2 * (cos(w))^2

w = angle of the cannon with the x-axis

x = x coordinate of the cannonball

g = 9.8 m/s^2 (i.e. gravity)

v = initial velocity of the cannonball

jwatte

05-14-2001, 10:33 AM

If you're simulating this in a game (per frame) then chances are that you're better served with a discrete integrator. Using vector algebra, a simple integrator goes something like this:

init:

V = velocity, direction of ball from cannon [m/s]

P = position of where cannon ejects ball [m]

W = velocity, direction of the wind [m/s]

G = direction, force of gravity [m/s2]

d = drag coefficient of the ball [1/s]

t = time of each physics frame [s]

per frame:

V = V + t*d*(W-V) + t*G

P = P + t*V

There are other integrators which may work better depending on your simulator, but this one is easiest to understand and usually quite good enough. Note that this one is more accurate the smaller your time step (t) is.

(I added units for clarity)

[This message has been edited by jwatte (edited 05-14-2001).]

Korval

05-14-2001, 12:30 PM

It is important to have a full-function analytic solution for AI purposes, though. If you want the AI to hit something, it has to know what angle/power to use. And the fastest way to know that is to be able to solve this problem analytically.

Well full analytic functions for a cannonball trajectory isnt very hard, but when you start having possible collisions between a bunch of such analytic functions (which is the case if a swarm of cannonballs trajectories intersect in a single frame), then you need to start dividing them into small fractions in time solving the new trajectories chronologically so you only have to test each cannonball trajectory once.

This is where the full analytic power yields its greatest treasure, because the full path of motion is described by a single function (for each cannonball) letting us know the exact position of each cannonball at any timepoint.

Changing timeframe is then just a matter of letting the user/AI do some input to change the outcome and decide the next wave of cannonballs to be fired.

Now adding wind to the equations, you can still use the full analytic method even though the gusts of wind changes along the trajectory, but only if you use a predefined path of motion for the gusts of wind, so we can calculate its influence over time.

Wind is chaotic in nature, but you can simulate this using a fractal function taking timespace as parameters. Each moment in time with each position in space will yield the same path of motion every time you calculate it.

This yields aslong as there is no external influences on the wind, such as user input that adds to the fractal expansion of the wind.

So at any given time and any given point, you will not be able to deduce the trajectory over time in a volume of gusts of wind without using an arbitrary set of small timeframes.

So we still need to use alot of small timesteps to be able to change to outcome of history in our universe. Even if we do use a full analytic way of motion.

iNsaNEiVaN

05-14-2001, 05:51 PM

ok guys, THANKS for everything but could you help me one last time since im bad in physics.

Cannon launch point = -1.75, 1.3

cannon angle = cannonball[0].yo ( 0 - 90 )

cannonball x-cord = cannonball[0].x

cannonball y-cord = cannonball[0].y

gravity = .05

speed = 5

Ok using these variables would one of you be gernerous enough to rewrite the whole equation. thank you!! its getting closer!

Tim Stirling

05-15-2001, 01:54 AM

Its important to note that the horizonatl and vertical component of the cannon balls velocity are independent and are only related in time.

The horizontal component, if ignoring air resistance is constant and will be applied for as long as the ball is in the air which is dependent on the vertical velocity at launch.

Vertical velocity equation is s = ut + 0.5at^2

S = displacement (distance from start)

u = initial vertical velocity (calculate from trig)

a = gravitation acceleration = 9.8 m per s

But U and a act in oposite directs so you should make a negative -> -9.8 (or you could make u -)

T can be calculated from v = u + at

v = final velocity.

when the ball is at its highest position v = 0

0 = u + -9.8t

enter the initial vertical velocity u and solve. t for the whole flight will be double this value (this is the time to the top)

horizontal equation is s = vt, since you have calculated t and v is the horizonatly velocity. This gives the distance (displacement) it will go after the whole flight.

should be easy to solve now, just use trig on that speed of 5.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.