Physics 1 student, making a physics based and I need a little math help

In summary, a user is seeking help with creating a physics-based game involving Newton's gravity equation. They are struggling with getting the movement to work properly on a 2D plane and are unsure of how to use cos and sin to split up the distance and acceleration. Another user suggests putting the attractor at the origin and resolving velocities and acceleration into x and y components to determine if the acceleration is positive or negative.
  • #1
someoneYEAH!
1
0
Hooray for long titles...

Anyway, I wasn't quite sure where to post this, sorry if this is in the totally wrong forum.

As you may have gathered from the title, I am attempting to make a physics based game. The primary equation in this game is Newton's gravity equation.

F = G(m1*m2)/(r^2)

I mangled it to where it actually works with numbers thrown around in the game while not changing it too much, but here's my problem, my game is on a 2D plane, and I cannot figure out how to get my movement to work out right.

I fuse the x-axis and y-axis distances into one distance at the beginning, and, of course, to get what I want to move I have to split that value up using cos and sin. So I split it up after I find the acceleration from the force and then check the distances to see if the acceleration should be positive or negative. It ends up that in certain cases, the planet will sort of wobble back and forth as it moves.

it's easier to show: http://ian.janasnyder.com/phys.png

I think my problem is that I should be splitting up the speed rather than acceleration, but then how do I tell whether to add or subtract acceleration?

Any tips?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
Not sure if this is any help, but from the hip, and assuming the "attractor" is much more massive than the "planet", I would put the attractor at the origin and resolve both velocities and acceleration into x and y components. If on successive time frames, the absolute value of the x or y position is becoming larger, then the acceleration is retarding, and vice versa.
 
  • #3


Hello! It sounds like you are on the right track with using Newton's gravity equation for your game. As for your issue with the movement of the planet, it may be helpful to think about using vectors to represent the planet's position and velocity. This will allow you to easily split up the movement in both the x and y directions. Additionally, you may want to consider using the concept of centripetal force to ensure that the planet's movement is smooth and circular around the center of gravity. I recommend looking into vector math and centripetal force to help with your game development. Good luck!
 

What is the difference between distance and displacement?

Distance is the total length traveled by an object, while displacement is the straight line distance between the initial and final position of the object. In other words, displacement takes into account the direction of movement, while distance does not.

What is the formula for calculating velocity?

The formula for velocity is v = d/t, where v is velocity, d is distance, and t is time. This formula can also be rearranged to find distance or time, depending on which values are known.

How is acceleration related to velocity and time?

Acceleration is the rate at which velocity changes over time. It is calculated by dividing the change in velocity by the change in time. This means that the greater the change in velocity in a given amount of time, the higher the acceleration will be.

What is the difference between speed and velocity?

Speed is the rate at which an object is traveling, while velocity is the rate at which an object is changing its position. Velocity takes into account the direction of movement, while speed does not.

How do you calculate the force on an object?

The formula for calculating force is F = ma, where F is force, m is mass, and a is acceleration. This means that the greater the mass of an object and the greater the acceleration, the greater the force will be.

Similar threads

Replies
5
Views
1K
  • General Discussion
Replies
12
Views
1K
Replies
2
Views
881
  • STEM Academic Advising
Replies
6
Views
851
  • Introductory Physics Homework Help
Replies
4
Views
2K
  • Classical Physics
Replies
7
Views
827
  • STEM Academic Advising
Replies
18
Views
2K
  • Introductory Physics Homework Help
Replies
2
Views
945
  • STEM Academic Advising
Replies
10
Views
2K
Replies
16
Views
1K
Back
Top