xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(255);
translate(windowWidth/2, windowHeight/2)
scale(windowHeight/2, -windowHeight/2)
// Drawing the line network defined by
// F(x,y,t) = 0
// where
// F(x,y,t) = t*y + (1-t)*x - t*(1-t)
let N = 10
stroke(0)
strokeWeight(2/windowHeight)
for(let n=0; n<=N; ++n) {
let t = n/N
let P01 = createVector(0,1-t)
let P12 = createVector(t,0)
line(P01.x, P01.y, P12.x, P12.y)
}
// Let's compute the partial derivative w.r.t. t
// dF/dt(x,y,t) = t*y + (1-t)*x -t*(1-t)
// The envelope conditions are :
// | F(x,y,t) = 0 (1)
// | dF/dt(x,y,t) = 0 (2)
// Rearranging (2) => t = (x-y+1)/2
// Reinjecting into (1) => y² -2*(x+1)*y + (x-1)² = 0
// Solving for y, we obtain :
// y = x+1 +/- sqrt(x) (x>0)
// By symetry of the envelope conditions (using t'=1-t),
// one could use the alternate formula : x = y+1 +/- sqrt(y)
N = 100
stroke(255,0,0)
noFill()
strokeWeight(4/windowHeight)
beginShape()
for(let n=0; n<=N; ++n) {
//*
let x = n/N
let y = x+1-2*sqrt(x)
//let y = x+1+2*sqrt(x)
/*/
let y = n/N
//let x = y+1-2*sqrt(y)
let x = y+1+2*sqrt(y)
//*/
vertex(x,y)
}
endShape()
}