To learn mroe about the superellipse, I recommend watching Daniel Shiffman's Coding Challenge.
sgn(val) {
if (val == 0) {
return 0;
}
return val / abs(val);
}
superellipse() {
for (let theta = 0; theta < TWO_PI; theta += 0.05) {
let na = 2 / this.n;
let x = this.r * pow(abs(cos(theta)), na) * this.a * this.sgn(cos(theta));
let y = this.r * pow(abs(sin(theta)), na) * this.b * this.sgn(sin(theta));
this.points.push(createVector(x, y));
}
}
Hilbert curve background with box rule-set |
Rounded Star with superellipse |
Snake-kolam ruleset with superellipse |
Recurvsive circles2 rule-set, a=3.6,b=1.15,n=1.5 |