paral 45+90 rl0

 

 

paral 45+90 rl1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

header paral na

classes  "Paral" en "Paral3d"                            terug naar de inleiding

class   "Paral"               zie ook "Paral" in processing

 

class Paral extends Vormen { 
 
constructor(h, l, lr, d, x, y, hoek, c) { 
   super(x,y,hoek); 
   this.h = h;  this.l = l; this.lr = lr; this.d = d; this.x = x; this.y = y; 
   this.hoek = hoek; this.c = c; 
 } 
 
display() { 
 fill(this.c); 
 push(); 
 translate(this.x, this.y); 
 rotate(radians(this.hoek)); 
 beginShape(); 
 if (this.d == 0 && this.lr == 1) {vertex(-(this.l/2+this.h/2),this.h/2);vertex(-(this.l/2-this.h/2),-this.h/2); 
                                   vertex(this.h/2+this.l/2,-this.h/2);vertex(this.l/2-this.h/2,this.h/2);} 
 if (this.d == 1 && this.lr == 1) {vertex(0, 0);vertex(this.h,-this.h); vertex(this.l+this.h,-this.h); vertex(this.l,0);} 
 if (this.d == 2 && this.lr == 1) {vertex(-this.h/2,this.h/2); vertex(this.h/2,-this.h/2); 
                                   vertex(this.h/2+this.l,-this.h/2);vertex(this.l-this.h/2, this.h/2);} 
 if (this.d == 3 && this.lr == 1) {vertex(-this.h, this.h);vertex(0, 0);vertex(this.l, 0);vertex(this.l-this.h,this.h);} 
 if (this.d == 4 && this.lr == 1) {vertex(-(this.h+this.l/2),this.h);vertex(-this.l/2,0); 
                                   vertex(this.l/2, 0);vertex(-this.h+this.l/2, this.h);} 
 if (this.d == 5 && this.lr == 1) {vertex(-(this.h+this.l), this.h);vertex(-this.l, 0);vertex(0, 0);vertex(-this.h,this.h);} 
 if (this.d == 6 && this.lr == 1) {vertex(-(this.h/2+this.l),this.h/2);vertex(-(this.l-this.h/2),-this.h/2); 
                                   vertex(this.h/2,-this.h/2);vertex(-this.h/2,this.h/2);} 
 if (this.d == 7 && this.lr == 1) {vertex(-this.l, 0);vertex(-(this.l-this.h),-this.h);vertex(this.h,-this.h);vertex(0,0);} 
 if (this.d == 8 && this.lr == 1) {vertex(-this.l/2,0);vertex(this.h-this.l/2,-this.h);vertex(this.h+this.l/2,-this.h);vertex(this.l/2,0);} 
 if (this.d == 0 && this.lr == 0) {vertex(this.h/2-this.l/2, this.h/2);vertex(-(this.h/2+this.l/2),-this.h/2); 
                                   vertex(this.l/2-this.h/2,-this.h/2);vertex(this.l/2+this.h/2,this.h/2);} 
 if (this.d == 1 && this.lr == 0) {vertex(0, 0);vertex(-this.h,-this.h);vertex(this.l-this.h,-this.h);vertex(this.l,0);} 
 if (this.d == 2 && this.lr == 0) {vertex(this.h/2,this.h/2);vertex(-this.h/2,-this.h/2); 
                                   vertex(this.l-this.h/2,-this.h/2);vertex(this.h/2+this.l,this.h/2);} 
 if (this.d == 3 && this.lr == 0) {vertex(this.h,this.h);vertex(0,0);vertex(this.l,0);vertex(this.h+this.l,this.h);} 
 if (this.d == 4 && this.lr == 0) {vertex(this.h-this.l/2, this.h);vertex(-this.l/2, 0);vertex(this.l/2, 0);vertex(this.h+this.l/2,this.h);} 
 if (this.d == 5 && this.lr == 0) {vertex(this.h-this.l, this.h);vertex(-this.l, 0);vertex(0, 0);vertex(this.h, this.h);} 
 if (this.d == 6 && this.lr == 0) {vertex(-(this.l-this.h/2),this.h/2);vertex(-(this.l+this.h/2),-this.h/2); 
                                   vertex(-this.h/2,-this.h/2);vertex(this.h/2,this.h/2);} 
 if (this.d == 7 && this.lr == 0) {vertex(-this.l,0);vertex(-(this.h+this.l),-this.h);vertex(-this.h, -this.h);vertex(0,0);} 
 if (this.d == 8 && this.lr == 0) {vertex(-this.l/2, 0);vertex(-(this.h+this.l/2),-this.h);vertex(-this.h+this.l/2,-this.h);vertex(this.l/2,0);} 
 endShape(CLOSE); 
 pop(); 
 } 
}

 

header paral na

                                         De draaipunten 0 t/m 8   Hoogte h = n en lengte l = n

 

"Paral3d"    class in p5.js.                       terug naar de inleiding                    zie ook het voorbeeld 3d animatie met 12 parallellogrammen

 

argumenten van de constructor 1) hoogte h, 2) lengte l , 3) links/rechts lr, 4) draaipunt d, 5) x positie, 6) y positie, 7) z) positie,
                                                   8) rotatie mode, rotmod,  met: 1) 2d rotatie, 2) X rotatie, 3) Y rotatie, 4) Z rotatie (met Xrotate op 45 graden),  9) hoek,  10) kleur c

                 

 

