1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Split gravitational force into x, y, and z componenets

  1. Nov 20, 2011 #1
    Hi. I'm not really all that knowledgeable about physics, so I'm sorry if the answer to this is obvious.

    1. The problem statement, all variables and given/known data
    I am writing a program for a computer science class in which I am doing an n-body simulation in 3-dimensional space. Currently, I have figured out the gravitational force along the hypotenuse between two bodies. Now I have to split these up into the x, y, and z components, and this is where I am having trouble.

    2. Relevant equations
    Force between two objects (force_t)=G*m1*m2/r^2
    Typically, force_x=force_t*cos(angle between x-axis and hypotenuse)
    force_y=force_t*sin(angle between x-axis and hypotenuse)

    3. The attempt at a solution

    So, I can figure out my triangle. I know that my two bodies are located at (x1, y1, z1) and (x2, y2, z2), so I have my triangle. And I am fairly certain that the above equations will hold for x and y, even though I'm in three dimensions, but I'm just not sure what the corresponding equation for the z component will be. My thought was that the combination of the three forces has to equal the total force, so perhaps I solve for the z component algebraically using the pythagorean theorem, but I have no way to check whether or not this is true.

    Anyway, any help would be appreciated. Thanks!
  2. jcsd
  3. Nov 20, 2011 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    How much vector mechanics have you studied?
  4. Nov 20, 2011 #3
    None. I've had a little linear algebra if that's related. I'm a computer science major with a minor in math.
  5. Nov 20, 2011 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    It's difficult to explain so much in a forum like this. Have you sought assistance from someone studying physics?
  6. Nov 20, 2011 #5
    That's a good idea. I'll look into it. Do you know of any site that explains this? I've been googling for a site that explains the math in-depth, but have had no success.
  7. Nov 20, 2011 #6
    If I am not mistaking I think you can just orient the coordinate system so the force is along one axis. I dont know any CS though.
  8. Nov 20, 2011 #7
    That would be problematic because in the libraries that I am using to write this program I have a static coordinate system, and the forces and direction of forces are dynamic, since I'm doing an n-body simulation. Unless you know of a way that I can recalculate the coordinate system? The programming isn't a problem; it's just the math that's giving me grief.
  9. Nov 20, 2011 #8
    Here's how I think I might be able to solve it (keep in mind that this is based on a decent amount of math but only one year of high-school level physics).

    I am trying to split up a force vector in a 3-dimensional space into three components, and I definitely have enough information to solve for all triangle side lengths with no trouble.

    I already know how to solve for the force in 2-dimensions. Fx=cos(theta)*F_total and Fy=sin(theta)*F_total, where theta is the angle of incidence with the x-axis.

    Therefore, I can split this into two triangles. One will be a triangle in the x-y plane and one will be a triangle in the x-y-z space. The hypotenuse of the triangle in the x-y plane will be one leg of the triangle in x-y-z space.

    To picture this: a square room. One triangle is made by the line from one corner on the floor of the room to the corner farthest from it on the ceiling. Another triangle is the half of the room that is on the floor, connecting to the third side of the first triangle.

    Then, I can easily solve for the leg lengths of the second triangle. Therefore, if I use the typical math described above to find the force on each of the legs of the original triangle, I can use this information to find the force in one direction and then a second force, which will be the combination of the x-y force.

    I can use x-y force with the second triangle described above and split it up into its components to find the individual forces that are in this triangle.

    I think that this should work, but obviously I have no means to test it. Does this sound alright to you? Obviously it's rough. Sorry, I couldn't find a good picture online to describe what I mean by two triangles.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook