- #1
Mipada
- 2
- 0
I've made a virtual solar system in Java3d. I'm trying to implement the orbiting of planets and ships. I get the basic formula
Code:
F = G((m1*m2)/r^2))[\code] and saw a discussion here about the formula in 3d but, I don't know how to read a letter with an arrow over it, lol. Can someone help me with the details?
Note:doubles can't seem to hold the big distances and the minute force of gravity at those distances. I've ended up creating a BigVector3d class. It holds BigDecimal numbers and allows me to use vectors (at least to hold 3d numbers in one object). I'll post that for someone else to use.
Fundamentally I'm doing this.
(Sorry, I can't find the usual code formatting commands I've seen before. And, I don't know if this is in the right forum.)
[code]
vv = vv + av;//velocity vector = velocity vector + acceleration vector
lv = lv + vv;//location vector = location vector + velocity vector (for x, y, z)
[\code]
My main loop calls acceleration(Mass3d m2)
[code]
for (int j = 0;j < mass.size();j++){
for (int i = j;i < mass.size();i++)//skip previously done masses
{
mass.get(j).acceleration(mass.get(i));//for each other mass
}
}
[\code]
Then i try using this formula.
[code]
acceleration(Mass3D m2){
//F = -((G*m1*m2 * r.x)/r3) * r3
//split force between two masses. I don't think this part works at all.
m1.location.add(F/2);
m2.location.sub(F/2);
}
[\code]
How can i get the gravitational force for the x, y, z components?
Last edited: