Interesting. I’ve build few Mathematics Applets 10 years ago. Yet, I can still discover their links on internet. I’ve just found my Spirals Applet being featured at comPADRE – a Physics and Astronomy community site.

Applet is http://www.roussev.org/applets/spiral/spiral.html.

And the Spirals Algorithm is as simple as:

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;

public class HelloSpirals extends Applet {
   int max = 100;
   int centerPosition = 150;
   double angle = 22 / (double) 128;

   public void paint( Graphics g){
      setBackground(Color.black);
      g.setColor(Color.red);

      for (int i = 0; i < max; i++) {
         int[] coordEnd = getCoordinates(i);
         int[] coordStart = getCoordinates(i - 1);
         g.drawLine(centerPosition + coordStart[0],
                         centerPosition + coordStart[1],
                         centerPosition + coordEnd[0],
                         centerPosition + coordEnd[1]);
      }
   }

   private double getAngle( int inx){
      return (inx - 1) * angle;
   }

   private int[] getCoordinates( int inx){
      double angle = getAngle(inx - 1);
      int x = (int) Math.round(inx * Math.cos(angle));
      int y = (int) Math.round(inx * Math.sin(angle));

      return new int[] { x, y };
   }
}