| 
					
				 | 
			
			
				@ -57,10 +57,11 @@ public class CountDistance { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Point point2 = points.get(j); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            double dis = getDistance(point.getX(),point.getY(), point1.getX(), point1.getY()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            double dis2 = getDistance(point.getX(),point.getY(), point2.getX(), point2.getY()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //如果dis = dis2 该点与边垂直 判断到边的距离 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (dis==dis2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Point pointCenter = new Point((point1.getX()+point2.getX())/2.0,(point1.getY()+point2.getY())/2.0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                dis2 = getDistance(point.getX(),point.getY(), pointCenter.getX(), pointCenter.getY()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //获取该点与边的垂足 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Point foot = getFoot(point,point1,point2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (onLineSegment(foot,point1,point2)){//垂足点在线段上,求出最小距离 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                dis2 = getDistance(point.getX(),point.getY(), foot.getX(), foot.getY()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            double min = dis<dis2?dis:dis2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (min<dist){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -117,5 +118,39 @@ public class CountDistance { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return peneralPath.contains(point); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 是否在线段AB上 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static boolean onLineSegment(Point p,Point p1,Point p2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double maxx,minx,maxy,miny; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        maxx = p1.x >p2.x ?p1.x :p2.x ;    //矩形的右边长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        minx = p1.x >p2.x ?p2.x :p1.x ;     //矩形的左边长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        maxy = p1.y >p2.y ?p1.y :p2.y ;    //矩形的上边长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        miny = p1.y >p2.y ?p2.y :p1.y ;     //矩形的下边长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if( ((p.x -p1.x )*(p2.y -p1.y) == (p2.x -p1.x) *(p.y -p1.y)) && ( p.x >= minx && p.x <= maxx ) && ( p.y >= miny && p.y <= maxy)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *获取P点到直线AB的垂足坐标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static Point getFoot(Point p,Point p1,Point p2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Point foot=new Point(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double dx=p1.x-p2.x; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double dy=p1.y-p2.y; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double u=(p.x-p1.x)*dx+(p.y-p1.y)*dy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        u/=dx*dx+dy*dy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        foot.x=p1.x+u*dx; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        foot.y=p1.y+u*dy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return foot; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |