Hello! I’m trying to write code that checks if any two lines drawn on the canvas have intersecting points.
Currently, I have an ArrayList of “Line” objects, each containing their own ArrayList of PVectors (“coords”). I want to compare the all of the PVectors in each of the Lines to see which of them match with each other.
I’ve tried using nested loops but the lines always end up comparing their own coordinates to themselves. How do I make it not do this? Is there a better way to do this? Thank you!
for(Line l1: lines){
for (Line l2: lines){
for(PVector c1 : l1.coords){
for(PVector c2 : l2.coords){
if(c1.x==c2.x &&
c1.y== c2.y){
ellipse(c1.x,c1.y,50,50);
}
}
}
}
}