Get the squared distance between this location and another. @param o The other location @return the distance @throws IllegalArgumentException for differing worlds @see Vector
(@NotNull Location o)
| 492 | * @see Vector |
| 493 | */ |
| 494 | public double distanceSquared(@NotNull Location o) { |
| 495 | if (o == null) { |
| 496 | throw new IllegalArgumentException("Cannot measure distance to a null location"); |
| 497 | } else if (o.getWorld() == null || getWorld() == null) { |
| 498 | throw new IllegalArgumentException("Cannot measure distance to a null world"); |
| 499 | } else if (o.getWorld() != getWorld()) { |
| 500 | throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName()); |
| 501 | } |
| 502 | |
| 503 | return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z); |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * Performs scalar multiplication, multiplying all components with a |