Ok, this is probably easy but I can’t find a way.
How can I connect two random points with an arc?

The code below shows the final result, but I’d like to do it calculating the arc starting from any position of the two circles.

Thanks for your help.

function setup() {
createCanvas(600, 600);
}
function draw() {
angleMode(DEGREES);
background(0);
stroke(255);
noFill();
let x1 = 170;
let y1 = 170;
let r1 = 30;
let x2 = 400;
let y2 = 400;
let r2 = 50;
circle(x1, y1, r1);
circle(x2, y2, r2);
let d = dist(x1, y1, x2, y2);
let xm = (x1+x2)/2;
let ym = (y1+y2)/2;
arc(xm, ym, d, d, -135, 45);
}

let x1 = 170;
let y1 = 170;
let r1 = 30;
let x2 = 400;
let y2 = 400;
let r2 = 30;
function setup() {
createCanvas(600, 600);
}
function draw() {
angleMode(DEGREES);
background(0);
stroke(255);
noFill();
circle(x1, y1, r1);
circle(x2, y2, r2);
let d = dist(x1, y1, x2, y2);
let xm = (x1+x2)/2;
let ym = (y1+y2)/2;
//let a1 = -135;
//let a2 = 45;
let a1 = atan2(?); // For you to complete.
let a2 = atan2(?); // For you to complete.
arc(xm, ym, d, d, a1, a2);
}
function keyPressed()
{
x2 = random(width/2, width);
y2 = random(height/2, height);
}

The above works!

You will have to look up the atan2() reference and complete the code.

Ah … right. That is much better. Thank you.
I have a lot to learn
Here is my solution …

let x1;
let y1;
let r1 = 30;
let x2;
let y2;
let r2 = 80;
function setup() {
createCanvas(windowWidth, windowHeight);
x1 = random(100, windowWidth - 100);
y1 = random(100, windowHeight - 100);
x2 = random(100, windowWidth - 100);
y2 = random(100, windowHeight - 100);
}
function draw() {
angleMode(DEGREES);
background(0);
stroke(255);
noFill();
// Calculates the discance between the 2 circles
let d = dist(x1, y1, x2, y2);
// Calculates the mid point on the distance
let xm = (x1+x2)/2;
let ym = (y1+y2)/2;
circle(xm, ym, 5);
// Calculates the necessary rotation of the arc
let dx = x2 - x1;
let dy = y2 - y1;
let ang = Math.atan2(dy, dx) * 180 / Math.PI;
push();
translate(xm, ym);
rotate(ang);
arc(0, 0, d, d, 0, 180);
pop();
push();
fill(0);
circle(x1, y1, r1);
circle(x2, y2, r2);
pop();
}

Uhh … nice. Thank you.
This is just a little piece of a much bigger project.
You may know Loopy (LOOPY: a tool for thinking in systems).
I’m trying to develop something on that line but a little more usable for certain training activities.

It will be a loooooooooong journey not being a programmer at all … but with the help of this community … maybe … who knows.