Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that explores the effects of gravity on a ball that is thrown fr

ID: 3556687 • Letter: W

Question

Write a program that explores the effects of gravity on a ball that is thrown from a tower at a constant velocity. Your program will calculate how far the ball will travel, and how long it takes, before hitting the ground. Use three different classes. World class, Ball class, Tester class. The Tester class will contain the main() method and provide the control of the program. The World class will provide the acceleration force felt by the ball, and the tower height. The Ball class will contain the velocity and angle of throw of the ball. We will discuss in class the methods necessary to make this all work. The Program will take as input: Initial velocity Initial angle Tower height The program will then return: Distance thrown Time to impact

Explanation / Answer

the basic Euler integration method described in tenpn's answer suffers from a few problems:

Even for simple motion, like ballistic jumping under constant gravity, it introduces a systematic error.

The error depends on the timestep, meaning that changing the timestep changes object trajectories in a systematic way that may be noticed by players if the game uses a variable timestep. Even for games with a fixed physics timestep, changing the timestep during development can noticeably affect the game physics such as the distance that an object launched with a given force will fly, potentially breaking previously designed levels.

It doesn't conserve energy, even if the underlying physics should. In particular, objects that should oscillate steadily (e.g. pendulums, springs, orbiting planets, etc.) may steadily accumulate energy until the whole system blows apart.

Fortunately, it's not hard to replace Euler integration with something that is almost as simple, yet has none of these problems

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote