fun to reload
Log in to post a comment.
Canvas.setpenopacity(1)
const t = new Turtle()
for (let it = 0; it < 4; it ++ ) {
let cx = [], cy = []
const N = 40
for (let i = 0; i < N; i++) {
d = -1
for (let j = 0; j < 100; j++) {
nx = -100 + 180 * Math.random()
ny = -100 + 180 * Math.random()
mind = 10**6
for (let k = 0; k < i; k++) {
mind = Math.min(mind, (nx - cx[k])**2 + (ny - cy[k])**2)
}
if (mind > d) {
cx[i] = nx
cy[i] = ny
d = mind
}
}
}
const phi = Math.PI / 4 * it
for (let i = 0; i < N; i++) {
let x = cx[i], y = cy[i]
cx[i] = x * Math.cos(phi) - y * Math.sin(phi)
cy[i] = x * Math.sin(phi) + y * Math.cos(phi)
}
t.left(45)
function fr(x, y) {
f = 0
p = 0.5
for (let i = 0; i < N; i++) {
let dx = x - cx[i], dy = y - cy[i]
f += 1.0 / (Math.sqrt(dx * dx + dy * dy) ** p)
}
f += 1.0 / ((x + 100) ** p)
f += 1.0 / ((100 - x) ** p)
f += 1.0 / ((y + 100) ** p)
f += 1.0 / ((100 - y) ** p)
return f
}
const s = 1
for (let i = 0; i < 50000; i++) {
let x = -100 + 200 * Math.random()
let y = -100 + 200 * Math.random()
f = fr(x, y)
if (f > 5.1 - 0.0 * Math.random()) {
t.jump(x, y)
t.left(360 * Math.random())
t.forward(s)
t.back(2 * s)
t.jump(x, y)
t.left(90)
t.forward(s)
t.back(2 * s)
}
}
}