grahams-scan

Convex Hull Misunderstanding?

早过忘川 提交于 2019-12-23 19:52:46
问题 I wrote an implementation of Graham's Scan convex hull algorithm and for test data I used the points [(2.0,2.0),(4.0,2.0),(0.5,2.5),(3.0,3.5),(1.0,4.0),(0.0,4.0),(1.0,1.0),(3.0,2.5),(4.0,4.0),(3.5,1.5),(0.5,1.0)] According to my program the convex hull is [(0.0,4.0),(1.0,4.0),(4.0,4.0),(3.0,2.5),(4.0,2.0),(3.5,1.5),(1.0,1.0),(0.5,1.0)] However, I expected the convex hull to be [(0.0,4.0),(1.0,4.0),(4.0,4.0),(4.0,2.0),(3.5,1.5),(1.0,1.0),(0.5,1.0)] I tried my set of points with https://github

Sorting points by their polar angle in Java

不问归期 提交于 2019-11-30 19:37:30
I'm using Graham scan algorithm to find the convex-hull of set of points I'm trying to sort the points by their polar angle but I have no idea how to do it (I've already sorted the set of points by their Y coordinates). What I've already wrote is like this: public double angle(Coord o, Coord a) { return Math.atan((double)(a.y - o.y) / (double)(a.x - o.x)); } where Coord is the class where I have X and Y coordinates as double . I also looked at one of the similar posts in Stack Overflow where someone had tried to implement this angle with C++, but I don't understand qsqrt . Do we have something

Sorting points by their polar angle in Java

不打扰是莪最后的温柔 提交于 2019-11-30 03:42:35
问题 I'm using Graham scan algorithm to find the convex-hull of set of points I'm trying to sort the points by their polar angle but I have no idea how to do it (I've already sorted the set of points by their Y coordinates). What I've already wrote is like this: public double angle(Coord o, Coord a) { return Math.atan((double)(a.y - o.y) / (double)(a.x - o.x)); } where Coord is the class where I have X and Y coordinates as double . I also looked at one of the similar posts in Stack Overflow where

Sort latitude and longitude coordinates into clockwise ordered quadrilateral

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 16:51:33
Problem Users can provide up to four latitude and longitude coordinates, in any order. They do so with Google Maps. Using Google's Polygon API (v3), the coordinates they select should highlight the selected area between the four coordinates. Question How do you sort an array of latitude and longitude coordinates in (counter-)clockwise order? Solutions and Searches StackOverflow Questions Drawing resizable (not intersecting) polygons How to sort points in a Google maps polygon so that lines do not cross? Sort Four Points in Clockwise Order Related Sites http://www.daftlogic.com/projects-google

Sort latitude and longitude coordinates into clockwise ordered quadrilateral

笑着哭i 提交于 2019-11-27 10:09:38
问题 Problem Users can provide up to four latitude and longitude coordinates, in any order. They do so with Google Maps. Using Google's Polygon API (v3), the coordinates they select should highlight the selected area between the four coordinates. Question How do you sort an array of latitude and longitude coordinates in (counter-)clockwise order? Solutions and Searches StackOverflow Questions Drawing resizable (not intersecting) polygons How to sort points in a Google maps polygon so that lines do