summaryrefslogtreecommitdiffstats
path: root/AutoVisual/IGPSquare.pde
blob: 80e3700bbd3040e60913212876f8a216372a1553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class IGPSquare extends IGPFamily {
	int parts;

  IGPSquare(float x, float y, float d, int p){
		super(x, y, d);
		parts = p;
    setVectorsOnAlphaCircle();
//    setConstructionCircleCenters();
		setVectorsOnOuterSquare();
  }
	
	void setVectorsOnAlphaCircle(){
		constructionCircleCenters = new ArrayList <PVector> (4);
		constructionCircleCenters.add(getVectorOnAlphaCircle(0));
		constructionCircleCenters.add(getVectorOnAlphaCircle(90));
		constructionCircleCenters.add(getVectorOnAlphaCircle(180));
		constructionCircleCenters.add(getVectorOnAlphaCircle(270));
	}

	void setConstructionCircleCenters(){
		constructionCircleCenters = new ArrayList <PVector> (4);
		constructionCircleCenters.add(alphaCircleVectors.get(0));
		constructionCircleCenters.add(alphaCircleVectors.get(3));
		constructionCircleCenters.add(alphaCircleVectors.get(6));
		constructionCircleCenters.add(alphaCircleVectors.get(9));
	}

	void setVectorsOnOuterSquare(){
		int amount = 12;
		constructionPartsTwelve = new ArrayList <PVector>(12);
		constructionPartsTwelve.add(constructionCircleCenters.get(0));
		constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(1).x+radius/2+radius/amount, mid.y-radius));
		constructionPartsTwelve.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y-radius/2-radius/amount));
		constructionPartsTwelve.add(constructionCircleCenters.get(1));
		constructionPartsTwelve.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y+radius/2+radius/amount));
		constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(3).x+radius/2+radius/amount, mid.y+radius));	
		constructionPartsTwelve.add(constructionCircleCenters.get(2));
		constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(3).x-radius/2-radius/amount, mid.y+radius));
		constructionPartsTwelve.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y+radius/2+radius/amount));
		constructionPartsTwelve.add(constructionCircleCenters.get(3));
		constructionPartsTwelve.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y-radius/2-radius/amount));
		constructionPartsTwelve.add(new PVector(constructionCircleCenters.get(1).x-radius/2-radius/amount, mid.y-radius));
		constructionPartsSixteen = new ArrayList <PVector>(16);		
		constructionPartsSixteen.add(constructionCircleCenters.get(0));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x+radius/2-radius/amount, mid.y-radius));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x-radius, constructionCircleCenters.get(2).y-radius));
		constructionPartsSixteen.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y-radius/2+radius/amount));
		constructionPartsSixteen.add(constructionCircleCenters.get(1));
		constructionPartsSixteen.add(new PVector(mid.x+radius, constructionCircleCenters.get(0).y+radius/2-radius/amount));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x+radius, constructionCircleCenters.get(0).y-radius));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x+radius/2-radius/amount, mid.y+radius));	
		constructionPartsSixteen.add(constructionCircleCenters.get(2));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x-radius/2+radius/amount, mid.y+radius));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x+radius, constructionCircleCenters.get(0).y+radius));
		constructionPartsSixteen.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y+radius/2-radius/amount));
		constructionPartsSixteen.add(constructionCircleCenters.get(3));
		constructionPartsSixteen.add(new PVector(mid.x-radius, constructionCircleCenters.get(2).y-radius/2+radius/amount));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(3).x-radius, constructionCircleCenters.get(2).y+radius));
		constructionPartsSixteen.add(new PVector(constructionCircleCenters.get(1).x-radius/2+radius/amount, mid.y-radius));	
	}

	void createDividingConstructionLines(int amount){
		if(amount == 12){
   		stroke(0.0, 0.66, 0.0, 0.4);
			createLine(constructionPartsTwelve.get(0), constructionPartsTwelve.get(6));
			createLine(constructionPartsTwelve.get(1), constructionPartsTwelve.get(7));
			createLine(constructionPartsTwelve.get(2), constructionPartsTwelve.get(8));
			createLine(constructionPartsTwelve.get(3), constructionPartsTwelve.get(9));
			createLine(constructionPartsTwelve.get(4), constructionPartsTwelve.get(10));
			createLine(constructionPartsTwelve.get(5), constructionPartsTwelve.get(11));
		}else if (amount == 16){
			amount = 12;
    	stroke(0.0, 0.0, 0.66, 0.4);
			createLine(constructionPartsSixteen.get(0), constructionPartsSixteen.get(8));
			createLine(constructionPartsSixteen.get(1), constructionPartsSixteen.get(9));
			createLine(constructionPartsSixteen.get(2), constructionPartsSixteen.get(10));
			createLine(constructionPartsSixteen.get(3), constructionPartsSixteen.get(11));
			createLine(constructionPartsSixteen.get(4), constructionPartsSixteen.get(12));
			createLine(constructionPartsSixteen.get(5), constructionPartsSixteen.get(13));
			createLine(constructionPartsSixteen.get(6), constructionPartsSixteen.get(14));
			createLine(constructionPartsSixteen.get(7), constructionPartsSixteen.get(15));
		}
	}

  void display() {
    super.display();
    createOuterSquare();
		if (parts == 16){
			createInnerSquare();
			createInnerSquareTilted(45);
			createDividingConstructionLines(16);
		}else if (parts == 12){
			createDividingConstructionLines(12);
		}
  }

}