We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I have a question about two ArrayLists of my script.
There are two ArraLists:
for(int i = 0; i < inputPolys.size(); i++){
WB_Polygon2D a = inputPolys.get(i);
for(int j = 0; j < a.points.length; j++ ){
pointsInput1.add(a.points[j]);
}//for
}//for
for(int i = 0; i < intersectPolys.size(); i++){
WB_Polygon2D a = intersectPolys.get(i);
for(int j = 0; j < a.points.length; j++ ){
pointsInput2.add(a.points[j]);
}//for
}//for
The script is dealing with polygons - inputPolys and intersected polygons - intersectPolys. There are N polygons in inputPolys, and from 0 to n-1 polygons in intersectPolys ArrayList (this arrayList changes each frame - the number of objects changes).
What I am doing in these double for() loops is getting the points of polygons and adding them to new ArrayLists
a) pointsInput1 - for inputPolys polygons
b) pointsInput2 - for changing intersectPolys polygons.
Then I want two compare if the location of pointsInput1 (a.points[i].x, a.points[i].y) and pointsInput2(b.points[j].x, b.points[j].y) are the same.
But this is the problem I have.
How to write a code when I want to compare one point of first arraylist with all the other points from second arrayList?
Thanks, Petras
Answers
Although it got nothing to do w/ your code, I think the algorithm used from the code below
to determine whether a Dot is near to each other can be food for thought: :-\"
Dear GoToLoop,
I see that the script you posted is dealing with class Dot. Maybe this is a problem I have as I am not very good at using classes.
Could you review my script? It is actually all about ArrayLists and it uses Hemesh library. At top of the script there are 3 triangles initialized, then they are put into inputPolys ArrayList, then intersected polygons are put into intersectPolys ArrayList.
Then I am dealing with the current problem of comparing points of each list. I found the idea how to compare if each point is in the same location. You could look at function called "substractManyfromOne". But still happened another problem. I got at the same time 9 outcomes (not 1 as I need) in the arrayList "inputPoints3" --> the outcome is showed on display by println function. This happened because, there is for loop that is changing like that (1 object, 2 objects,... 9 objects).
Do you know how to solve it?
Dunno if I'd be able to help you on this. I'm not very good at using 3rd-party libraries yet! 3:-O
Anyways, to raise the chances for some1 to help you out, you should at least post your code well formatted! [..]
After posting it, select it and press the C button (4th button).
Actually, it does no have much with 3rd-party library Hemesh. As it is dealing with a few simple classes and functions. If you have the Hemesh or could install it and take a look how my script works, it would be a big help for me:)
Thanks.
Found it! Yes.