private void UpdateDistBrg() { Distance = LatLongCalc.Distance(StartLat, StartLon, EndLat, EndLon, 'N'); DispDistTextBox.Text = decimal.Round(Convert.ToDecimal(Distance), 2, MidpointRounding.AwayFromZero).ToString(); TrueBrg = LatLongCalc.Bearing(StartLat, StartLon, EndLat, EndLon); DispBrgTextBox.Text = decimal.Round(Convert.ToDecimal(TrueBrg), 2, MidpointRounding.AwayFromZero).ToString(); }
private void UpdateStats() { if ((CenterLat != -1) && (CenterLon != -1)) { if ((StartLat != -1) && (StartLon != -1)) { StartBrg = LatLongCalc.Bearing(CenterLat, CenterLon, StartLat, StartLon); if (StartBrg == 0) { StartBrg = 360; } StartRadialNUD.Value = Convert.ToInt32(StartBrg); ArcRadius = LatLongCalc.Distance(CenterLat, CenterLon, StartLat, StartLon); CalcDistanceTextBox.Text = ArcRadius.ToString("F3"); } else { ArcRadius = -1; StartBrg = -1; StartRadialNUD.Value = 1; CalcDistanceTextBox.Text = string.Empty; } if ((EndLat != -1) && (EndLon != -1)) { EndBrg = LatLongCalc.Bearing(CenterLat, CenterLon, EndLat, EndLon); if (EndBrg == 0) { EndBrg = 360; } EndRadialNUD.Value = Convert.ToInt32(EndBrg); EndDistTextBox.Text = LatLongCalc.Distance(CenterLat, CenterLon, EndLat, EndLon).ToString("F3"); if (ArcRadius != -1) { ChordStats(); } } else { EndBrg = -1; EndRadialNUD.Value = 1; EndDistTextBox.Text = string.Empty; } } else { ArcRadius = EndBrg = StartBrg - 1; } CheckArcButton(); }
private void CenterFromChord() { // The center is perpendicular to the midpoint of the start/end chord // Since I'm always turning to the right, perpendicular is always +90 double Lat0 = (StartLat + EndLat) / 2.0; double Lon0 = (StartLon + EndLon) / 2.0; double Brg = (LatLongCalc.Bearing(StartLat, StartLon, EndLat, EndLon) + 90) % 360; double[] Coords = LatLongCalc.Destination(Lat0, Lon0, RadiusFromChordArc(), Brg, 'N'); CenterLat = Coords[0]; CenterLon = Coords[1]; CenterLatitudeTextBox.Text = Conversions.Degrees2SCT(CenterLat, true); CenterLongitudeTextBox.Text = Conversions.Degrees2SCT(CenterLon, false); CenterFixTextBox.Text = "<calculated from chord>"; StartBrg = (LatLongCalc.Bearing(CenterLat, CenterLon, StartLat, StartLon) + 90) % 360; StartRadialNUD.Value = (int)StartBrg; EndBrg = (LatLongCalc.Bearing(CenterLat, CenterLon, EndLat, EndLon) + 90) % 360; EndRadialNUD.Value = (int)EndBrg; }