Here's a simple console-mode gizmo you might like to play with...
Comments gratefully recieved.
For the total novice:
Cut and paste the following code into a text application and save it as: DNA.java
Compile the program with: javac DNA.java
And run it with: java DNA
Try different values. Higher numbers make faster waves. Start with an 8.
This is programmed to 'improvise' around the wavelength you choose, so the picking same number twice will not achieve the same result twice.
import java.util.*;
publicclass DNA
{
publicstaticvoid main (String[] args)
{
Random random =new Random();
Scanner in =new Scanner(System.in);
System.out.println("On a scale of 0 to 12, what's your wavelength?:");
int factor = 10-in.nextInt();
int radius1 = random.nextInt(38);
int radius2 = (38-radius1);
double wavemultiplier = factor * 10.5 + 45;
double waveadder = factor * 14.5 + 5;
double wavelength1 = wavemultiplier * random.nextDouble() + waveadder;
double angle1 = random.nextDouble()*2;
angle1 = Math.PI*angle1;
double wavelength2 = wavemultiplier * random.nextDouble() + waveadder;
double angle2 = random.nextDouble()*2;
angle2 = Math.PI*angle2;
int spaces1;
double step1 = Math.PI/wavelength1;
int spaces2;
double step2 = Math.PI/wavelength2;
do
{
spaces1 = (int) Math.round((1+Math.sin(angle1))*radius1);
spaces2 = (int) Math.round((1+Math.sin(angle2))*radius2);
int diff = spaces2 - spaces1;
if (diff >= 0)
{
if (diff == 0)
plot (spaces1,"$$");
elseif (diff == 1)
{
plot (spaces1,"+$X");
}
else
{
plot (spaces1,"++");
plot (diff - 2,"XX");
}
}
else
{
diff = spaces1 - spaces2;
if (diff == 1)
{
plot (spaces2,"X$+");
}
else
{
plot (spaces2,"XX");
plot (diff - 2,"++");
}
spaces1 = spaces2;
}
plot (spaces1,"jon\n");
angle1 += step1;
angle2 -= step2;
for (int delayloop = 0; delayloop <=15000; delayloop++)
{
double fairy = 0;
for (int scale = 0; scale <= 3; scale++)
{
fairy = Math.sin(1);// waste some time.
}
}
}
while (true);
}
publicstaticvoid plot (int x, String y)
{
while (0 != x--)
{
System.out.print(" ");
}
System.out.print(y);
}
}

