Aashijit
1/31/2016 - 7:32 AM

Logarithmic Spiral

Logarithmic Spiral

import java.util.ArrayList;

/**
 * Created by LENOVO on 06-01-2016.
 */
public class curves
{
    ArrayList<String> al=new ArrayList<>();
    double a=3,b=0.200029;
    public curves()
    {
        make_way();
        new draw(al);
    }

    private void make_way()
    {
       double x,y,xfin,yfin;
        int ax,ay;
        for(double t=0;t<=1000;t++)
        {
            double rad=(3.14/180.00)*t;
         x=a*Math.exp(b*rad)*Math.cos(rad);
         y=a*Math.exp(b*rad)*Math.sin(rad);
         xfin=x*5+200;
            yfin=y*5+400;
            ax=(int)xfin;
            ay=(int)yfin;
           // System.out.println(xfin+"\t"+yfin);
        al.add(ax+","+ay);
        }
    }
    public static void main(String[] args)
    {
     new curves();
    }
}
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

/**
 * Created by LENOVO on 06-01-2016.
 */
public class draw extends JFrame
{
    ArrayList<String> al;
    public draw(ArrayList<String> al)
    {
        super("hellw");
        this.al=al;
        setSize(800,800);
        getContentPane().setBackground(new Color(0,0,0));
        enable e=new enable();
        add(e);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }



    public class enable extends Canvas
    {
        public enable()
        {

        }
        @Override
        public void paint(Graphics g)
        {
            g.setColor(new Color(255,255,255));
            for(int i=0;i<al.size();i++)
            {
             String[] tmp=al.get(i).split(",");
                int x=getWidth()/3+Integer.parseInt(tmp[0]);
                int y=getHeight()-Integer.parseInt(tmp[1]);
                g.drawRect(x,y,1,1);
              //  String[] tmp1=al.get(i+1).split(",");
                //int x1=Integer.parseInt(tmp1[0]);
                //int y1=800-Integer.parseInt(tmp1[1]);
                //g.drawLine(x,y,x1,y1);
                //g.drawArc(x,y,Math.abs(x1-x),Math.abs(y1-y),10,180);
            }
        }
    }
}