Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 2.42 KB

File metadata and controls

75 lines (61 loc) · 2.42 KB

Cornu Spiral

cornu spiral

Code:

fresnelC(t) {
    let sum = 0;
    let n = 50;
    let dt = t / n;
    for (let i = 0; i < n; i++) {
      let u = i * dt;
      sum += cos((u * u) / 2) * dt;
    }
    return sum;
}

fresnelS(t) {
    let sum = 0;
    let n = 50;
    let dt = t / n;
    for (let i = 0; i < n; i++) {
      let u = i * dt;
      sum += sin((u * u) / 2) * dt;
    }
    return sum;
}

cornuSpiral() {
    let numPoints = 200;
    let maxT = this.a * PI;
    for (let i = 0; i < numPoints; i++) {
      let t = map(i, 0, numPoints, -maxT, maxT);
      let x = this.n + this.r * this.fresnelC(t);
      let y = this.n + this.r * this.fresnelS(t);
      this.points.push(createVector(x, y));
    }
}

Sources:

🌄 Gallery

Recursive circles with cornu spiral

Recursive circles with cornu spiral
Rounded Star with cornu spiral

Rounded Star with cornu spiral
Square skierpinski with cornu spiral

Square skierpinski with cornu spiral
Hilbert curve with cornu spiral

Hilbert curve with cornu spiral