Need help for computer science coursework - motion and gravity

In summary, the conversation discusses a problem with calculating the motion of a ball in a pinball simulation and the relevant equations and methods to solve it. The use of vectors to represent position, velocity, and acceleration is recommended and the application of Newton's Second Law is suggested to calculate acceleration. Finally, the speed and angle of the ball can be determined from the velocity vector.
  • #1
gutti
26
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
  • #2
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)
 

FAQ: Need help for computer science coursework - motion and gravity

1. What is the relationship between motion and gravity?

The relationship between motion and gravity is that gravity is a force that pulls objects towards each other, causing them to move. This force is responsible for the motion of celestial bodies in space as well as the movement of objects on Earth.

2. How does gravity affect the motion of objects?

Gravity affects the motion of objects by exerting a force on them that causes them to accelerate towards the center of the Earth. This acceleration is known as the acceleration due to gravity and is approximately 9.8 meters per second squared on Earth.

3. What is the difference between mass and weight in relation to gravity?

Mass is a measure of the amount of matter an object contains, while weight is a measure of the force of gravity acting on an object. Mass remains constant regardless of location, while weight may vary depending on the strength of gravity.

4. How does gravity impact the motion of objects in space?

In space, gravity is the dominant force that determines the motion of objects. The gravitational pull of large celestial bodies, such as planets, can cause objects to orbit around them. Additionally, the force of gravity can also cause objects to collide or be pulled towards each other.

5. What are some real-world applications of understanding motion and gravity?

Understanding motion and gravity is crucial in many real-world applications, such as space exploration, engineering, and sports. It helps us predict the motion of objects and design structures and vehicles that can withstand gravitational forces. It also allows us to accurately measure and track the movements of objects in space and on Earth.

Similar threads

Replies
5
Views
2K
Replies
38
Views
2K
Replies
19
Views
2K
Replies
8
Views
611
Replies
18
Views
4K
Replies
1
Views
2K
Replies
7
Views
4K
Back
Top