double (Line2D aLine) { final double length = getLineLength(aLine.getX1(), aLine.getY1(), aLine.getX2(), aLine.getY2()); if (length == 0) { throw new IllegalArgumentException(toString(aLine) + " has a zero length"); } double deltaX = aLine.getX2() - aLine.getX1(); return deltaX / length; }