import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.awt.geom.*; import java.util.Arrays; /**This class defines and manipulates the strips associated to a polygon**/ public class Strips { public Strips() {} /**This is a routine specially included for polygons with parallel sides.**/ public static int stripCharacter(PolyWedge P,int n) { int n0=n%P.count; int n1=(n+1)%P.count; Complex z1=P.z[n0]; Complex z2=P.z[n1]; Complex z3=P.getCenter(); Complex z4=Complex.minus(z2,z1); Complex z5=Complex.minus(z3,Complex.average(z1,z2)); int a1=1; if(z4.y/z4.x>0) a1=-1; int a2=1; if(z5.y>0) a2=-1; if((a1==1)&&(a2==-1)) return(1); if((a1==1)&&(a2==1)) return(-1); if((a1==-1)&&(a2==1)) return(1); if((a1==-1)&&(a2==-1)) return(-1); return(0); } /**Given a vertex (and the counterclockwise-adjacent edge) find the vertex farthest from the vertex. This works when the polygon has no parallel sides.**/ public static int farthest(PolyWedge P,int n) { int n0=n%P.count; int n1=(n+1)%P.count; int n2=0; Complex z1=P.z[n0]; Complex z2=P.z[n1]; int parallel=stripCharacter(P,n); if(n>=P.count) parallel=-parallel; double area=0; double max=0; int index=0; for(int i=0;i