Hi!
I have 50ish Vector2 representing the endpoint of a raycast and I’d like to arrange them by thier angle. This is for creating a light mesh so it means 50ish * number of lights.
Right now I’m using Java’s TreeMap to do so. I have a one map for each light. It works fine but I’m not sure if my method is correct.
Since the points change (wich means the angles change aswell) almost every update I constnalty have to clear the TreeMap, and fill it like this: map.put(angle, new Vector2(x, y)).
This way I have to create a lot of objects plus I’m not sure if the TreeMap is the best way to go here. Apparently I cant use a ‘temp’ Vector2 and just set a different value for it and add that to the map because it just discards it.
Thing is I’m not too familiar with the Maps of Java / Libgdx nor thier sorting performance.
My question is if there is a better Map or a better method to contain a bunch of Vector2s and sort them by thier angle.
Any help is much appreciated!