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

argumenten van de constructor:
1) n = hoogte,  2) l = lengte,  3) lr = links = 0 of rechts = 1,   4) draaipunt,

5 en 6)  x,y positie van het draaipunt,  7) hoek,  8) kleur van de parallellogram,  9) lijndikte,  10) lijnkleur

 

class Paral extends Vormen {
//constructor 1  2  3   4  5  6   7    8   9  10
  constructor(n, l, lr, d, x, y, hoek, c, sw, sc) {
    super(x,y,hoek);
    this.n = n;  this.l = l; this.lr = lr; this.d = d; this.x = x; this.y = y;
    this.hoek = hoek; this.c = c, this.sw = sw, this.sc = sc;
 }
 
display() {
 fill(this.c);
 let n = this.n; let l = this.l; let lr = this.lr; let d = this.d;
 strokeWeight(this.sw);
 stroke(this.sc);
 push();
 translate(this.x, this.y);
 rotate(radians(this.hoek));
 beginShape();
 if (d == 0 && lr == 1) {vertex(-(l/2+n/2),n/2);vertex(-(l/2-n/2),-n/2);vertex(n/2+l/2,-n/2);vertex(l/2-n/2,n/2);}
 if (d == 1 && lr == 1) {vertex(0, 0);        vertex(n,-n);         vertex(l+n,-n);    vertex(l, 0);}
 if (d == 2 && lr == 1) {vertex(-n/2,n/2);    vertex(n/2,-n/2);     vertex(n/2+l,-n/2);vertex(l-n/2, n/2);}
 if (d == 3 && lr == 1) {vertex(-n, n);       vertex(0, 0);         vertex(l, 0);    vertex(l-n, n);}
 if (d == 4 && lr == 1) {vertex(-(n+l/2),n);  vertex(-l/2,0);       vertex(l/2, 0);  vertex(-n+l/2, n);}
 if (d == 5 && lr == 1) {vertex(-(n+l), n);   vertex(-l, 0);        vertex(0, 0);    vertex(-n,n);}
 if (d == 6 && lr == 1) {vertex(-(n/2+l),n/2);vertex(-(l-n/2),-n/2);vertex(n/2,-n/2);vertex(-n/2, n/2);}
 if (d == 7 && lr == 1) {vertex(-l, 0);       vertex(-(l-n), -n);   vertex(n, -n);   vertex(0, 0);}
 if (d == 8 && lr == 1) {vertex(-l/2,0);      vertex(n-l/2, -n);    vertex(n+l/2,-n);vertex(l/2, 0);}
 if (d == 0 && lr == 0) {vertex(n/2-l/2, n/2);vertex(-(n/2+l/2),-n/2);vertex(l/2-n/2,-n/2);vertex(l/2+n/2,n/2);}
 if (d == 1 && lr == 0) {vertex(0, 0);        vertex(-n, -n);    vertex(l-n, -n);    vertex(l, 0);}
 if (d == 2 && lr == 0) {vertex(n/2, n/2);    vertex(-n/2, -n/2);vertex(l-n/2, -n/2);vertex(n/2+l, n/2);}
 if (d == 3 && lr == 0) {vertex(n, n);        vertex(0, 0);      vertex(l, 0);       vertex(n+l, n);}
 if (d == 4 && lr == 0) {vertex(n-l/2, n);    vertex(-l/2, 0);   vertex(l/2, 0);     vertex(n+l/2, n);}
 if (d == 5 && lr == 0) {vertex(n-l, n);      vertex(-l, 0);     vertex(0, 0);       vertex(n, n);}
 if (d == 6 && lr == 0) {vertex(-(l-n/2),n/2);vertex(-(l+n/2),-n/2);vertex(-n/2,-n/2);vertex(n/2,n/2);}
 if (d == 7 && lr == 0) {vertex(-l, 0);       vertex(-(n+l), -n);   vertex(-n, -n);  vertex(0, 0);}
 if (d == 8 && lr == 0) {vertex(-l/2, 0);     vertex(-(n+l/2),-n); vertex(-n+l/2,-n);vertex(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, 9) hoek x as, 10) hoek,  11) kleur c

                 

 

class Paral3d extends Vormen {
 
constructor(h, l, lr, d, x, y, z, rotmod, xHoek, 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.xHoek = xHoek; 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(this.xHoek));
 
 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, thish/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();
 }
}