/** * Sets the direction. This or setting the ending location is required * and can only be done once. * * @param direction The direction * @return This for chained calls */ public BlockRayBuilder<E> direction(Vector3d direction) { checkState(this.direction == null, "Direction has already been set"); checkNotNull(direction, "direction"); checkArgument(direction.lengthSquared() != 0, "Direction must be a non-zero vector"); this.direction = direction.normalize(); return this; }
/** * Returns whether the given vector is along this axis. * * @param vector The vector to test * @return True if it is along this axis */ public boolean isVectorAlongAxis(final Vector3d vector) { return vector.abs().normalize().sub(this.direction).lengthSquared() == 0; }
Direction(Vector3d direction, Division division) { if (direction.lengthSquared() == 0) { // Prevent normalization of the zero direction this.offset = direction; } else { this.offset = direction.normalize(); } this.blockOffset = direction.round().toInt(); this.division = division; }
private BlockRay(Predicate<BlockRayHit<E>> skipFilter, Predicate<BlockRayHit<E>> stopFilter, E extent, Vector3d position, Vector3d direction, boolean narrowPhase, double distanceLimit) { checkArgument(direction.lengthSquared() != 0, "Direction cannot be the zero vector");
@Override public int compareTo(Vector3d v) { return (int) Math.signum(lengthSquared() - v.lengthSquared()); }
@Override public int compareTo(Vector3d v) { return (int) Math.signum(lengthSquared() - v.lengthSquared()); }
@Override public double length() { return (double) Math.sqrt(lengthSquared()); }
@Override public double length() { return (double) Math.sqrt(lengthSquared()); }
/** * Sets the direction. This or setting the ending location is required and can only be done once. * * @param direction The direction * @return This for chained calls */ public BlockRayBuilder<E> direction(Vector3d direction) { checkState(this.direction == null, "Direction has already been set"); checkNotNull(direction, "direction"); checkArgument(direction.lengthSquared() != 0, "Direction must be a non-zero vector"); this.direction = direction.normalize(); return this; }
/** * Returns whether the given vector is along this axis. * * @param vector The vector to test * @return True if it is along this axis */ public boolean isVectorAlongAxis(final Vector3d vector) { return vector.abs().normalize().sub(this.direction).lengthSquared() == 0; }
Direction(Vector3d direction, Division division) { if (direction.lengthSquared() == 0) { // Prevent normalization of the zero direction this.offset = direction; } else { this.offset = direction.normalize(); } this.blockOffset = direction.round().toInt(); this.division = division; }
private BlockRay(Predicate<BlockRayHit<E>> skipFilter, Predicate<BlockRayHit<E>> stopFilter, E extent, Vector3d position, Vector3d direction, boolean narrowPhase, double distanceLimit) { checkArgument(direction.lengthSquared() != 0, "Direction cannot be the zero vector");