カオスの表示 : Logistic Function (メイの漸化式)



// (FAI SysOp 村上さんのソースです)

import java.awt.*;
import java.applet.*;

public class test003 extends Applet {
    double minX = 2.9;
    double maxX = 4.0;
    double minY = 0.0;
    double maxY = 1.0;
    int        skipCount = 40;
    int        plotCount = 60;

    public void paint(Graphics g) {
        Dimension d = size();
        double dX = (maxX - minX) / d.width;
        double dY = (maxY - minY) / d.height;
        double myu = minX;
        setBackground(Color.black);
        g.clearRect(0, 0, d.width, d.height);
        for(int x = 0; x <= d.width; ++x)    {
            double temp = 0.5;
            for (int i = 0; i < skipCount; ++i)    {
                temp = myu * temp * (1.0 - temp);
            }
            g.setColor(Color.getHSBColor(0.0f, 1.0f, 1.0f));
            for (int i = 0; i < plotCount; ++i)    {
                temp = myu * temp * (1.0 - temp);
                int y = (int)Math.round(d.height - (temp - minY) / dY);
                g.setColor(Color.getHSBColor((float)i/plotCount,1.0f,1.0f));
                g.drawLine(x, y, x, y);
            }
            myu += dX;
        }
    }
}