Android Question Help: Ans = Infinity

wonder

Expert
Licensed User
Longtime User
So, I'm working on a little science project:
B4X:
Dim G          = 6.67 * Power(10, -11) as Float
Dim Earth_Mass = 5.97 * Power(10,  24) as Float 'in kilograms
Dim Sun_Mass   = 1.99 * Power(10,  30) as Float 'in kilograms
Dim Distance   = 1.5  * power(10,  11) as Float 'in meters
u6l3c3.gif

B4X:
Dim Gravitational_Force = (G * Sun_Mass * Earth_Mass) / Power(Distance, 2) as Float
Log(Gravitational_Force)
Output: Infinity

I'm getting "Infinity" instead of the actual value.
How can I handle such big numbers? Any suggestions?
I'm not a math wizzard...
 

wonder

Expert
Licensed User
Longtime User
Upvote 0

wonder

Expert
Licensed User
Longtime User
I woke-up yesterday with the urge to build a miniature solar system. :D
I'm trying to get stable orbits while inputing real data.
So far all I managed to do, was to crash a few planets into the Sun.

Files:
Capture.png


Photoshop concept art:
implementation.png
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Well, I haven't got it to work properly yet, but last night I was temporarily able to get some stable orbits.

I have only two velocity vectors.
Untitled.png

Vector A is the planet's linear speed (30 km/sec).
Vector B is perpendicular to vector A and it's accelerated towards the Sun.
B4X:
Sub Acceleration_Towards_The_Sun(planet_index As Int) As Double
    Return (G * SpaceBody(Sun).Mass) / Power(Distance_Between_Two_SpaceBodies_in_Meters(planet_index, Sun), 2)
End Sub

Once I have it all figured out, I'll share the code. :)
 
Upvote 0
Top