package Current.plot.Dyadic; import Current.*; import Current.basic.*; import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class ConvexIntersector { public ConvexIntersector() {} /**Ethis routine decides if three points in the plane make a positively oriented triangle or a negatively oriented triangle */ public static int orientation(Complex z1,Complex z2,Complex z3) { double x1,x2; x1=z1.x*z2.y+z2.x*z3.y+z3.x*z1.y; x2=z1.y*z2.x+z2.y*z3.x+z3.y*z1.x; if(x1x2) return(-1); return(0); } /**this routine decides is a point w1 nearly lies on the line segment joining w2 to w3. We just test the triangle inequality. 1 means that there is a near-degeneracy.*/ public static int nearDegeneracy(Complex z1,Complex z2,Complex z3) { double[] d=new double[7]; d[1]=Complex.dist(z1,z3); d[2]=Complex.dist(z1,z2); d[3]=Complex.dist(z2,z3); d[4]=(d[1]+d[2])/d[3]; if(d[4]<1.00000000001) return(1); return(0); } /**this routine checks if a point z0 lies in a region bounded by a convex polygon P*/ public static int checkTouch(Complex z0,Complex[] P) { Complex z1=new Complex(); Complex z2=new Complex(); int total,local; int n=P.length; total=0; for(int i=0;iP[i].x) xmin=P[i].x; if(xmaxP[i].y) ymin=P[i].y; if(ymax1;--kk) { for(int i=1;i