Shape of shared area
in
Programming Questions
•
2 years ago
I am trying to figure out how to calculate the corner points of the shared area between two four sided shapes. That is, I want to be able to draw the shape of the area they have in common and hide the originals.
For example the two shapes in the attached sketch...
Up until now I have only been able to come up with overly complicated ideas and I am sure that there must be a simple mathematical way of doing it.
Any help will be greatly appreciated!
- float[] xA = {50,285,275,45};
float[] yA = {50,45,260,250};
float[] xB = {90,255,345,95};
float[] yB = {150,140,380,350};
void setup(){
size(400,400);
stroke(255);
noFill();
}
void draw(){
background(0);
beginShape();
vertex(xA[0],yA[0]);
vertex(xA[1],yA[1]);
vertex(xA[2],yA[2]);
vertex(xA[3],yA[3]);
endShape(CLOSE);
beginShape();
vertex(xB[0],yB[0]);
vertex(xB[1],yB[1]);
vertex(xB[2],yB[2]);
vertex(xB[3],yB[3]);
endShape(CLOSE);
}
1