i want to sort a list of two dimensional points based on their polar angles with respect to a particular point. this will a part of a bigger code to find collinear objects from a set of points.
the method i thought of for doing this is is:
- create an arraylist of Point2D points
- use the POLAR_ORDER comparator of the above Point2D class.
the code i thought of for this is :
// setting things up and stuff
ArrayList<Point2D> p = new ArrayList<Point2D>();
// more code that i'll have to think of
Collections.sort(p, p.get(0).POLAR_ORDER);
// other stuff
will the above two lines work? i really dont know what to put in between them yet, so im yet to run simple tests...
if the above two lines work then ill proceed in the way that iv thought of, else back to the drawing board..
edit: im intending to sort the points according to polar angle it makes with the 1st point contained in the arraylist. im assuming p.get(0) gives the 1st element... ??