Skip to content

Instantly share code, notes, and snippets.

@sminogue
Created April 13, 2017 13:45
Show Gist options
  • Save sminogue/4400e46a614989a3fabe17c880a22397 to your computer and use it in GitHub Desktop.
Save sminogue/4400e46a614989a3fabe17c880a22397 to your computer and use it in GitHub Desktop.
//Get the four corners and add them to a list fot sorting.
List<Point2D_F64> points = new ArrayList<>();
points.add(polygon.get(2));
points.add(polygon.get(1));
points.add(polygon.get(0));
points.add(polygon.get(3));
//Sort the points so that the array is in TL, TR, BR, BL order
points = sortPoints(points);
//Pull the four points out into variables for ease of use
Point2D_F64 topLeft = points.get(0);
Point2D_F64 topRight = points.get(1);
Point2D_F64 bottomRight = points.get(2);
Point2D_F64 bottomLeft = points.get(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment