Segment extends GM_LineSegment { public boolean containsPoint(IDirectPosition point, double tolerance) { Vector2D vect1 = new Vector2D(startPoint(), point); Vector2D vect2 = new Vector2D(point, endPoint()); Vector2D vect3 = new Vector2D(startPoint(), endPoint()); if (!vect1.isColinear(vect2, tolerance)) return false; double kAC = vect3.prodScalaire(vect1); double kAB = vect3.prodScalaire(vect3); if (kAC < 0) return false; if (kAC > kAB) return false; return true; } Segment(IDirectPosition point1, IDirectPosition point2); double getCoefA(); double getCoefB(); double getCoefC(); Segment getPerpendicularSegment(boolean start); Segment getBisectionSegment(); IDirectPosition straightLineIntersection(Segment other); Set<IDirectPosition> intersectionWithCircle(IDirectPosition centre,
      double radius); double distanceToPoint(IDirectPosition point); double orientation(); void print(); static List<Segment> getSegmentList(ILineString line); static List<Segment> getSegmentList(IPolygon polygon,
      IDirectPosition origin); static List<Segment> getSegmentList(IRing ring, IDirectPosition origin); static List<Segment> getReverseSegmentList(IPolygon polygon,
      IDirectPosition origin); static List<Segment> getReverseSegmentList(IRing ring,
      IDirectPosition origin); boolean containsPoint(IDirectPosition point, double tolerance); boolean containsPoint(IDirectPosition point); boolean lineContainsPoint(IDirectPosition point); boolean lineContainsPoint(IDirectPosition point, double tolerance); IDirectPosition getMiddlePoint(); IDirectPosition getWeightedMiddlePoint(double ratio); Segment extendAtExtremities(double length);  }
@Test public void testContainsPoint() { IDirectPosition p1 = new DirectPosition(0.0, 0.0); IDirectPosition p2 = new DirectPosition(10.0, 10.0); IDirectPosition p3 = new DirectPosition(5.0, 5.0); IDirectPosition p4 = new DirectPosition(25.0, 25.0); Segment segment = new Segment(p1, p2); Assert.assertTrue(segment.containsPoint(p3)); Assert.assertFalse(segment.containsPoint(p4)); }