Created
December 28, 2015 00:19
-
-
Save SharpMan/0de623f3ac5791469f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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