class Paral3d extends Vormen { 
//          1  2  3   4  5  6  7    8      9   10 
constructor(h, l, lr, d, x, y, z, rotmod, hoek, c) { 
   super(x,y,hoek); 
   this.h = h;  this.l = l; this.lr = lr; this.d = d; this.x = x; this.y = y; this.z = z; 
   this.rotmod = rotmod; this.hoek = hoek; this.c = c; 
 } 
 
display() { 
  strokeWeight(1); 
 fill(this.c); 
 push(); 
 translate(this.x, this.y, this.z); 
 if (this.rotmod == 1) rotate(radians(this.hoek)); 
 if (this.rotmod == 2) rotateX(radians(this.hoek)); 
 if (this.rotmod == 3) rotateY(radians(this.hoek)); 
 if (this.rotmod == 4) rotateZ(radians(this.hoek)); 
 if (this.rotmod == 4) rotateX(radians(45)); 
 
 beginShape(); 
 if (this.d == 0 && this.lr == 1) {vertex(-(this.l/2+this.h/2),this.h/2, this.z);vertex(-(this.l/2-this.h/2),-this.h/2,this.z); 
                                   vertex(this.h/2+this.l/2,-this.h/2,this.z);vertex(this.l/2-this.h/2,this.h/2,this.z);} 
 if (this.d == 1 && this.lr == 1) {vertex(0, 0,this.z);vertex(this.h,-this.h,this.z); 
                                   vertex(this.l+this.h,-this.h,this.z);vertex(this.l,0, this.z);} 
 if (this.d == 2 && this.lr == 1) {vertex(-this.h/2,this.h/2,this.z);vertex(this.h/2,-this.h/2,this.z); 
                                   vertex(this.h/2+l,-this.h/2,this.z);vertex(this.l-this.h/2, this.h/2,this.z);} 
 if (this.d == 3 && this.lr == 1) {vertex(-this.h,this.h,this.z);vertex(0, 0,this.z); 
                                   vertex(this.l,0,this.z);vertex(this.l-this.h,this.h,this.z);} 
 if (this.d == 4 && this.lr == 1) {vertex(-(this.h+this.l/2),this.h,this.z);vertex(-this.l/2,0,this.z); 
                                   vertex(this.l/2, 0,this.z);vertex(-this.h+this.l/2, this.h,this.z);} 
 if (this.d == 5 && this.lr == 1) {vertex(-(this.h+this.l),this.h,this.z);vertex(-this.l,0,this.z); 
                                   vertex(0,0,this.z);vertex(-this.h,this.h,this.z);} 
 if (this.d == 6 && this.lr == 1) {vertex(-(this.h/2+this.l),this.h/2,this.z);vertex(-(this.l-this.h/2),-this.h/2,this.z); 
                                   vertex(this.h/2,-this.h/2,this.z);vertex(-this.h/2,this.h/2,this.z);} 
 if (this.d == 7 && this.lr == 1) {vertex(-this.l, 0,this.z);vertex(-(this.l-this.h),-this.h,this.z); 
                                   vertex(this.h,-this.h,this.z);vertex(0,0,this.z);} 
 if (this.d == 8 && this.lr == 1) {vertex(-this.l/2,0,this.z);vertex(this.h-this.l/2,-this.h,this.z); 
                                   vertex(this.h+this.l/2,-this.h,this.z);vertex(this.l/2,0,this.z);} 
 if (this.d == 0 && this.lr == 0) {vertex(this.h/2-this.l/2,this.h/2,this.z);vertex(-(this.h/2+this.l/2),-this.h/2,this.z); 
                                   vertex(this.l/2-this.h/2,-this.h/2,this.z);vertex(this.l/2+this.h/2,this.h/2,this.z);} 
 if (this.d == 1 && this.lr == 0) {vertex(0,0,this.z);vertex(-this.h,-this.h,this.z); 
                                   vertex(this.l-this.h,-this.h,this.z);vertex(this.l,0,this.z);} 
 if (this.d == 2 && this.lr == 0) {vertex(this.h/2,this.h/2,this.z);vertex(-this.h/2,-this.h/2,this.z); 
                                   vertex(this.l-this.h/2,-this.h/2,this.z);vertex(this.h/2+this.l,this.h/2,this.z);} 
 if (this.d == 3 && this.lr == 0) {vertex(this.h,this.h,this.z);vertex(0,0,this.z); 
                                   vertex(this.l,0,this.z);vertex(this.h+this.l,this.h,this.z);} 
 if (this.d == 4 && this.lr == 0) {vertex(this.h-this.l/2,this.h,this.z);vertex(-this.l/2,0,this.z); 
                                   vertex(this.l/2,0,this.z);vertex(this.h+this.l/2,this.h,this.z);} 
 if (this.d == 5 && this.lr == 0) {vertex(this.h-this.l,this.h,this.z);vertex(-this.l,0,this.z); 
                                   vertex(0,0,this.z);vertex(this.h,this.h,this.z);} 
 if (this.d == 6 && this.lr == 0) {vertex(-(this.l-this.h/2),h/2,this.z);vertex(-(this.l+this.h/2),-this.h/2,this.z); 
                                   vertex(-this.h/2,-this.h/2,this.z);vertex(this.h/2,this.h/2,this.z);} 
 if (this.d == 7 && this.lr == 0) {vertex(-this.l,0,this.z);vertex(-(this.h+this.l),-this.h,this.z); 
                                   vertex(-this.h,-this.h,this.z);vertex(0,0, this.z);} 
 if (this.d == 8 && this.lr == 0) {vertex(-this.l/2,0,this.z);vertex(-(this.h+this.l/2),-this.h,this.z); 
                                   vertex(-this.h+this.l/2,-this.h);vertex(this.l/2,0,this.z);} 
 endShape(CLOSE); 
 pop(); 
 } 
}