Hi
I’m trying to filter through an arraylist (rectangles) by comparing the locations of the objects in it with the locations of the objects of another arraylist (windows).
The goal eventually is to make different kinds of rectangles depending on the fact that they’re above a window or not.
At the moment it either cuts all rectangles or it cuts none.
class Facade{
....
boolean aboveWindow;
ArrayList< Window> windows;
ArrayList<Rectangle> rectangles;
Facade ( PVector locBuild,PVector dimBuild, int numWindowsHorizontal, int numWindowsVertical, float windowSpacing){
...
aboveWindow=true;
}
void update(){
}
void calculateWindows(float value){
windows = new ArrayList<Window>();
..
for(int i=0; i< numWindowsHor; i++){
for (int j=0; j< numWindowsVer; j++){
float windowX= -(buildingWidth)/2+windowSpacing+(i*(windowWidth +windowSpacing))+windowWidth/2;
float windowY= -(buildingHeight)/2+windowSpacing+(j*(windowHeight+windowSpacing))+windowHeight/2;
if (random(100)<value){
windows.add(new Window(windowX, windowY, windowWidth, windowHeight));
}
//println(" raam nr"+i+"-"+j+":"+ windowX +";"+ windowY +";"+ windowWidth +";"+ windowHeight+";");
}
}
}
void calculateRectangles(){
rectangles = new ArrayList<Rectangle>();
numRectVer=int(buildingHeight/rectSpacing);
numRectHor=int(buildingWidth/rectSpacing);
for(int i=0;i<numRectHor; i++){
for(int j=0;j<numRectVer; j++){
float rectX=-(buildingWidth)/2+(i*rectSpacing)+rectSpacing/2;
float rectY=-(buildingHeight)/2+(j*rectSpacing)+rectSpacing/2;
for (Window w: windows){
if (rectX>(w.loc.x-windowWidth/2) && rectX<(w.loc.x+windowWidth/2)&&
rectY>(w.loc.y-windowHeight/2) && rectY<(w.loc.y+windowHeight/2)){
aboveWindow=false;
}
}
if (aboveWindow){
rectangles.add(new Rectangle(rectX, rectY));
}
//println("rectangle "+i+"-"+j+":"+rectX+";"+rectY+";");
}
}
println("# rectangles:"+rectangles.size());
}
void render(){
for (Window w: windows){
w.render();
}
for (Rectangle r: rectangles){
r.render();
}
}
}
````Preformatted text`
Thanks in advance x