import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.geom.*; import java.math.*; /**This class defines interval versions of our dyadic planar sets, as well as the routines used in the proof.**/ public class IntervalBox { IntervalComplex z; //the center int k; // - log of the sidelength int type; // type 0 is a square; type 1 is an interval on the real axis; type 2 is the point at infinity GaussianInteger g; //2^{25} times center int DYADIC; public IntervalBox() {} /**For this routine it would be easier to use the power function, but we prefer iterated division.**/ public static IntervalBox create(Box B) { IntervalBox IB=new IntervalBox(); IB.g=new GaussianInteger(B.g.x,B.g.y); Interval R=Interval.powerLookUp(25); Interval X=new Interval(B.g.x); Interval Y=new Interval(B.g.y); X=Interval.times(X,R); Y=Interval.times(Y,R); if(B.g.x==0.0) X=new Interval(0.0); if(B.g.y==0.0) Y=new Interval(0.0); IB.z=new IntervalComplex(X,Y); IB.type=B.type; IB.k=B.k; IB.DYADIC=B.DYADIC; return(IB); } /**Prints out the box**/ public void print() { System.out.print("type "+type+" size "+k+" center "); z.print(); } /**These routines get various pieces of information about the box **/ /**The inverse stereographic image of the center**/ public IntervalVector getCenter() { if(type==2) return(IntervalVector.northPole()); return(IntervalStereo.inverseStereo(z)); } /**side length**/ public Interval sidelength() { Interval d=Interval.powerLookUp (k); return(d); } public Interval sidelengthHalf() { Interval d=Interval.powerLookUp (k+1); return(d); } public Interval sidelengthTwice() { Interval d=Interval.powerLookUp (k-1); return(d); } /**Gets the vertices of a box**/ public IntervalComplex[] toVertices() { Interval d=sidelengthHalf(); if(type==0) { IntervalComplex[] Z=new IntervalComplex[4]; Z[0]=new IntervalComplex(Interval.minus(z.x,d),Interval.minus(z.y,d)); Z[1]=new IntervalComplex(Interval.minus(z.x,d),Interval.plus(z.y,d)); Z[2]=new IntervalComplex(Interval.plus(z.x,d),Interval.plus(z.y,d)); Z[3]=new IntervalComplex(Interval.plus(z.x,d),Interval.minus(z.y,d)); return(Z); } if(type==1) { IntervalComplex[] Z=new IntervalComplex[2]; Z[0]=new IntervalComplex(Interval.minus(z.x,d),z.y); Z[1]=new IntervalComplex(Interval.plus(z.x,d),z.y); return(Z); } IntervalComplex[] Z={new IntervalComplex()}; return(Z); } /**Gets the vertices of a box and then does inverse stereographic projection. The boxes of type 2 corresponds to the infinit point in the plane, which in turn corresponds to the point (0,0,1) on the unit sphere. **/ public IntervalVector[] toVectors() { if(type==0) { IntervalComplex[] Z=toVertices(); IntervalVector[] V=new IntervalVector[4]; for(int i=0;i<4;++i) V[i]=IntervalStereo.inverseStereo(Z[i]); return(V); } if(type==1) { IntervalComplex[] Z=toVertices(); IntervalVector[] V=new IntervalVector[2]; for(int i=0;i<2;++i) V[i]=IntervalStereo.inverseStereo(Z[i]); return(V); } IntervalVector[] V={new IntervalVector(new Interval(0.0),new Interval(0.0),new Interval(1.0))}; return(V); } /**These routines get various of the vertices of a box. The first works for generic boxes, and the second works for intervals contained on the real axis.**/ public IntervalComplex getVertex0(int i,int j) { IntervalComplex[] Z=toVertices(); int q=2*i+j; return(Z[q]); } public IntervalComplex getVertex1(int i) { IntervalComplex[] Z=toVertices(); return(Z[i]); } /**Basic quantities associated to a box**/ /**the quantities underline x, .etc, from the paper. These are only used for boxes which do not cross the coordinate axes**/ public Interval xAbsMin() { Interval r=sidelengthHalf(); Interval t=Interval.minus(Interval.abs(z.x),r); return(t); } public Interval yAbsMin() { Interval r=sidelengthHalf(); Interval t=Interval.minus(Interval.abs(z.y),r); return(t); } public Interval xAbsMax() { Interval r=sidelengthHalf(); Interval t=Interval.plus(Interval.abs(z.x),r); return(t); } public Interval yAbsMax() { Interval r=sidelengthHalf(); Interval t=Interval.plus(Interval.abs(z.y),r); return(t); } /**The min and max coords for a box, magnified by 2^25 **/ public int xMin() { int r=(int)(Math.pow(2,25-k-1)); return(g.x-r); } public int xMax() { int r=(int)(Math.pow(2,25-k-1)); return(g.x+r); } public int yMin() { int r=(int)(Math.pow(2,25-k-1)); return(g.y-r); } public int yMax() { int r=(int)(Math.pow(2,25-k-1)); return(g.y+r); } /**we only care about the right endpoint of the interval.*/ public double xMaxDouble() { Interval r=sidelengthHalf(); Interval t=Interval.plus(z.x,r); return(t.r); } /**The quantity delta **/ public Interval delta() { if(type==2) return(new Interval(0.0)); Interval x=xAbsMin(); Interval y=yAbsMin(); Interval ONE=new Interval(1.0); Interval d1=sidelengthTwice(); Interval d2=Interval.plus(Interval.plus(ONE,Interval.times(x,x)),Interval.times(y,y)); Interval d=Interval.divide(d1,d2); return(d); } public Interval tau() { if(type==2) return(new Interval(0.0)); if(type==1) return(new Interval(1.0)); return(new Interval(1.41421356,1.41421357)); //sqrt 2 } public int confine(IntervalComplex w,int k) { Interval r=Interval.powerLookUp(k+1); IntervalComplex[] Z=this.toVertices(); for(int i=0;ir.l) return(0); } return(1); } }