本文整理了Java中org.bukkit.util.Vector.distance()
方法的一些代码示例,展示了Vector.distance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.distance()
方法的具体详情如下:
包路径:org.bukkit.util.Vector
类名称:Vector
方法名:distance
[英]Get the distance between this vector and another. The value of this method is not cached and uses a costly square-root function, so do not repeatedly call this method to get the vector's magnitude. NaN will be returned if the inner result of the sqrt() function overflows, which will be caused if the distance is too long.
[中]得到这个向量和另一个向量之间的距离。此方法的值不会被缓存,并且使用了代价高昂的平方根函数,因此不要反复调用此方法来获取向量的大小。如果sqrt()函数的内部结果溢出,将返回NaN,如果距离太长,将导致溢出。
代码示例来源:origin: CitizensDev/CitizensAPI
public float distance(VectorNode to) {
return (float) location.distance(to.location);
}
代码示例来源:origin: CitizensDev/CitizensAPI
@Override
public float getInitialCost(VectorNode node) {
return (float) node.getVector().distance(goal);
}
代码示例来源:origin: CitizensDev/CitizensAPI
public float heuristicDistance(Vector goal) {
return (float) (location.distance(goal) + getBlockCost()) * TIEBREAKER;
}
代码示例来源:origin: echurchill/CityWorld
public boolean inCityRange(int x, int z) {
if (checkCityRange) {
Vector centerPoint = getCenterPoint(x, z);
if (buildOutsideRadius)
return centerPoint.distance(new Vector(x, 0, z)) > cityChunkRadius;
else
return centerPoint.distance(new Vector(x, 0, z)) <= cityChunkRadius;
}
return true;
}
}
代码示例来源:origin: echurchill/CityWorld
public boolean inConstructRange(int x, int z) {
if (checkConstructRange) {
Vector centerPoint = getCenterPoint(x, z);
if (buildOutsideRadius)
return centerPoint.distance(new Vector(x, 0, z)) > constructChunkRadius;
else
return centerPoint.distance(new Vector(x, 0, z)) <= constructChunkRadius;
}
return true;
}
代码示例来源:origin: echurchill/CityWorld
public boolean inRoadRange(int x, int z) {
if (checkRoadRange) {
Vector centerPoint = getCenterPoint(x, z);
if (buildOutsideRadius)
return centerPoint.distance(new Vector(x, 0, z)) > roadChunkRadius;
else
return centerPoint.distance(new Vector(x, 0, z)) <= roadChunkRadius;
}
return true;
}
代码示例来源:origin: marcelo-mason/SimpleClans
String name = (cpm.isLeader() ? plugin.getSettingsManager().getPageLeaderColor() : (cpm.isTrusted() ? plugin.getSettingsManager().getPageTrustedColor() : plugin.getSettingsManager().getPageUnTrustedColor())) + cpm.getName();
Location loc = p.getLocation();
int distance = (int) Math.ceil(loc.toVector().distance(player.getLocation().toVector()));
String coords = loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ();
String world = loc.getWorld().getName();
代码示例来源:origin: CitizensDev/CitizensAPI
@Override
public Vector getVector(NPC npc, Collection<NPC> nearby) {
Vector steering = new Vector(0, 0, 0);
Vector pos = npc.getEntity().getLocation().toVector();
int c = 0;
for (NPC neighbor : nearby) {
if (!neighbor.isSpawned())
continue;
double dist = neighbor.getEntity().getLocation().toVector().distance(pos);
Vector repulse = pos.subtract(neighbor.getEntity().getLocation().toVector()).normalize()
.divide(new Vector(dist, dist, dist));
steering = repulse.add(steering);
c++;
}
steering = steering.divide(new Vector(c, c, c));
return steering.subtract(npc.getEntity().getVelocity()).multiply(weight);
}
}
代码示例来源:origin: elBukkit/MagicPlugin
destination = (int)playerLoc.distance(targetLoc);
内容来源于网络,如有侵权,请联系作者删除!