We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, this are my data
name, value
hal,500
wos,1400
interHalWos,300
I would like to represent interHalWos, the intersection between the two variable wos and hal, like on the image beside :
I have done this code below. But it doesnt work. in fact it seems to be more complex, because we might have to calc the coordinate of the two points at the intersection of the circles, and so to deal with area, whereas below I work with line ...
any suggestion ?
Table myData;
float wos, hal, scopus;
float rA, rB, rC ;
float interHalWos, interHalScopus, interScopusWos;
float ax, ay, bx, by;
void setup() {
myData = loadTable("data.csv", "header, tsv");
size(400, 400);
background(100);
purcentCalcul();
ax = width/2;
ay = height/2 ;
strokeWeight(1);stroke(255);point(ax,ay);
rA = map(hal, 0, 100, 0, width/4);
rB = map(wos, 0, 100, 0, width/4);
bx = ax + map(100-hal,0,100,0,rA+rB);
println(bx);
by = ay;
circle("hal", ax,ay, color(0, 255, 0), rA);
circle("wos", bx,by, color(255, 0, 0), rB);
}
void purcentCalcul() {
TableRow findTotal = myData.findRow("total", "name");
TableRow findWos = myData.findRow("wos", "name");
TableRow findHal = myData.findRow("hal", "name");
TableRow findInterhw = myData.findRow("interHalWos", "name");
float sumHalWos = findWos.getInt("value") + findHal.getInt("value") - findInterhw.getInt("value");
wos = findWos.getInt("value") * 100 / sumHalWos;
hal = findHal.getInt("value") * 100 / sumHalWos;
interHalWos = findInterhw.getInt("value") * 100 /sumHalWos;
println("wos % : "+ wos +" hal % : "+hal+" inter % : "+interHalWos);
}
void circle(String name, float x, float y, color couleur, float radius) {
noFill();
stroke(couleur);
strokeWeight(3);
ellipse(x, y, 2*radius, 2*radius);
textAlign(CENTER);
fill(couleur);
text(name, x, y-radius-10);
}