From 77bc712eba46d905eadf32d0630931f6aa0eb458 Mon Sep 17 00:00:00 2001 From: C9Glax <13404778+C9Glax@users.noreply.github.com> Date: Mon, 31 Oct 2022 23:10:28 +0100 Subject: [PATCH] double to float --- Graph/Edge.cs | 4 ++-- Graph/Node.cs | 12 ++++++------ Graph/Utils.cs | 6 +++--- astar/Astar.cs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Graph/Edge.cs b/Graph/Edge.cs index 9cfa252..0c35cbd 100644 --- a/Graph/Edge.cs +++ b/Graph/Edge.cs @@ -3,8 +3,8 @@ public struct Edge { public Node neighbor { get; } - public double weight { get; } - public Edge(Node neighbor, double weight) + public float weight { get; } + public Edge(Node neighbor, float weight) { this.neighbor = neighbor; this.weight = weight; diff --git a/Graph/Node.cs b/Graph/Node.cs index 23ab811..433f884 100644 --- a/Graph/Node.cs +++ b/Graph/Node.cs @@ -4,21 +4,21 @@ { public float lat { get; } public float lon { get; } - public List edges { get; } + public HashSet edges { get; } public Node previousNode { get; set; } - public double goalDistance { get; set; } + public float goalDistance { get; set; } - public double pathLength { get; set; } + public float pathLength { get; set; } public Node(float lat, float lon) { this.lat = lat; this.lon = lon; - this.edges = new List(); + this.edges = new(); this.previousNode = nullnode; - this.goalDistance = double.MaxValue; - this.pathLength = double.MaxValue; + this.goalDistance = float.MaxValue; + this.pathLength = float.MaxValue; } public static Node nullnode = new(float.NaN, float.NaN); } diff --git a/Graph/Utils.cs b/Graph/Utils.cs index 6240448..550ed10 100644 --- a/Graph/Utils.cs +++ b/Graph/Utils.cs @@ -2,12 +2,12 @@ public struct Utils { - public static double DistanceBetweenNodes(Node n1, Node n2) + public static float DistanceBetweenNodes(Node n1, Node n2) { return DistanceBetweenCoordinates(n1.lat, n1.lon, n2.lat, n2.lon); } - public static double DistanceBetweenCoordinates(float lat1, float lon1, float lat2, float lon2) + public static float DistanceBetweenCoordinates(float lat1, float lon1, float lat2, float lon2) { const int earthRadius = 6371; double differenceLat = DegreesToRadians(lat2 - lat1); @@ -19,7 +19,7 @@ double a = Math.Sin(differenceLat / 2) * Math.Sin(differenceLat / 2) + Math.Sin(differenceLon / 2) * Math.Sin(differenceLon / 2) * Math.Cos(lat1Rads) * Math.Cos(lat2Rads); double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); - return earthRadius * c; + return Convert.ToSingle(earthRadius * c); } private static double DegreesToRadians(double deg) diff --git a/astar/Astar.cs b/astar/Astar.cs index 6019cb5..187afaa 100644 --- a/astar/Astar.cs +++ b/astar/Astar.cs @@ -34,7 +34,7 @@ namespace astar foreach(Node n in nodes.Values) { n.previousNode = Node.nullnode; - n.goalDistance = double.MaxValue; + n.goalDistance = float.MaxValue; } }