Need help for computer science coursework - motion and gravity

Click For Summary
SUMMARY

The discussion focuses on calculating the motion of a ball in a pinball simulation, specifically using Newton's Second Law of Motion, represented by the equation \( a = \frac{F}{m} \). The gravity value is set at 25 L/ms², and the simulation requires updating the ball's velocity and position on each tick. The recommended approach involves using vectors for position, velocity, and acceleration, applying gravity directly to the acceleration vector, and resetting it each frame to prevent value accumulation.

PREREQUISITES
  • Understanding of Newton's Second Law of Motion
  • Familiarity with vector mathematics
  • Basic programming skills for simulation development
  • Knowledge of physics concepts related to motion and gravity
NEXT STEPS
  • Research vector mathematics in programming for motion simulations
  • Learn about implementing physics engines in game development
  • Explore advanced topics in kinematics for more complex simulations
  • Study the effects of different forces on motion in physics
USEFUL FOR

Game developers, physics enthusiasts, and students working on simulations involving motion and gravity will benefit from this discussion.

gutti
Messages
26
Reaction score
0
I'm not a physics student and haven't done any physics work since high school. I've since then forgot most of what I knew and although while researching this problem, everything looks familiar. It just doesn't fit together in my head. This isn't a marked piece of the coursework it's just involved and the coursework really doesn't work without it.

I am making a pinball simulation and need to calculate the motion of a ball. At all times I can get the coordinates of the ball (which I don't think really matter, the velocity(speed and angle of movement) and I am given a value for gravity which is 25 L/ms^2 where L is some unit of distance.

On each tick of the program the ball will move and then gravity must be applied to it.

I need to calculate the new angle the ball will be moving at and the new speed of the ball.

Could someone tell me which equations I would use to calculate this.
 
Physics news on Phys.org
This isn't really the section of the forums to ask this, but I'm happy to answer it anyway. Luckily motion is pretty easy to set up in a program. If you use vectors to represent position, velocity, and acceleration, it becomes quite simple.

For each tick you choose which forces to apply to which objects (in your case the pinball), and calculate the resulting acceleration from Newton's Second:
$$a = \frac{F}{m}$$
Or, in a case like gravity where acceleration will always be the same value, you can just change the acceleration vector directly.

Then, on each tick, just add the acceleration vector to the velocity vector, then add the velocity vector to the position vector. There are other ways to do it, say if you wanted to move things forward a certain time value each time, but this is the simplest, I think. Also, make sure you set the acceleration vector to null on each frame (or reset it to something like the acceleration from gravity) so that you don't accumulate values in the vector each frame.

Then you can calculate the speed and angle from the velocity vector. (Speed is the magnitude of the vector, angle is the direction of the vector)
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 38 ·
2
Replies
38
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 18 ·
Replies
18
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
Replies
1
Views
2K