// // PatternCanvas.java // paths // // Created by Graham Wakefield on 11/02/2005. // Copyright 2005 __MyCompanyName__. All rights reserved. // import java.util.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import javax.swing.*; public class PatternCanvas extends Canvas implements Runnable, MouseListener, MouseMotionListener { public static Color background = Color.BLACK; public static Color pointcolor = Color.WHITE; public static int numpoints = 50; public static int maxharmonic = 10; public static double tolerance = 0.001; public static double halfPI = Math.PI/2.0; public static Random r = new Random(); protected Thread t; protected Point2D.Double[] points; protected int[] harmonics; protected Vector[] model; protected Color[] colours; public PatternCanvas() { super(); harmonics = new int[maxharmonic]; for (int i=0;i cd ? ab/cd : cd/ab; ha = abt > cdt ? abt/cdt : cdt/abt; hd = Math.abs(hd); if (hd < maxharmonic) // the ratio is small enough to count { // check if the error is smaller than a % tolerance if ((hd-Math.floor(hd))/hd < tolerance && Math.floor(hd) > 0.0) { // store the results (ratio, dist/ang, pt a, pt b) int h = new Double(Math.floor(hd)).intValue(); PatternApp.debug(h + " : " + hd); Point2D.Double[] p = new Point2D.Double[4]; p[0] = a; p[1] = b; p[2] = c; p[3] = d; model[h].add(p); // update ratio count harmonics[h] += 1; // show the curernt counts for (int i=0;i