I'm slightly embarrassed with this email on two counts. First, I wrote it before I read Jonathan Lang's response about smaller triangles being more accurate. Second? The program code I listed below, included "REM" lines in it where I had echo checks in the program so I knew what the program was doing as it executed the code. What you see sans the "REM msbox" code is what is required to get that code to work. As for making it work in a traveler based game, I need only turn that code into a function that accepts start hex, end hex, and then returns the distance value as part of the function, and I can use it for keeping track of where a ship is in the spinward marches or any other of the Traveler maps.
Ah well, enough for the interruption here ;) -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Alaconius Sent: Monday, October 10, 2011 10:55 PM To: 'The GURPSnet mailing list' Subject: RE: [gurps] Planetary movement and checking the Math That code by the way is: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim StartX As Integer = Int(Val(TextBox1.Text) / 100) REM MsgBox("StartX: " & Str(StartX)) Dim StartY As Integer = Val(TextBox1.Text) - StartX * 100 REM MsgBox("StartY: " & Str(StartY)) Dim EndX As Integer = Int(Val(TextBox2.Text) / 100) REM MsgBox("EndX: " & Str(EndX)) Dim EndY As Integer = Val(TextBox2.Text) - EndX * 100 REM MsgBox("EndY: " & Str(EndY)) Dim DeltaX As Integer = Math.Abs(StartX - EndX) REM MsgBox("Absolute Value StartX - EndX: " & Str(DeltaX)) Dim distance As Integer = 0 Dim DeltaY As Double = EndY - StartY Dim StartXMod As Double = 0 Dim EndXMod As Double = 0 REM MsgBox("StartX Mod 2: " & Str(StartX Mod 2)) If (StartX Mod 2) = 0 Then StartXMod = -0.5 Else StartXMod = 0 End If REM MsgBox("StartXMod = " & Str(StartXMod)) REM MsgBox("EndX Mod 2: " & Str(EndX Mod 2)) If (EndX Mod 2) = 0 Then EndXMod = 0.5 Else EndXMod = 0 End If REM MsgBox("EndXMod = " & Str(EndXMod)) DeltaY = Math.Abs(DeltaY + StartXMod + EndXMod) REM MsgBox("DeltaY = " & Str(DeltaY)) REM =IF(DeltaX>(2*AbsoluteDy),DeltaX,DeltaX/2+AbsoluteDy) If DeltaX > (2 * DeltaY) Then distance = DeltaX Else distance = (DeltaX / 2) + DeltaY End If TextBox3.Text = Str(distance) End Sub End Class _______________________________________________ GurpsNet-L mailing list <[email protected]> http://mail.sjgames.com/mailman/listinfo/gurpsnet-l
