import java.awt.*; import java.awt.image.*; import java.awt.geom.*; import javax.swing.*; import java.util.Random; public class LV extends JComponent implements Runnable { double initialX, initialY, initialZ; int imageWidth, imageHeight; double delta = 0.001; //double delta = 0.5/3.0; double hDispF = Math.sqrt(3)/2.0; double vDispF = 1.0/2.0; double xLowerLeft, yLowerLeft, xUpperRight, yUpperRight; double pixelWidth, pixelHeight, invPixelWidth, invPixelHeight; double[] ot2D = new double[2]; double[] ot3D = new double[3]; double[] xt2D = new double[2]; double[] xt3D = new double[3]; double[] yt2D = new double[2]; double[] yt3D = new double[3]; double[] zt2D = new double[2]; double[] zt3D = new double[3]; double[] pt2D = new double[2]; double[] pt3D = new double[3]; double[] qt2D = new double[2]; double[] qt3D = new double[3]; //double sigma = 10.0; double B = 8.0/3.0; double R = 28.0; //double aR = 0.2; double bR = 0.2; double cR = 5.7; int counter = 0; double alpha = 1.0; double alpha1 = 1.0; Random randNumGen = new Random(5); BufferedImage bufImage; Graphics2D bufImageGraphic; public LV(int w, int h, double xLL, double yLL, double xUR, double yUR) { initialX = 2.403; initialY = 4.892; initialZ = 4.673; pt3D[0] = 1.1; pt3D[1] = 1.1; pt3D[2] = 1.1; qt3D[0] = 1.1; qt3D[1] = 1.1; qt3D[2] = 1.1; imageWidth = w; imageHeight = h; xLowerLeft = xLL; yLowerLeft = yLL; xUpperRight = xUR; yUpperRight = yUR; pixelWidth = (xUR - xLL)/((double)w); invPixelWidth = ((double)w)/(xUR - xLL); pixelHeight = (yUR - yLL)/((double)h); invPixelHeight = ((double)h)/(yUR - yLL); System.out.println(imageWidth + " " + imageHeight); System.out.println(pixelWidth + " " + pixelHeight); bufImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); bufImageGraphic = bufImage.createGraphics( ); bufImageGraphic.setPaint(Color.black /*white*/); //bufImageGraphic.setPaint(Color.black); bufImageGraphic.fillRect(0, 0, w, h); bufImageGraphic.setPaint(Color.blue); bufImageGraphic.setStroke(new BasicStroke((float)(0.1*pixelHeight))); AffineTransform at = new AffineTransform(invPixelWidth, 0, 0, -invPixelHeight, -invPixelWidth*xLL, invPixelHeight*yUR ); bufImageGraphic.setTransform(at); ot3D[0] = 0; ot3D[1] = 0; ot3D[2] = 0; xt3D[0] = 3; xt3D[1] = 0; xt3D[2] = 0; yt3D[0] = 0; yt3D[1] = 3; yt3D[2] = 0; zt3D[0] = 0; zt3D[1] = 0; zt3D[2] = 3; ot2D = isom(ot3D); xt2D = isom(xt3D); yt2D = isom(yt3D); zt2D = isom(zt3D); bufImageGraphic.setPaint(Color.red); Line2D.Double Lx = new Line2D.Double(ot2D[0], ot2D[1], xt2D[0], xt2D[1]); bufImageGraphic.fill(Lx); bufImageGraphic.setPaint(Color.green); Line2D.Double Ly = new Line2D.Double(ot2D[0], ot2D[1], yt2D[0], yt2D[1]); bufImageGraphic.fill(Ly); bufImageGraphic.setPaint(Color.yellow); Line2D.Double Lz = new Line2D.Double(ot2D[0], ot2D[1], zt2D[0], zt2D[1]); bufImageGraphic.fill(Lz); bufImageGraphic.setPaint(Color.blue); Thread t = new Thread(this); t.start( ); } public void timeStep( ) { //counter++; alpha = alpha + 0.0000001; double[] u3D = new double[3]; double[] v3D = new double[3]; u3D = DLV(pt3D, alpha); double[] u2D = new double[2]; double[] v2D = new double[2]; u2D = isom(u3D); pt2D = isom(pt3D); if ((counter % 100000) == 0) System.out.println( pt3D[0] + " " + pt3D[1] + " " + pt3D[2] + " " + alpha ); Line2D.Double L = new Line2D.Double(pt2D[0], pt2D[1], u2D[0], u2D[1]); bufImageGraphic.fill(L); pt3D[0] = u3D[0]; pt3D[1] = u3D[1]; pt3D[2] = u3D[2]; if (counter > 150000) { alpha1 = alpha1 + 0.0000001; v3D = DLV(qt3D, alpha1); v2D = isom(v3D); qt2D = isom(qt3D); L = new Line2D.Double(qt2D[0], qt2D[1], v2D[0], v2D[1]); bufImageGraphic.setPaint(Color.black /* white */); bufImageGraphic.fill(L); qt3D[0] = v3D[0]; qt3D[1] = v3D[1]; qt3D[2] = v3D[2]; //bufImageGraphic.setPaint(Color.blue); } /* bufImageGraphic.setPaint(Color.red); Line2D.Double Lx = new Line2D.Double(ot2D[0], ot2D[1], xt2D[0], xt2D[1]); bufImageGraphic.fill(Lx); bufImageGraphic.setPaint(Color.green); Line2D.Double Ly = new Line2D.Double(ot2D[0], ot2D[1], yt2D[0], yt2D[1]); bufImageGraphic.fill(Ly); bufImageGraphic.setPaint(Color.yellow); Line2D.Double Lz = new Line2D.Double(ot2D[0], ot2D[1], zt2D[0], zt2D[1]); bufImageGraphic.fill(Lz); */ bufImageGraphic.setPaint(Color.blue); } public void run( ) { try { //while (true) //for(int i = 0; i < 1000000; ++i) for(counter = 0; counter < 10000000; ++counter) { //Loopbody: timeStep( ); repaint( ); Thread.sleep(0); } } catch (InterruptedException ie) {} } double[] DLV(double[] s, double parm) { double u[] = new double[3]; u[0] = delta*( s[0]*(0.5*(1 - s[0]) + 0.5*(1 - s[1]) + 0.1*(1 - s[2])) ) + s[0]; u[1] = delta*( s[1]*(-0.5*(1 - s[0]) - 0.1*(1 - s[1]) + 0.1*(1 - s[2])) ) + s[1]; u[2] = delta*( s[2]*(1.32*(1 - s[0]) + 0.1*(1 - s[1]) + 0.1*(1 - s[2])) ) + s[2]; return u; } double[] isom(double[] s) { double q[] = new double[2]; // q in R^2 q[0] = s[0] + hDispF*s[2]; // s in R^3 q[1] = s[1] + vDispF*s[2]; //q[0] = s[0]; //q[1] = s[2]; return q; } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); //g2.setPaint(Color.blue); //g2.drawImage(image, imageX, imageY, this); g2.drawImage(bufImage, 0, 0, this); } public static void main(String[] args) { JFrame frame = new JFrame("LV"); frame.setBackground(Color.black /* white */); LV plot = new LV(800, 800, -0.1, -0.5, 3.9, 3.5); //Plotter plot = new Plotter(700, 700, -2, -1.5, 1, 1.5); //Plotter plot = new Plotter(700, 700, 0, 0, 700, 700); frame.getContentPane( ).add(plot); frame.setSize(800, 800); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }