Added a method to UtilAlg.
This commit is contained in:
parent
a618b19b73
commit
e81a3f7ecd
@ -251,6 +251,25 @@ public class UtilAlg
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location findFurthest(Location mid, ArrayList<Location> locs)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double dist = UtilMath.offset(mid, loc);
|
||||
|
||||
if (bestLoc == null || dist > bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static boolean isInPyramid(Vector a, Vector b, double angleLimit)
|
||||
{
|
||||
return (Math.abs(GetPitch(a) - GetPitch(b)) < angleLimit) && (Math.abs(GetYaw(a) - GetYaw(b)) < angleLimit);
|
||||
@ -298,6 +317,42 @@ public class UtilAlg
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getLocationAwayFromOtherLocations(ArrayList<Location> locs, ArrayList<Location> players)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double closest = -1;
|
||||
|
||||
for (Location player : players)
|
||||
{
|
||||
//Different Worlds
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
double dist = UtilMath.offsetSquared(player, loc);
|
||||
|
||||
if (closest == -1 || dist < closest)
|
||||
{
|
||||
closest = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (closest == -1)
|
||||
continue;
|
||||
|
||||
if (bestLoc == null || closest > bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = closest;
|
||||
}
|
||||
}
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getLocationNearPlayers(ArrayList<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
|
Loading…
Reference in New Issue
Block a user