Segment extends GM_LineSegment { public IDirectPosition getWeightedMiddlePoint(double ratio) { Vector2D vect = new Vector2D(getStartPoint(), getEndPoint()); if (ratio == 1.0) return this.getMiddlePoint(); else if (ratio < 1) { vect.scalarMultiplication(ratio / 2.0); return vect.translate(getStartPoint()); } else { vect.scalarMultiplication(3.0 / (2.0 * ratio)); return vect.translate(getStartPoint()); } } 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 testGetWeightedMiddlePoint() { 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(2.5, 2.5); IDirectPosition p5 = new DirectPosition(7.5, 7.5); Segment segment = new Segment(p1, p2); Assert.assertTrue(p3.equals(segment.getWeightedMiddlePoint(1.0), 0.01)); Assert.assertTrue(p4.equals(segment.getWeightedMiddlePoint(0.5), 0.01)); Assert.assertTrue(p5.equals(segment.getWeightedMiddlePoint(2.0), 0.01)); }