summaryrefslogtreecommitdiffstats
path: root/AutoVisual/IGPSquare.pde
blob: b23176f6cc2031a9207dda2ada24ef4abcb363fc (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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 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(alphaCircleVectors.get(0));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(1), mid.x+radius, false));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(2), mid.y-radius, true));
    constructionPartsTwelve.add(alphaCircleVectors.get(3));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(4), mid.y-radius, true));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(5), mid.x-radius, false));
    constructionPartsTwelve.add(alphaCircleVectors.get(6));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(7), mid.x-radius, false));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(8), mid.y+radius, true));
    constructionPartsTwelve.add(alphaCircleVectors.get(9));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(10), mid.y+radius, true));
    constructionPartsTwelve.add(extendLine(mid, alphaCircleVectors.get(11), mid.x+radius, false));
 
    constructionPartsSixteen = new ArrayList <PVector>(16);
    constructionPartsSixteen.add(alphaCircleVectorsSixteen.get(0));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(1), mid.x+radius, false));
    constructionPartsSixteen.add(new PVector(mid.x+radius, mid.y-radius));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(3), mid.y-radius, true));
    constructionPartsSixteen.add(alphaCircleVectorsSixteen.get(4));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(5), mid.y-radius, true));
    constructionPartsSixteen.add(new PVector(mid.x-radius, mid.y-radius));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(7), mid.x-radius, false));
    constructionPartsSixteen.add(alphaCircleVectorsSixteen.get(8));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(9), mid.x-radius, false));
    constructionPartsSixteen.add(new PVector(mid.x-radius, mid.y+radius));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(11), mid.y+radius, true));
    constructionPartsSixteen.add(alphaCircleVectorsSixteen.get(12));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(13), mid.y+radius, true));
    constructionPartsSixteen.add(new PVector(mid.x+radius, mid.y+radius));
    constructionPartsSixteen.add(extendLine(mid, alphaCircleVectorsSixteen.get(15), mid.x+radius, false));
  }

  void createDividingLines(){
      stroke(0.0, 0.66, 0.0, 0.4);
    if(parts == 12){
      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 (parts == 16){
      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 createDividingConstructionLines(){
    if(parts == 12){
      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 (parts == 16){
      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();
    createDividingLines();
  }

  void displayConstructionLines(){
    super.displayConstructionLines();
    createDiagonalConstructionLinesOnOuterSquare();
    if (parts == 16){
      createInnerSquare();
      createInnerSquareTilted(45);
    }
    createDividingConstructionLines();
  }
}