Virtual Solar System (formula for gravity in 3d)

AI Thread Summary
A virtual solar system has been created using Java3D, focusing on implementing the orbital mechanics of planets and ships. The user is utilizing the gravitational formula F = G((m1*m2)/r^2) but is struggling with 3D vector calculations and the limitations of double precision for large distances. To address this, a BigVector3d class has been developed to handle BigDecimal numbers for accurate 3D vector representation. The main loop calculates acceleration between masses, but there are concerns about the implementation of gravitational force calculations across the x, y, and z components. The user is seeking assistance to refine the gravitational force calculations and ensure accurate orbital dynamics.
Mipada
Messages
2
Reaction score
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:
Astronomy news on Phys.org
I found this formula.
Gravity formula.jpg

and tried to implement it as:
//FX
if (BD.get(X).doubleValue() > 0.000000009){//avoid div by 0 error
FX = FX.add(BG);//big gravity
FX = FX.multiply(BM);//big mass
FX = FX.divide(BD.get(X).pow(2), mc);//big distance (x dist^2)
FX = FX.multiply(BD.get(X));//big distance
FX = FX.multiply(NEG1);//make negative
}
else{//distance is 0, no force applied
FX = new BigDecimal("0");
}
Giving me the Earth pulling on a small ship in orbit, a value of
FX5=-9960977999999.9991344000
in meters per second. I'll check the numbers and get back to you.
 
Publication: Redox-driven mineral and organic associations in Jezero Crater, Mars Article: NASA Says Mars Rover Discovered Potential Biosignature Last Year Press conference The ~100 authors don't find a good way this could have formed without life, but also can't rule it out. Now that they have shared their findings with the larger community someone else might find an explanation - or maybe it was actually made by life.
TL;DR Summary: In 3 years, the Square Kilometre Array (SKA) telescope (or rather, a system of telescopes) should be put into operation. In case of failure to detect alien signals, it will further expand the radius of the so-called silence (or rather, radio silence) of the Universe. Is there any sense in this or is blissful ignorance better? In 3 years, the Square Kilometre Array (SKA) telescope (or rather, a system of telescopes) should be put into operation. In case of failure to detect...
Thread 'Could gamma-ray bursts have an intragalactic origin?'
This is indirectly evidenced by a map of the distribution of gamma-ray bursts in the night sky, made in the form of an elongated globe. And also the weakening of gamma radiation by the disk and the center of the Milky Way, which leads to anisotropy in the possibilities of observing gamma-ray bursts. My line of reasoning is as follows: 1. Gamma radiation should be absorbed to some extent by dust and other components of the interstellar medium. As a result, with an extragalactic origin, fewer...
Back
Top