Skip to content

Instantly share code, notes, and snippets.

@SharpMan
Created December 28, 2015 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SharpMan/0de623f3ac5791469f72 to your computer and use it in GitHub Desktop.
Save SharpMan/0de623f3ac5791469f72 to your computer and use it in GitHub Desktop.
private static MapPoint getBestNextPortal(MapPoint param1, MapPoint[] param2) {
Point refCoord = null;
Point nudge = null;
MapPoint refCell = param1;
MapPoint[] closests = param2;
if (closests.length < 2) {
throw new Error("closests should have a size of 2.");
} else {
refCoord = refCell.coordinates();
nudge = new Point(refCoord.x, refCoord.y + 1);
final Point CommparedrefCoord = refCoord;
final Point ComparedNudge = nudge;
Arrays.stream(closests).sorted((MapPoint param3, MapPoint param4) -> {
final double _loc3_ = getPositiveOrientedAngle(CommparedrefCoord, ComparedNudge, new Point(param3.get_x(), param3.get_y())) - getPositiveOrientedAngle(CommparedrefCoord, ComparedNudge, new Point(param4.get_x(), param4.get_y()));
return _loc3_ > 0 ? 1 : _loc3_ < 0 ? -1 : 0;
}).toArray(MapPoint[]::new);
MapPoint res = getBestPortalWhenRefIsNotInsideClosests(refCell, closests);
if (res != null) {
return res;
}
return closests[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment