protected Point interp(double x1,double y1,double x2,double y2,int width,int height){
  double deltaY=y2 - y1;
  double deltaX=x2 - x1;
  double slope=deltaY / deltaX;
  double newX=x2;
  double newY=y2;
  if (newX < 0) {
    newX=0;
    newY=Math.round(slope * (newX - x1) + y1);
  }
 else   if (newX >= width) {
    newX=width - 1;
    newY=Math.round(slope * (newX - x1) + y1);
  }
  if (newY < 0) {
    newY=0;
    newX=Math.round(x1 + (newY - y1) / slope);
  }
 else   if (newY >= height) {
    newY=height - 1;
    newX=Math.round(x1 + (newY - y1) / slope);
  }
  int intX=(int)newX;
  int intY=(int)newY;
  if (intX < 0) {
    logger.warning("new x is " + intX);
    intX=0;
  }
  if (intX >= width) {
    logger.warning("new x is " + intX);
    intX=width - 1;
  }
  if (intY < 0) {
    logger.warning("new y is " + intY);
    intY=0;
  }
  if (intY >= height) {
    logger.warning("new y is " + intY);
    intY=height - 1;
  }
  if (logger.isLoggable(Level.INFO)) {
    logger.info("from " + x1 + ","+ y1+ " to "+ x2+ ","+ y2+ "w "+ width+ " h "+ height+ " interp "+ intX+ ","+ intY);
  }
  return new Point(intX,intY);
}

protected Point interp ( double x1 , double y1 , double x2 , double y2 , int width , int height ) { double deltaY = y2 - y1 ; double deltaX = x2 - x1 ; double slope = deltaY / deltaX ; double newX = x2 ; double newY = y2 ; if ( newX < 0 ) { newX = 0 ; newY = Math . round ( slope * ( newX - x1 ) + y1 ) ; } else if ( newX >= width ) { newX = width - 1 ; newY = Math . round ( slope * ( newX - x1 ) + y1 ) ; } if ( newY < 0 ) { newY = 0 ; newX = Math . round ( x1 + ( newY - y1 ) / slope ) ; } else if ( newY >= height ) { newY = height - 1 ; newX = Math . round ( x1 + ( newY - y1 ) / slope ) ; } int intX = ( int ) newX ; int intY = ( int ) newY ; if ( intX < 0 ) { logger . warning ( "new x is " + intX ) ; intX = 0 ; } if ( intX >= width ) { logger . warning ( "new x is " + intX ) ; intX = width - 1 ; } if ( intY < 0 ) { logger . warning ( "new y is " + intY ) ; intY = 0 ; } if ( intY >= height ) { logger . warning ( "new y is " + intY ) ; intY = height - 1 ; } if ( logger . isLoggable ( Level . INFO ) ) { logger . info ( "from " + x1 + "," + y1 + " to " + x2 + "," + y2 + "w " + width + " h " + height + " interp " + intX + "," + intY ) ; } return new Point ( intX , intY ) ; }
find a point between x1 , y1 and x2 , y2 that is within the visible map
