|
|
back to boardYou want solve? See! // find distance between line Ax,Ay Bx,By and point X,Y double R(double Ax,double Ay,double Bx,double By){ double r1,r2; double x=(Ax+Bx)/2.0; double y=(Ay+By)/2.0; do{//(fabs(Ax-Bx)>E1 || fabs(Ay-By)>E1){ -> WA 3 x=(Ax+Bx)/2.0; y=(Ay+By)/2.0; r1=len(Ax,Ay,X,Y); r2=len(Bx,By,X,Y); if(r1>r2){ Ax=x; Ay=y; }else{ Bx=x; By=y; } }while(fabs(r1-r2)>E1); return (len(x,y,X,Y)); } when we find distance between P and some line(Ax Ay Bx By) we must compare r1 and r2! Sorry for my english. P.S E1=1.0e-10 |
|
|