# Physics: Kind of like a cannonball...

• 08-29-2001
Cheeze-It
Physics: Kind of like a cannonball...
Eek. It's been about 2 years since I've been in a
physics class, and since my memory is terrible
(it's because of the video games, according to
Japan's Tohoku University
), I can't remember
much of it.

I'm trying to find a tutorial that explains the
physics of something launching upwards at a
certain angle/speed, then falling. An example
of the movement I'm talking about, would be kind
of like a flying cannonball. Am I making sense?

Will someone explain the physics of this to me,
or point me to a tutorial that does?
• 08-29-2001
Gwargh
Let's see how much I remember from physics...

Well, an object's horizontal movement is independent of its vertical movement, so if you throw a ball, it will keep moving horizontally at a constant speed (ignoring friction/air resistance, which you might have to incorporate into your physics logic) even though gravity causes it to accelerate downward at 9.8 m/s/s.

I would recommend doing the calculations before launching the cannon, because it's all based on the angle. Find out how many units horizontally and how many units vertically the cannonball will move at a time based on the angle. Unless you decide to implement friction/air resistance (which I'm a little rusty on, ask someone else about that), the variable for horizontal speed will not change throughout the flight, but the variable for vertical speed must be decreased by 9.8 m/s/s (or some reasonable equivalent :) ) with each loop of your logic.
• 08-29-2001
Scourfish
As I recall, the velocity of an object on the horizontal is cos(d/t), accelleration being cos(d/t^2), and sin(d/t) or sin(d/t^2) for the vertical. Of course, this is simple stuff that you probably already knew; if so, ignore me talking out of my butt.
• 08-29-2001
Esss
Start with a velocity u and an angle a, at (0, 0).

Horizontal velocity uH = u cos a
Vertical velocity uV = u sin a

Then, at time t:

Horizontal position x = uH t
Vertical position y = uV t - 1/2 g(t^2)

I feel a Gorilla (remember?) game coming on...
• 08-29-2001
SilentStrike
That gorilla game was cool... but tank wars was the greatest ;).
• 08-30-2001
Aran
Does anyone still play Blast Doors? what an insane and fun game!
• 09-05-2001
Sebastiani
Try this. It seems to go into quite a lot of detail. I am actually reading it right now! :)
• 09-06-2001
gordy
gorilla, now that was a game.
• 09-07-2001
Sebastiani
Hey Static, did you check out that URL? I read it last night and it seems to answer your question quite well!
• 09-07-2001
Sebastiani
Also if you would like some help working it into some code, I would be willing to help...
• 09-07-2001
Cheeze-It
Hey, yeah, thanks. I printed it out... Haven't
read it yet... I'll read it tonight.
• 09-12-2001
Unregistered
Here's an algorithim that might work:

grav = the pull of gravity each time interval
move_u = verticle speed
move_f = horivontal speed
at_z = current height
at_x = current x (horivontal) position
start_z
Start_x
array_z
array_x

while !(( start_z == at_z ) && ( move_u <= 0 ))
{
array_z = at_z;
array_x = at_x;
move_u -= grav;
at_z += move_u;
at_x += move_f;
}

you might need trig to get move_z and move_x, but maybe not. Depends on your code.