import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.awt.geom.*; /**This is wrapper class for a list of points in the plane. The main routines in this class are 1. taking the convex hull of a finite set of points. 2. intersecting two convex polygons. **/ public class PolygonWrapper { Complex[] z=new Complex[1000]; int count; /**Constructors**/ public PolygonWrapper() {} public PolygonWrapper(int cc,Complex[] zz) { this.count=cc; for(int i=0;i.00000001) { Y.z[count]=new Complex(CURRENT); ++count; HISTORY=new Complex(CURRENT); } P.next(); } Y.count=count; return(Y); } public boolean contains(Complex z) { GeneralPath gp=this.toGeneralPath(); return(gp.contains(z.x,z.y)); } /**printout**/ public void print() { System.out.println("count "+count); for(int i=0;i=P.count) match=1; if(n[ct+1]==-1) match=1; Q=roll(Q,n[ct],n[ct+1]); ++ct; } for(int i=0;i.0000000001) { w=Complex.unit(w); test=Complex.dist(w,ONE); if(testd2) return(null); d1=Math.max(Complex.dist(q,w1),Complex.dist(q,w2)); d2=Complex.dist(w1,w2); if(d1>d2) return(null); return(q); } public static Complex intersectRaw(Complex z1,Complex z2,Complex w1,Complex w2) { Vector[] V=new Vector[7]; V[0]=new Vector(z1); V[1]=new Vector(z2); V[2]=new Vector(w1); V[3]=new Vector(w2); V[4]=Vector.cross(V[0],V[1]); V[5]=Vector.cross(V[2],V[3]); V[6]=Vector.cross(V[4],V[5]); Complex w=new Complex(V[6].x[0]/V[6].x[2],V[6].x[1]/V[6].x[2]); return(w); } /**These two routines start with a polygon that may have repeated vertices. The output is a polygon with the repeated vertices weeded out.**/ public PolygonWrapper trim() { PolygonWrapper Q=new PolygonWrapper(); Complex[] LIST=new Complex[this.count]; int c=0; for(int i=0;i