// Returns the closest Waypoint Coordinate, based on bots current Location Coordinate public Coordinate ClosestWaypoint(Coordinate current) { float shortestDistance = 0.0f; Coordinate closestWaypoint = new Coordinate(0f, 0f, 0f); // <- shut compiler up foreach (Coordinate waypoint in waypoints) { Vect3D v = new Vect3D(current, waypoint); if (shortestDistance == 0.0f) { shortestDistance = v.LengthFast; closestWaypoint = waypoint; } else if (v.LengthFast < shortestDistance) { shortestDistance = v.LengthFast; closestWaypoint = waypoint; } } return(closestWaypoint); }
// Returns the closest Waypoint Coordinate, based on bots current Location Coordinate public Coordinate ClosestWaypoint(Coordinate current) { float shortestDistance = 0.0f; Coordinate closestWaypoint = new Coordinate(0f, 0f, 0f); // <- shut compiler up foreach (Coordinate waypoint in waypoints) { Vect3D v = new Vect3D(current, waypoint); if (shortestDistance == 0.0f) { shortestDistance = v.LengthFast; closestWaypoint = waypoint; } else if (v.LengthFast < shortestDistance) { shortestDistance = v.LengthFast; closestWaypoint = waypoint; } } return closestWaypoint; }