gouden spiraal. "Spiraal_8gdt_gk in p5.js" terug naar de inleiding
Spiraal_8gdt_gk is een spiraal van 8 bogen, van ieder 108 graden, samengesteld met 8 gnomons die zijn ontstaan door 9 gouden driehoeken.
De top en tevens draaipunt van de spiraal staat in het (0,0) punt
De argumenten van de constructor
1) "n" = de straal van de eerste boog (boog van 108 graden in gnomon "n"), 2) "lr" = 0 spiraal naar links, "lr" = 1 spiraal naar rechts
3) "r" = aantal bogen (max 8), van groot naar klein, dus voor "r" = 1 is de grootste boog zichtbaar.
4) en 5) x, y positie van de het beginpunt van de spiraal in het punt (0,0), dit is ook het draaipunt,
6) hoek, 7) "sw" = lijndikte, 8) lijnkleur
class Spiraal_8gdt_gk extends Vormen {
//constructor 1 2 4 5 6 7 8 9
constructor(n, lr, r, x, y, hoek, sw, c) {
super(x,y,hoek);
this.n = n; this.lr = lr; this.r = r;
this.x = x; this.y = y; this.sw = sw;
this.hoek = hoek; this.c = c; this.r = r;
}
display() {
stroke(this.c);
noFill();
let lr = this.lr; let r = this.r; let n = this.n;
strokeWeight(this.sw);
push();
translate(this.x, this.y);
rotate(radians(this.hoek));
let phi= (1+sqrt(5))/2; let nphi = n*phi;
let h1 = nphi*sin(radians(72)); let a = nphi-nphi/phi;
let ax1 = (nphi-a)*cos(radians(72)); let ay1 = (nphi-a)*sin(radians(72));
let b = n-n/phi; let ay2 = ay1+b*sin(radians(36));
let c = a-a/phi; let bx1 = c*cos(radians(36));
let by1 = ay2+c*sin(radians(36));
let d = b-b/phi; let e = c-c/phi; let f = d-d/phi; let h = f-f/phi;
let ex1 = c-(e-f*cos(radians(72))); let ey1 = ay2+f*sin(radians(72));
let fx1 = (c-e)+f*cos(radians(36)); let fy1 = ay2+f*sin(radians(36));
let gx1 = (c-e)+(f-h)*cos(radians(36)); let gy1 = ay2+(f-h)*sin(radians(36));
let g = e-e/phi;
//Gulden Gnomon (36,36,108) ontstaan door driehoek n (36,72,72)
if ((r==1 || r==2 || r==3 || r==4 || r==5 || r==6 || r==7 || r==8) && lr==0)
arc(ax1,ay1, n*2 ,n*2, radians(144), radians(252));
if ((r==1 || r==2 || r==3 || r==4 || r==5 || r==6 || r==7 || r==8 ) && lr==1)
arc(-ax1,ay1, n*2,n*2, radians(288), radians(396));
if ((r==2 || r==3 || r==4 || r==5 || r==6 || r==7 || r==8) && lr==0)
arc(0, ay2, a*2 ,a*2,radians(36), radians(144));
if ((r==2 || r==3 || r==4 || r==5 || r==6 || r==7 || r==8) && lr==1)
arc(0, ay2, a*2,a*2, radians(36) , radians(144));
if ((r==3 || r==4 || r==5 || r==6 || r==7 || r==8) && lr==0)
arc(bx1,by1, b*2 ,b*2, radians(288), radians(396));
if ((r==3 || r==4 || r==5 || r==6 || r==7 || r==8) && lr==1)
arc(-bx1,by1, b*2,b*2, radians(144), radians(252));
if ((r==4 || r==5 || r==6 || r==7 || r==8) && lr==0)
arc(c, ay2, c*2 ,c*2, radians(180), radians(288));
if ((r==4 || r==5 || r==6 || r==7 || r==8) && lr==1)
arc(-c,ay2, c*2 ,c*2, radians(252), radians(360));
if ((r==5 || r==6 || r==7 || r==8) && lr==0)
arc(c-e,ay2, d*2 ,d*2, radians(72), radians(180));
if ((r==5 || r==6 || r==7 || r==8) && lr==1)
arc(-(c-e),ay2, d*2,d*2, radians(0), radians(108));
if ((r==6 || r==7 || r==8) && lr==0)
arc(ex1, ey1, e*2 ,e*2, radians(324), radians(432));
if ((r==6 || r==7 || r==8) && lr==1)
arc(-ex1,ey1, e*2,e*2, radians(108), radians(216));
if ((r==7 || r==8) && lr==0)
arc(fx1,fy1, f*2 ,f*2, radians(216), radians(324));
if ((r==7 || r==8) && lr==1)
arc(-fx1,fy1, f*2,f*2, radians(216), radians(324));
if ((r==8) && lr==0)
arc(gx1,gy1, g*2 ,g*2, radians(108), radians(216));
if ((r==8) && lr==1)
arc(-gx1,gy1, g*2,g*2, radians(324), radians(432));
pop();
strokeWeight(1);
}
}