Point { static double distanceFromLineSqrd(Point<? extends Number> pt, Point<? extends Number> ln1, Point<? extends Number> ln2) { final double A = ln1.y.doubleValue() - ln2.y.doubleValue(); final double B = ln2.x.doubleValue() - ln1.x.doubleValue(); double C = A * ln1.x.doubleValue() + B * ln1.y.doubleValue(); C = A * pt.x.doubleValue() + B * pt.y.doubleValue() - C; return C * C / (A * A + B * B); } protected  Point(Point<T> pt); protected  Point(T x, T y, T z); @Override boolean equals(Object obj); void set(Point<T> other); void setX(T x); void setY(T y); void setZ(T z); @Override String toString();  }
@Test public void distanceFromLineSqrdTest() { DoublePoint pt = new DoublePoint(9.2342, 2); DoublePoint ln1 = new DoublePoint(0, 10); DoublePoint ln2 = new DoublePoint(0, 0); Assert.assertEquals(85.27044964, Point.distanceFromLineSqrd(pt, ln1, ln2), DOUBLE_EPSILON_COMPARISON); }