当前位置: 首页>>代码示例>>Java>>正文


Java Vector.distanceSquared方法代码示例

本文整理汇总了Java中org.bukkit.util.Vector.distanceSquared方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.distanceSquared方法的具体用法?Java Vector.distanceSquared怎么用?Java Vector.distanceSquared使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.util.Vector的用法示例。


在下文中一共展示了Vector.distanceSquared方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNearest

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public EventRule getNearest(Vector pos) {
    EventRule nearest = null;
    double distance = Double.POSITIVE_INFINITY;

    for(EventRule rule : byPriority) {
        double d = pos.distanceSquared(rule.region().getBounds().center());
        if(d < distance) {
            nearest = rule;
            distance = d;
        }
    }

    return nearest;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:EventRuleContext.java

示例2: distanceSquared

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public double distanceSquared(Vector point) {
    if(delta.isZero()) {
        return point.distanceSquared(start);
    } else {
        final double t = perpendicularProjectionParameter(point);
        if(t <= 0) {
            return point.distanceSquared(start);
        } else if(t >= 1) {
            return point.distanceSquared(finish);
        } else {
            return point.distanceSquared(parametricPoint(t));
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:LineSegment.java

示例3: run

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void run()
{
    final Location playerLocation = player.getLocation();


    // Checks if the player is still on the line

    Vector position   = playerLocation.toVector();
    Vector origin     = getStart().toVector();
    Vector director   = yodel.getAngleVector();
    double k;

    if (isZero(origin)) origin = getEnd().toVector();

    try
    {
        k = director.getX() * (position.getX() - origin.getX())
                + director.getY() * (position.getY() - origin.getY())
                + director.getZ() * (position.getZ() - origin.getZ());

        k /= NumberConversions.square(director.getX())
                + NumberConversions.square(director.getY())
                + NumberConversions.square(director.getZ());
    }
    catch (ArithmeticException e)
    {
        this.hub.getLogger().log(Level.SEVERE, "Division by zero while checking route on yodel, remains unfixed", e);
        return;
    }

    Vector projection = origin.add(director.multiply(k));

    if (projection.distanceSquared(position) > 4)
    {
        player.teleport(projection.toLocation(playerLocation.getWorld()).setDirection(playerLocation.getDirection()));
    }


    // Updates the velocity

    player.setVelocity(velocityStep);
    player.setFallDistance(0);


    // Checks if the line is finished (either we are on the finish zone, or out of the path if for some
    // reason the landing zone was not entered)

    if (playerLocation.distanceSquared(getEnd()) < 6
            || playerLocation.distanceSquared(getStart()) > yodel.getLength() + 10)
    {
        this.yodel.stop(player);
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:55,代码来源:YodelRunner.java

示例4: awayFromSpawn

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * Function to check proximity to nether spawn location
 *
 * @param player
 * @return true if in the spawn area, false if not
 */
private boolean awayFromSpawn(Player player) {
    Vector p = player.getLocation().toVector().multiply(new Vector(1, 0, 1));
    Vector spawn = player.getWorld().getSpawnLocation().toVector().multiply(new Vector(1, 0, 1));
    return spawn.distanceSquared(p) < (Settings.netherSpawnRadius * Settings.netherSpawnRadius);
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:12,代码来源:NetherEvents.java


注:本文中的org.bukkit.util.Vector.distanceSquared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。