import java.util.Vector; public static int WIDTH=500; public static int HEIGHT=500; public static int CLOCKWISE=0; public static int ANTICLOCKWISE=1; class Edge { Node node1, node2; float angle1, angle2; public Edge(Node n1, Node n2) { node1=n1; node2=n2; angle1=atan2(node2.y - node1.y, node2.x - node1.x); if (angle1 < 0) angle1+=TWO_PI; angle2=atan2(node1.y - node2.y, node1.x - node2.x); if (angle2 < 0) angle2+=TWO_PI; } public void draw() { line(node1.x,node1.y, node2.x,node2.y); } public String toString() { return "Edge: "+node1.toString()+", "+node2.toString(); } public float angle(Node n) { // return the angle of the edge at Node n if (n==node1) return angle1; else return angle2; } public Node other_node(Node n) { if (n==node1) return node2; else return node1; } public float angle_to(Edge e2, Node node, int direction) { /* returns the absolute angle from this edge to "edge2" around "node" following "direction" */ float a; if (direction==CLOCKWISE) a=this.angle(node) - e2.angle(node); else a=e2.angle(node) - this.angle(node); if (a<0) return a+2*PI; else return a; } } //====================================================================== class EdgeCouple { int [][] array; int size; public EdgeCouple(int nb_edges) { array = new int[nb_edges][2]; size=nb_edges; } }; class EdgeDirection { Edge e; int d; public EdgeDirection(Edge e, int d) { this.e=e; this.d=d; } }; class Graph { public static final int TYPE_POLAR=0; public static final int TYPE_TGRID=1; public static final int TYPE_KENNICOTT=2; public static final int TYPE_TRIANGLE=3; int type; Vector nodes; Vector edges; int xmin,ymin,width,height; public Graph(int type, float xmin, float ymin, float width, float height, float param1, float param2) { this.type=type; nodes=new Vector(100); edges=new Vector(100); float cx,cy,x,y,size; float SQRT_3 = (float)(1.73205080756887729352); Node grid[]; int step,nbcol,nbrow; switch (type) { case Graph.TYPE_POLAR: int nbp=(int)param1; /* number of points on each orbit */ int nbo=(int)param2; /* number of orbits */ float os = (width1.0) ? 1.0 : t+st.STEP; // System.out.println("t: "+t+", t2: "+t2); for (int i=0;i= 1.0) { noLoop(); delay(3000); myinit(); t=0; loop(); } } //int i; void mousePressed() { myinit(); t=0; loop(); }