I'm dealing with a question for class that is asking me to mimic the movements of planets/moons/asteroids within a solar system in a 3D space. We started early the semester with vectors, masses, and forces, so I'm still trying to grasp it.
*My issues are detailed below on step 4 and 5. Let me know if I got anything wrong along the way. Any input and guidance would be greatly appreciated.
- Info Given
Each object in space has the following:
- mass
- position vector <x, y, z>
- velocity vector <x, y, z>
I have to use Newton's Law of Universal Gravitation:
F = G * mass1 * mass2 / distance^2
- Question
Given time t update the position and velocity of each object in space. So if t is 10 seconds, where would those objects be in space at that given time?
I'm told to treat acceleration as constant throughout t. And not to worry about object collisions and that the objects may be extremely small, for simplicity's sake. Given objects in space may be from 1 to 100.
- My Progress So Far
I'm not sure if I'm doing it right so far but here's the steps I'm taking so far:
Step 1: If it was 2 objects then I'd use the force formula as it as. But since it's X amount of objects I'm going through each object and I'm calculating the Force between itself and every other object. I'm adding those up to a Net Force.
Step 2: I'm calculating my Acceleration:
a = Net Force / Mass
Step 3: Next I calculate the final velocity:
V = u + a*t
u = initial velocity
Step 4: Calculate the final position of the object:
s = s0 + u*t + 1/2*a*t^2
s0 = initial position, u = initial velocity
Step 5: repeat the process on the rest of the objects
My problem is on step 4 and 5. My positions and velocities are vectors. but the acceleration is a scalar, so I know I just can't add that up to the vectors. So what do I do here? Do I do the calculation on each vector component then put all the components back into the new final velocity and final position vectors? I'd really appreciate the help and any input.