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)
| 569 | * @see Vector |
| 570 | */ |
| 571 | public double distanceSquared(@NotNull Location o) { |
| 572 | if (o == null) { |
| 573 | throw new IllegalArgumentException("Cannot measure distance to a null location"); |
| 574 | } else if (o.getWorld() == null || getWorld() == null) { |
| 575 | throw new IllegalArgumentException("Cannot measure distance to a null world"); |
| 576 | } else if (o.getWorld() != getWorld()) { |
| 577 | throw new IllegalArgumentException("Cannot measure distance between " + getWorld().key().asString() + " and " + o.getWorld().key().asString()); |
| 578 | } |
| 579 | |
| 580 | return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z); |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * Performs scalar multiplication, multiplying all components with a |