Jump to content

[Program] Remote Tech 2.0 - Relay Stuff Calculator


JoePatrick

Recommended Posts

So I have just finished making what seems like a simple program and is fairly simple, although uses some fairly complicated maths. The program is for use with a mod called Remote Tech for Kerbal Space Program. First you enter the omni-directional range of each satellite and then how many satellites you would like in your relay orbit. Then just press the calculate button and it will tell you:

-The lowest orbit you can have where all the satellites will be connected

-The highest orbit you can have where all the satellites will be connected

-The required angle of separation between each satellite

Screenshots:

l4HHv2A.png

PccosYp.png

YxjUNDa.png

sQ1isKO.png

qeaSJ8z.png

fUsHUuS.png

zbtV0XQ.png

Public Class Form1 

Function angle(ByVal x)
Dim rad As Single = x
Dim deg = rad * Math.PI / 180
Return deg
End Function


Dim dist As Single
Dim sideBMinString, SideBMaxString As String
Dim units As String
Dim radius As Integer
Dim satcount As Integer
Dim limit, atmoLimit As Boolean
Dim angleA, angleB, sideA, sideC, sideBMin, sideBMax, clearSide As Single
'Dim alt As Integer = 1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
limit = False
atmoLimit = False
If TextBox1.Text = "" Then TextBox1.Text = 0
dist = TextBox1.Text
units = "m"
satcount = NumericUpDown1.Value
radius = 600000
angleA = angle(360 / satcount)
angleB = angle((180 - (360 / satcount)) / 2)
sideA = dist
sideBMax = ((sideA / Math.Sin(angleA)) * Math.Sin(angleB)) - radius
sideBMinString = "Coming soon..."
If sideBMax > 0 Then
If sideBMax > dist Then limit = True
SideBMaxString = Format(sideBMax, "#,###")
Else
SideBMaxString = "0"
End If
Label4.Text = "Min Altitude: Calculating..."
Label5.Text = "Max Altitude: Calculating..."
Label6.Text = "Angle of Seperation: Calculating..."
BackgroundWorker1.RunWorkerAsync()
If limit = False Then

Label5.Text = "Max Altitude: " & SideBMaxString & units
Else

Label5.Text = "Max Altitude: " & Format(dist, "#,###") & units
End If
If sideBMax > 0 Then
Label6.Text = "Angle of Seperation: " & Math.Round(360 / satcount) & ""
Else
Label6.Text = "Angle of Seperation: 0"
End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Control.CheckForIllegalCrossThreadCalls = False
End Sub


Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
e.Handled = True
End If
End Sub


Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For alt = 1 To 84159286
Dim satDist As Single = Math.Sin(angleA) * (alt / Math.Sin(angleB)) / 2
clearSide = Math.Sqrt((satDist ^ 2) + (alt ^ 2) - (2 * satDist * alt * Math.Cos(angleB)))
If clearSide >= 600000 Then
BackgroundWorker1.ReportProgress(100)
sideBMin = alt - radius
If sideBMin < 70000 Then
atmoLimit = True
End If
Exit For
End If
Next
End Sub


Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
If sideBMin > sideBMax Then
Label4.Text = "Min Altitude: 0m"
Label5.Text = "Max Altitude: 0m"
Label6.Text = "Angle of Seperation: 0"
MessageBox.Show("You cannot put " & satcount & " satellites with an omni-range of " & Format(dist, "#,###") & "m in orbit and have a connection as the minimum required altitude is higher than the maximum")
Else
If atmoLimit = False Then
Label4.Text = "Min Altitude: " & Format(sideBMin, "#,###") & "m"
Else
Label4.Text = "Min Altitude: 70,000m"
End If
If atmoLimit = True Then
MessageBox.Show("Your setup is capable of having a minimum altitude of " & Format(sideBMin, "#,###") & "m but because of Kerbin's atmosphere, this is limited to 70,000m")
End If
If limit = True Then
If sideBMax < 84159286 Then
MessageBox.Show("The omni-range you have chosen cannot receive a signal from Kerbin above " & Format(dist, "#,###") & units & " but this setup has the potential for a max altitude of " & Format(sideBMax, "#,###") & "m if you add a dish with enough range to reach Kerbin")
Else
MessageBox.Show("The omni-range you have chosen cannot receive a signal from Kerbin above " & Format(dist, "#,###") & units & " but this setup has the potential for a max altitude of 84,159,286m (edge of Kerbin's SOI) if you add a dish with enough range to reach Kerbin")
End If
End If
End If
End Sub

End Class

Edited by JoePatrick
Link to comment
Share on other sites

  • 3 weeks later...

Tried to get this to run, but without the designer code as well you would have to make all the labels/messages.

Went ahead and made the same thing in excel / google docs if anyone comes accross this thread in the future:

http://forum.kerbalspaceprogram.com/threads/52132-Spreadsheet-Orbit-Night-Darkness-Req-Battery-Capacity-and-Satellite-Relay-Coverage

Spreadsheet version.

EeCb5AC.png

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...