Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euclidean1D> { public double distance(final Vector2D p) { return FastMath.abs(getOffset(p)); } Line(final Vector2D p1, final Vector2D p2, final double tolerance);  Line(final Vector2D p, final double angle, final double tolerance); private  Line(final double angle, final double cos, final double sin,
                 final double originOffset, final double tolerance); @Deprecated  Line(final Vector2D p1, final Vector2D p2); @Deprecated  Line(final Vector2D p, final double angle);  Line(final Line line); Line copySelf(); void reset(final Vector2D p1, final Vector2D p2); void reset(final Vector2D p, final double alpha); void revertSelf(); Line getReverse(); Vector1D toSubSpace(Vector<Euclidean2D> vector); Vector2D toSpace(Vector<Euclidean1D> vector); Vector1D toSubSpace(final Point<Euclidean2D> point); Vector2D toSpace(final Point<Euclidean1D> point); Vector2D intersection(final Line other); Point<Euclidean2D> project(Point<Euclidean2D> point); double getTolerance(); SubLine wholeHyperplane(); PolygonsSet wholeSpace(); double getOffset(final Line line); double getOffset(Vector<Euclidean2D> vector); double getOffset(final Point<Euclidean2D> point); boolean sameOrientationAs(final Hyperplane<Euclidean2D> other); Vector2D getPointAt(final Vector1D abscissa, final double offset); boolean contains(final Vector2D p); double distance(final Vector2D p); boolean isParallelTo(final Line line); void translateToPoint(final Vector2D p); double getAngle(); void setAngle(final double angle); double getOriginOffset(); void setOriginOffset(final double offset); static Transform<Euclidean2D, Euclidean1D> getTransform(final AffineTransform transform);  }
@Test public void testDistance() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2), 1.0e-10); Assert.assertEquals(+5.0, l.distance(new Vector2D(5, -3)), 1.0e-10); Assert.assertEquals(+5.0, l.distance(new Vector2D(-5, 2)), 1.0e-10); }