I am developing an add-on that creates a Galaxy of randomly created stars and planets.
Part of this add-on will take an existing scenario and modify it for one of the systems I have randomly created.
It works up to the point of calculating the RPOS and RVEL parameters.
I do not have the math skills to do this myself so I have "borrowed" the math from other add-ons.
This add-on is written in Visual Studio 2010 Visual Basic (which handles forms a lot easier than VC does imho). It is not meant to interface directly with orbiter.
Here is the code that is causing me a problem:
Dim r AsDouble = Val(BodyRadius.Text) + Val(OrbitSMA.Text)
Dim lng AsDouble = Val(Long_In.Text)
Dim clong AsDouble = System.Math.Cos(lng)
Dim slng AsDouble = System.Math.Sin(lng)
Dim lat AsDouble = Val(Lat_In.Text)
Dim clat AsDouble = System.Math.Cos(lat)
Dim slat AsDouble = System.Math.Sin(lat)
Dim M AsDouble = Val(BodyMass.Text)
' position in cartesian coordinates
Dim x AsDouble = r * System.Math.Cos(lat) * System.Math.Cos(lng)
Dim z AsDouble = r * System.Math.Cos(lat) * System.Math.Sin(lng)
Dim y AsDouble = r * System.Math.Sin(lat)
' Base velocity of orbit
Dim G AsDouble = 0.0000000000667 ' Gravitational Constant
Dim v AsDouble = System.Math.Sqrt(G * M / r)
Dim inc AsDouble = Val(OrbitInc.Text) / (180 / System.Math.PI) ' to radians
' assuming a standard (non-retrograde) orbit
Dim vx AsDouble = -v * System.Math.Cos(inc)
Dim vy AsDouble = v * System.Math.Sin(inc)
Dim vz AsDouble = 0.0
' derivatives in cartesian coordinates
RPOS_Out.Text = x & " " & y & " " & z
RVEL_Out.Text = vx & " " & vy & " " & vz
Can anyone give me some help in getting the correct values for RVEL and RPOS?
(I set vz to 0.0 as I could not find the math to properly calulate it)
Part of this add-on will take an existing scenario and modify it for one of the systems I have randomly created.
It works up to the point of calculating the RPOS and RVEL parameters.
I do not have the math skills to do this myself so I have "borrowed" the math from other add-ons.
This add-on is written in Visual Studio 2010 Visual Basic (which handles forms a lot easier than VC does imho). It is not meant to interface directly with orbiter.
Here is the code that is causing me a problem:
Dim r AsDouble = Val(BodyRadius.Text) + Val(OrbitSMA.Text)
Dim lng AsDouble = Val(Long_In.Text)
Dim clong AsDouble = System.Math.Cos(lng)
Dim slng AsDouble = System.Math.Sin(lng)
Dim lat AsDouble = Val(Lat_In.Text)
Dim clat AsDouble = System.Math.Cos(lat)
Dim slat AsDouble = System.Math.Sin(lat)
Dim M AsDouble = Val(BodyMass.Text)
' position in cartesian coordinates
Dim x AsDouble = r * System.Math.Cos(lat) * System.Math.Cos(lng)
Dim z AsDouble = r * System.Math.Cos(lat) * System.Math.Sin(lng)
Dim y AsDouble = r * System.Math.Sin(lat)
' Base velocity of orbit
Dim G AsDouble = 0.0000000000667 ' Gravitational Constant
Dim v AsDouble = System.Math.Sqrt(G * M / r)
Dim inc AsDouble = Val(OrbitInc.Text) / (180 / System.Math.PI) ' to radians
' assuming a standard (non-retrograde) orbit
Dim vx AsDouble = -v * System.Math.Cos(inc)
Dim vy AsDouble = v * System.Math.Sin(inc)
Dim vz AsDouble = 0.0
' derivatives in cartesian coordinates
RPOS_Out.Text = x & " " & y & " " & z
RVEL_Out.Text = vx & " " & vy & " " & vz
Can anyone give me some help in getting the correct values for RVEL and RPOS?
(I set vz to 0.0 as I could not find the math to properly calulate it)