private double distanceToSquared(Entity entity) { return RayUtil.getRayBetween(location, entity.getLocation()).lengthSquared(); }
/** * Maps {0, 0, 0} to {0, 1, 0} and all other vectors to their normalized form. * * @param ray the ray to transform * @return a ray of length 1 */ public static Vector getVelocityRay(Vector ray) { Vector velocityRay = ray.clone(); if (velocityRay.lengthSquared() == 0) { velocityRay.setX(0); velocityRay.setY(1); velocityRay.setZ(0); } else { velocityRay.normalize(); } return velocityRay; }
public static void setVectorLengthSquared(Vector vector, double lengthsquared) { double vlength = vector.lengthSquared(); if (Math.abs(vlength) > 0.0001) { if (lengthsquared < 0) { vector.multiply(-Math.sqrt(-lengthsquared / vlength)); } else { vector.multiply(Math.sqrt(lengthsquared / vlength)); } } }
public static boolean isHeadingTo(Vector offset, Vector velocity) { double dbefore = offset.lengthSquared(); if (dbefore < 0.0001) { return true; } Vector clonedVelocity = velocity.clone(); setVectorLengthSquared(clonedVelocity, dbefore); return dbefore > clonedVelocity.subtract(offset).lengthSquared(); } }
float lengthSquared = (float) current.lengthSquared(); if (minSquared > lengthSquared) { minSquared = lengthSquared; float lengthSquared = (float) v.lengthSquared(); if (lengthSquared >= average) { cacheGreen.add(v);
@Override public SpellResult start(CastContext context) { if (movementSpread > 0) { double entitySpeed = context.getMage().getVelocity().lengthSquared(); if (entitySpeed > 0) { double movementAmount = Math.min(1.0, entitySpeed / (movementSpread * movementSpread)); spread += (movementAmount * maxMovementSpread); if (context.getMage().getDebugLevel() >= 3) { context.getMage().sendDebugMessage(ChatColor.DARK_RED + " Applying spread of " + ChatColor.RED + spread + ChatColor.DARK_RED + " from speed of " + ChatColor.GOLD + context.getMage().getVelocity().length()); } } } return super.start(context); }
if(vehicle.getVelocity().lengthSquared() != 0)
if (v.lengthSquared() > 0.0) { builder.append("(svel=" + v.getX() + "," + v.getY() + "," + v.getZ() + ")");
if (scaledForce.lengthSquared() > 0.001) { SafetyUtils.setVelocity(entity, scaledForce);
distanceSquared = targetDirection.lengthSquared();
Vector velocity = mage.getVelocity().clone(); velocity.setY(0); double speedSquared = velocity.lengthSquared(); velocityCheck = (speedSquared > velocitySquared); double speedSquared = velocity.lengthSquared(); velocityCheck = (speedSquared > velocitySquared);
Vector forceVector = fromVector; forceVector.subtract(toVector); if (forceVector.lengthSquared() < 1) { forceVector = sourceLocation.getDirection(); if (pull) {
@Override public boolean tryAttack(SentinelTrait st, LivingEntity ent) { if (!(st.getLivingEntity() instanceof Player)) { return false; } CSDirector direc = (CSDirector) Bukkit.getPluginManager().getPlugin("CrackShot"); String node = direc.returnParentNode((Player) st.getLivingEntity()); if (node == null) { return false; } Vector faceAcc = ent.getEyeLocation().toVector().subtract(st.getLivingEntity().getEyeLocation().toVector()); if (faceAcc.lengthSquared() > 0.0) { faceAcc = faceAcc.normalize(); } faceAcc = st.fixForAcc(faceAcc); st.faceLocation(st.getLivingEntity().getEyeLocation().clone().add(faceAcc.multiply(10))); ItemStack itm = ((Player) st.getLivingEntity()).getItemInHand(); direc.csminion.weaponInteraction((Player) st.getLivingEntity(), node, false); ((Player) st.getLivingEntity()).setItemInHand(itm); if (st.rangedChase) { st.attackHelper.rechase(); } return true; } }
double distanceSquared = offset.lengthSquared(); Block moveToBlock = targetBlock; int distance = 0;
double distanceSquared = velocity.lengthSquared(); if (distanceSquared < Double.MIN_NORMAL) if (maxMagnitudeSquared != 0D && velocity.lengthSquared() > maxMagnitudeSquared) { velocity = velocity.normalize().multiply(maxMagnitude); magnitude = maxMagnitude;