Hi I remember I watched a tutorial of coding train channel a year ago that implement a line between balls in a particular distance as above:
class Ball {
PVector org, location;
float a = 10;
float theta, radius, offSet;
int s, dir, d = 50;
Ball(PVector _org, PVector _location, float _radius, int _dir, float _offSet) {
org = _org;
location = _location;
radius = _radius;
dir = _dir;
offSet = _offSet;
}
void run() {
move();
lineBetween();
}
void move() {
location.x = org.x + sin(theta+offSet)*radius;
location.y = org.y + cos(theta+offSet)*radius;
theta += (0.04/4*dir);
}
void lineBetween() {
for (int i=0; i<ballCollection.size(); i++) {
Ball other = (Ball) ballCollection.get(i);
float distance = location.dist(other.location);
if (distance >0 && distance < d) {
stroke(250,250,200);
line(location.x, location.y, other.location.x, other.location.y);
}
}
}
}
can anyone help me find aforementioned tutorial or the source code in p5js?