-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.cs
More file actions
39 lines (35 loc) · 906 Bytes
/
Utility.cs
File metadata and controls
39 lines (35 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
public class Utility
{
public static float DEG_from_RAD(float R)
{
return Convert.ToSingle(R / (2 * Math.PI) * 360);
}
public static float RAD_from_DEG(float D)
{
return Convert.ToSingle( (D / 360.0f) * 2 * Math.PI);
}
public static string GetLocalIPAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
return ip.ToString();
}
}
return "No network adapter found";
}
public static float InvertHeading(float hdg)
{
if (hdg < 180) return hdg + 180;
else return hdg - 180;
}
}