public static Point2D interpolatedPoint(Point2D A,Point2D B,double d){
  double r=Math.sqrt(d * d / norm2(A,B));
  if (r < FLT_EPSILON)   return A;
  if (1 - r < FLT_EPSILON)   return B;
  Point2D P=new Point2D.Double(r * B.getX() + (1 - r) * A.getX(),r * B.getY() + (1 - r) * A.getY());
  return P;
}

public static Point2D interpolatedPoint ( Point2D A , Point2D B , double d ) { double r = Math . sqrt ( d * d / norm2 ( A , B ) ) ; if ( r < FLT_EPSILON ) return A ; if ( 1 - r < FLT_EPSILON ) return B ; Point2D P = new Point2D . Double ( r * B . getX ( ) + ( 1 - r ) * A . getX ( ) , r * B . getY ( ) + ( 1 - r ) * A . getY ( ) ) ; return P ; }
interpolates a point on a segment .
