This is an advanced pursuit curve. It pretty much is a tessalated shape. This means it spirals inward. This pursuit curve is a bunch of square pursuit curves right next to each other. Here is what it looks like…

advcurv3

Here is the code:

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class AdvancedCurve extends JFrame {
Drow d = new Drow();

public static void main(String args[]) {
new AdvancedCurve();
}

public AdvancedCurve() {
setTitle(“Pursuit curve advanced”);
setSize(600, 600);
add(d);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
}
}

class Drow extends JPanel {
double maxX, maxY, minMax, xCenter, yCenter;

public void init() {
maxX = getWidth();
maxY = getHeight();
minMax = Math.min(maxX, maxY);
xCenter = maxX / 2;
yCenter = maxY / 2;
}

public int iX(float x) {
return Math.round(x);
}

public int iY(float y) {
return (int) (maxX – Math.round(y));
}

public Drow() {
setBackground(Color.BLACK);
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
init();
// g.setColor(Color.green);
float side = (float) (0.95f * minMax);
float halfSide = side / 2;
float h = (float) (halfSide * Math.sqrt(3));
float q = 0.05f;
float p = 1 – q;

/*
* float xA = (float) (xCenter – halfSide); float yA = (float) (xCenter
* – halfSide);
*
* float xB = (float) (xCenter + halfSide); float yB = yA;
*
* float xC = (float) (xCenter); float yC = (float) (yCenter + 0.5f *
* h);
*/

drawSingleCurve(g, 0, 0, 300, 0, 300, 300, 0, 300, p, q);
drawSingleCurve(g, 300, 300, 600, 300, 600, 600, 300, 600, p, q);
drawSingleCurve(g, 0, 300, 0, 600, 300, 600, 300, 300, p, q);
drawSingleCurve(g, 300, 0, 300, 300, 600, 300, 600, 0, p, q);
}

public void drawSingleCurve(Graphics g, float xA, float yA, float xB, float yB,
float xC, float yC, float xD, float yD, float p, float q) {

int iter = 255;
int iter2 = 165;
int iter3 = 0;
for (int i = 0; i < 600; i++) {
if (!(iter <= 10) && !(iter2 <= 10)) {
g.setColor(new Color(iter, iter2, 0));
iter -= 14;
iter2 -= 15;
iter3++;
} else {
if(iter3 >= 255) {
g.setColor(new Color(iter, iter2, 0));
}
else {
g.setColor(new Color(iter, iter2, iter3));
iter3++;
}
}
g.drawLine(iX(xA), iY(yA), iX(xB), iY(yB));
g.drawLine(iX(xB), iY(yB), iX(xC), iY(yC));
g.drawLine(iX(xC), iY(yC), iX(xD), iY(yD));
g.drawLine(iX(xD), iY(yD), iX(xA), iY(yA));

float xA1 = p * xA + q * xB;
float yA1 = p * yA + q * yB;

float xB1 = p * xB + q * xC;
float yB1 = p * yB + q * yC;

float xC1 = p * xC + q * xD;
float yC1 = p * yC + q * yD;

float xD1 = p * xD + q * xA;
float yD1 = p * yD + q * yA;

xA = xA1;
yA = yA1;

xB = xB1;
yB = yB1;

xC = xC1;
yC = yC1;

xD = xD1;
yD = yD1;
}
}
}

Advertisements