header drieh nh90
 
 De driehoeken in de draaipunten met h1 = 2*n
 
Driehoek met 90 graden hoek  "Drieh_nh90"                            terug naar de inleiding
argumenten van de constructor:
1) n = basis,  2)  h1 = hoogte, 3) lr = 1 schuine zijde --> rechts, lr = 0 schuine zijde --> links, 4) draaipunten 0 t/m6, 5) x positie, 6) y positie, 7) hoek, 8) kleur
 
 
 

class Drieh_nh90 extends Vormen {  
   
  Drieh_nh90(float n_, float h1_, int lr_, int d_, float x_, float y_, float hoek_, color c1_) {   
 super();   
 n  = n_;   
 h1 = h1_;  
 lr = lr_; 
 d  = d_;  
 x  = x_;   
 y  = y_;   
 hoek = hoek_;   
 c1 = c1_;     
 }  
   
void display() {   
 fill(c1);   
 pushMatrix();   
 translate(x, y);   
 rotate(radians(hoek));   
 beginShape();  
 if (d == 0 && lr == 0) {vertex(-n/4,h1/4);vertex(-n/4,-3*h1/4);vertex(3*n/4,h1/4);}  
 if (d == 1 && lr == 0) {vertex(0,0);vertex(0,-h1);vertex(n,0);}    
 if (d == 2 && lr == 0) {vertex(0,h1/2);vertex(0,-h1/2);vertex(n,h1/2);}   
 if (d == 3 && lr == 0) {vertex(0,h1);vertex(0,0);vertex(n,h1);}   
 if (d == 4 && lr == 0) {vertex(-n/2,h1/2);vertex(-n/2,-h1/2);vertex(n/2,h1/2);}   
 if (d == 5 && lr == 0) {vertex(-n,0);vertex(-n,-h1);vertex(0,0);}    
 if (d == 6 && lr == 0) {vertex(-n/2,0);vertex(-n/2,-h1);vertex(n/2,0);}  
 if (d == 0 && lr == 1) {vertex(-3*n/4,h1/4);vertex(n/4,-3*h1/4);vertex(n/4,h1/4);}    
 if (d == 1 && lr == 1) {vertex(0,0);vertex(n,-h1);vertex(n,0);}   
 if (d == 2 && lr == 1) {vertex(-n/2,h1/2);vertex(n/2,-h1/2);vertex(n/2,h1/2);}  
 if (d == 3 && lr == 1) {vertex(-n,h1);vertex(0,0);vertex(0,h1);}  
 if (d == 4 && lr == 1) {vertex(-n,h1/2);vertex(0,-h1/2);vertex(0,h1/2);}    
 if (d == 5 && lr == 1) {vertex(-n,0);vertex(0,-h1);vertex(0,0);}     
 if (d == 6 && lr == 1) {vertex(-n/2,0);vertex(n/2,-h1);vertex(n/2,0);}  
 endShape(CLOSE);   
 popMatrix();   
}   
}
 
animatie met 12 driehoeken met 90 graden hoeken      De animatie maakt ook gebruik van objectmethodes van de superclass  ¨Vormen¨.
 
bekijk de roterende driehoeken  met de "s'" toets stopt, en met de "r" toets start de rotatie
Met de "1" worden de ruitjes ingeschakeld en met de "2" weer uitgeschakeld
Om het ruitjespapier  te tonen maakt de schets gebruik van de  "Ruitjes"  class

Met de methode dpAan(); (line 47) worden de draaipunten als rode puntjes getoond.  De methode staat in de superclass  "Vormen"


 

 Vormen[] drieh = new Vormen[12]; 
boolean aan = false; 
Ruitjes ruitjespap; 
 void setup() {  
//  fullScreen(); 
  size(780, 560);  
  float x = width/2;  
  float y = height/2;  
  float n = height/8; 
  ruitjespap = new Ruitjes(n,x,y); 
  drieh[0] = new Drieh_nh90(n, 3*n, 1, 4, x-3*n, y-3*n/2, 90, color(200, 0, 100, 100));  
  drieh[1] = new Drieh_nh90(n, 3*n, 0, 2, x+3*n, y-3*n/2,-90, color(0, 255, 0, 100));   
  drieh[2] = new Drieh_nh90(n, 3*n, 0, 2, x-3*n, y+3*n/2, 90, color(255, 255, 0, 100));    
  drieh[3] = new Drieh_nh90(n, 3*n, 1, 4, x+3*n, y+3*n/2,-90, color(255, 0, 58, 100));    
  drieh[4] = new Drieh_nh90(n, 3*n, 1, 3, x,     y-n/2,   90, color(140, 255, 0, 100));    
  drieh[5] = new Drieh_nh90(n, 3*n, 0, 3, x,     y-n/2,  -90, color(0, 0, 255, 100));    
  drieh[6] = new Drieh_nh90(n, 3*n, 0, 3, x,     y+n/2,   90, color(100, 200, 100, 100));  
  drieh[7] = new Drieh_nh90(n, 3*n, 1, 3, x,     y+n/2,  -90, color(200, 200, 0, 100));    
  drieh[8] = new Drieh_nh90(n, 2*n, 1, 5, x,     y-n/2,    0, color(140, 255, 0, 100));    
  drieh[9] = new Drieh_nh90(n, 2*n, 0, 1, x,     y-n/2,    0, color(0, 0, 255, 100));      
  drieh[10] = new Drieh_nh90(n, 2*n, 0, 1, x,    y+n/2,  180, color(200, 0, 100, 100));  
  drieh[11] = new Drieh_nh90(n, 2*n, 1, 5, x,    y+n/2, -180, color(100, 200, 100, 100));   
}  
  
void draw() {  
  background(#E6FBFF); 
   
  for (int i = 0; i < 12; i++) 
{ 
  drieh[i].display(); 
} 
 
  drieh[0].dpRotRe(drieh[0]); 
  drieh[1].dpRotLi(drieh[1]); 
  drieh[3].dpRotRe(drieh[3]); 
  drieh[2].dpRotLi(drieh[2]); 
  drieh[8].dpRotLi(drieh[8]); 
  drieh[9].dpRotRe(drieh[9]); 
  drieh[10].dpRotRe(drieh[10]); 
  drieh[11].dpRotLi(drieh[11]); 
   
  if (key == '1' || aan ) {          
     ruitjespap.display(); 
     for (int i = 0; i < 12; i++) 
  { 
     drieh[i].dpAan(); 
  } 
     aan = true; 
} 
   
  if (key == '2' && aan ) {          
     aan = false; 
  } 
} 
 
void keyPressed() {     
   if (key == 's') {    
    noLoop();    
  }     
   if (key == 'r') {       
    loop();    
  }    
 }