class IGPFamily { PVector mid; float diameter; float radius; ArrayList alphaCircleVectors; ArrayList constructionCircleCenters; ArrayList constructionPartsTwelve; ArrayList constructionPartsSixteen; IGPFamily(float x, float y, float d){ ellipseMode(CENTER); colorMode(RGB, 1.0, 1.0, 1.0, 1.0); mid = new PVector(x, y); diameter = d; radius = d/2; println("New IGP object: x="+mid.x+"/ y="+mid.y+"/ diameter="+diameter); } void setVectorsOnAlphaCircle(){ alphaCircleVectors = new ArrayList (12); alphaCircleVectors.add(getVectorOnAlphaCircle(0)); alphaCircleVectors.add(getVectorOnAlphaCircle(30)); alphaCircleVectors.add(getVectorOnAlphaCircle(60)); alphaCircleVectors.add(getVectorOnAlphaCircle(90)); alphaCircleVectors.add(getVectorOnAlphaCircle(120)); alphaCircleVectors.add(getVectorOnAlphaCircle(150)); alphaCircleVectors.add(getVectorOnAlphaCircle(180)); alphaCircleVectors.add(getVectorOnAlphaCircle(210)); alphaCircleVectors.add(getVectorOnAlphaCircle(240)); alphaCircleVectors.add(getVectorOnAlphaCircle(270)); alphaCircleVectors.add(getVectorOnAlphaCircle(300)); alphaCircleVectors.add(getVectorOnAlphaCircle(330)); } PVector getVectorOnCircle(PVector mid, float degree){ PVector point = new PVector(mid.x + radius*cos(radians(degree)), mid.y + radius * sin(radians(degree))); return point; } PVector getVectorOnAlphaCircle(float degree){ return getVectorOnCircle(mid, degree); } void createSquare(PVector mid, float diameter){ rect(mid.x, mid.y, diameter, diameter); } void createOuterSquare() { stroke(0.0, 0.0, 0.66, 0.4); rectMode(CENTER); createSquare(mid, diameter); } void createInnerSquare() { stroke(0.66, 0.66, 0.66, 0.4); rectMode(CENTER); createSquare(mid, sqrt(sq(diameter)/2)); } void createInnerSquareTilted(float angle){ rectMode(CENTER); stroke(0.66, 0.66, 0.66, 0.4); translate(mid.x, mid.y); pushMatrix(); rotate(radians(angle)); createSquare(new PVector(0, 0), sqrt(sq(diameter)/2)); popMatrix(); translate(mid.x*(-1), mid.y*(-1)); } void createCircle(PVector v) { ellipse(v.x, v.y, diameter, diameter); } void createAlphaCircle() { stroke(1.0, 0.0, 0.0, 1.0); createCircle(mid); } void createConstructionCircles(){ stroke(0.66, 0.66, 0.66, 0.4); for (PVector constructionCircle : constructionCircleCenters) { createCircle(constructionCircle); } } void createLine(PVector from, PVector to){ beginShape(LINES); vertex(from.x, from.y); vertex(to.x, to.y); endShape(); } void createVerticalHorizontalConstructionLines(){ //TODO: add for 16 parts createLine(alphaCircleVectors.get(0), alphaCircleVectors.get(6)); createLine(alphaCircleVectors.get(3), alphaCircleVectors.get(9)); } void createDiagonalConstructionLines(){ //TODO: add for 16 parts createLine(new PVector(constructionCircleCenters.get(1).x-radius, constructionCircleCenters.get(2).y-radius), new PVector(constructionCircleCenters.get(3).x+radius, constructionCircleCenters.get(0).y+radius)); createLine(new PVector(constructionCircleCenters.get(1).x+radius, constructionCircleCenters.get(0).y-radius), new PVector(constructionCircleCenters.get(3).x-radius, constructionCircleCenters.get(2).y+radius)); } void createInnerHexagon(){ stroke(0.0, 0.0, 0.66, 0.4); beginShape(LINES); vertex(alphaCircleVectors.get(1).x, alphaCircleVectors.get(1).y); vertex(alphaCircleVectors.get(3).x, alphaCircleVectors.get(3).y); vertex(alphaCircleVectors.get(3).x, alphaCircleVectors.get(3).y); vertex(alphaCircleVectors.get(5).x, alphaCircleVectors.get(5).y); vertex(alphaCircleVectors.get(5).x, alphaCircleVectors.get(5).y); vertex(alphaCircleVectors.get(7).x, alphaCircleVectors.get(7).y); vertex(alphaCircleVectors.get(7).x, alphaCircleVectors.get(7).y); vertex(alphaCircleVectors.get(9).x, alphaCircleVectors.get(9).y); vertex(alphaCircleVectors.get(9).x, alphaCircleVectors.get(9).y); vertex(alphaCircleVectors.get(11).x, alphaCircleVectors.get(11).y); vertex(alphaCircleVectors.get(11).x, alphaCircleVectors.get(11).y); vertex(alphaCircleVectors.get(1).x, alphaCircleVectors.get(1).y); endShape(); } void createInnerHexagonTilted(float angle){ stroke(0.0, 0.0, 0.66, 0.4); translate(mid.x, mid.y); pushMatrix(); rotate(radians(angle)); beginShape(LINES); vertex(alphaCircleVectors.get(1).x-mid.x, alphaCircleVectors.get(1).y-mid.y); vertex(alphaCircleVectors.get(3).x-mid.x, alphaCircleVectors.get(3).y-mid.y); vertex(alphaCircleVectors.get(3).x-mid.x, alphaCircleVectors.get(3).y-mid.y); vertex(alphaCircleVectors.get(5).x-mid.x, alphaCircleVectors.get(5).y-mid.y); vertex(alphaCircleVectors.get(5).x-mid.x, alphaCircleVectors.get(5).y-mid.y); vertex(alphaCircleVectors.get(7).x-mid.x, alphaCircleVectors.get(7).y-mid.y); vertex(alphaCircleVectors.get(7).x-mid.x, alphaCircleVectors.get(7).y-mid.y); vertex(alphaCircleVectors.get(9).x-mid.x, alphaCircleVectors.get(9).y-mid.y); vertex(alphaCircleVectors.get(9).x-mid.x, alphaCircleVectors.get(9).y-mid.y); vertex(alphaCircleVectors.get(11).x-mid.x, alphaCircleVectors.get(11).y-mid.y); vertex(alphaCircleVectors.get(11).x-mid.x, alphaCircleVectors.get(11).y-mid.y); vertex(alphaCircleVectors.get(1).x-mid.x, alphaCircleVectors.get(1).y-mid.y); endShape(); popMatrix(); translate(mid.x*(-1), mid.y*(-1)); } void createInnerTriangle(){ stroke(0.0, 0.0, 0.66, 0.4); triangle(alphaCircleVectors.get(1).x, alphaCircleVectors.get(1).y, alphaCircleVectors.get(5).x, alphaCircleVectors.get(5).y, alphaCircleVectors.get(9).x, alphaCircleVectors.get(9).y); } void createInnerTriangleTilted(float angle){ stroke(0.0, 0.0, 0.66, 0.4); translate(mid.x, mid.y); pushMatrix(); rotate(radians(angle)); triangle(alphaCircleVectors.get(1).x-mid.x, alphaCircleVectors.get(1).y-mid.y, alphaCircleVectors.get(5).x-mid.x, alphaCircleVectors.get(5).y-mid.y, alphaCircleVectors.get(9).x-mid.x, alphaCircleVectors.get(9).y-mid.y); popMatrix(); translate(mid.x*(-1), mid.y*(-1)); } void display() { createAlphaCircle(); } void displayConstructionLines() { stroke(0.66, 0.66, 0.66, 0.4); createConstructionCircles(); createVerticalHorizontalConstructionLines(); } }