Questions tagged [grahams-scan]

Graham's scan is a method of computing the convex hull of a finite set of points in the plane with time complexity O(n log n). It is named after Ronald Graham, who published the original algorithm in 1972. The algorithm finds all vertices of the convex hull ordered along its boundary.

34 questions
1
vote
1 answer

Convex Hull Not Returning Right Path ( Graham Scan in C++)

I have done the algorithm the expected output is : p00 - p01, p01 - p03 , p03 - p10, p10 - p12 , p12 - p00 But I get this instead: Convex hull: p00 - p01 p01 - p03 p03 - p05 p05 - p10 p10 - p00 Points: p00: (-5,-6) p01: (6,-4) p02:…
1
vote
1 answer

How to generate worst case data for Graham Scan

I know that the worse case running time of graham scan is O(nlogn) but I am not sure how to generate the worst case data. From what I understood, this occurs at the step where points are being sorted, so does that mean I should generate the worst…
Theo0201
  • 27
  • 6
1
vote
1 answer

What's wrong with my Graham Scan function?

I almost finish the chapter 3 of Real World Haskell. The last exercise blocks me. My code will crash while running. Does anyone can tell me which part is wrong in my code? Thanks. Question: Using the code from the preceding three exercises,…
Sieg
  • 67
  • 1
  • 9
1
vote
1 answer

Draw a convex hull on a google map

I am new to javascript and working with google maps API for javascript. This is an asignment for school and we were provided with a working script and some php code to display a map, get the position, update the position and so on. Our task is to…
Xilef
  • 81
  • 11
1
vote
1 answer

extra point in convex hull (using graham scan) error + java

my code which is using graham algorithm to find the convex hull works pretty well (it shows me the polygon it suppose to show) but I can see that it sends me one extra collinear point (though I'm handling the collinear point in my code) here is my…
Navid Koochooloo
  • 285
  • 1
  • 5
  • 20
0
votes
0 answers

Graham scan when the points are already sorted by one of the coordinates

The Wikipedia entry for convex hull algorithms states: Graham scan — O(n log n) A slightly more sophisticated, but much more efficient algorithm, published by Ronald Graham in 1972. If the points are already sorted by one of the coordinates or by…
Rafael Almeida
  • 2,377
  • 3
  • 22
  • 32
0
votes
2 answers

Can you pattern match integers to ranges in OCaml?

As part of Graham's Scan, I am writing a function that determines whether the line is turning left or right at a certain point. Considering we have a function determinant point -> point -> point -> int where determinant p0 p1 p2 returns det(p0p1,…
ice-wind
  • 690
  • 4
  • 20
0
votes
1 answer

Graham Scan Convex Hull appending too many vertices

As above I am trying to implement a Graham Scan Convex Hull algorithm but I am having trouble with the stack appending too many vertices. The points are read from a .dat file here For reading points my function is as follows: def…
user8072934
0
votes
1 answer

Checking for a nonleft turn in Graham's scan

Following the description of the Graham's scan algorithm from Cormen's "Introduction to Algorithms" I found out the following note: By checking for a nonleft turn, rather than just a right turn, this test precludes the possibility of a straight…
rdiachenko
  • 696
  • 9
  • 15
0
votes
0 answers

Calculate contour by using Gaham Scan

In my code I get the coordinates of points stored in a vector called matrix. The points aren't sorted, so I have to sort them. Since I do not know whether the contour forms a convex hull I have to modify the Graham scan. I decided to use the…
user3794592
  • 183
  • 2
  • 16
0
votes
1 answer

Need help accepting points from a file and adding them to an array Java (Grahams Scan)

I am supposed to read points from a file and accept those points as an array so that I can implement Grahams Scan, however my program only seems to accept the first line of points can anyone help? import java.io.*; import java.util.*; public class…
IcySun
  • 15
  • 2
  • 6
0
votes
1 answer

Trouble with Graham's Scan

currently working on with Graham's Scan in conjunction with Convex HUll. I am a student, so I am trying to get it done myself, however I've been sifting through multiple sites to find an answer. In short I have my constructors, one from a file and…
Loomiss
  • 11
  • 1
  • 1
  • 6
0
votes
2 answers

Graham Scan Algorithm -> sqrt and arctan2 huge values

I have to implement Graham Scan Algorithm. This is my code: /* Graham's algorithm' */ #include #include #include #include #include #include #include…
dudeck
  • 393
  • 5
  • 13
0
votes
1 answer

How can I make min_element catch ALL points with the lowest value?

I'm writing a program to calculate the perimeter of a convex hull using the graham scan and need to find the lowest y coordinate in a set of data points. I'm using std::min_element(vector.begin(), vector.end()) with an overloaded < operator in my…
Syntactic Fructose
  • 18,936
  • 23
  • 91
  • 177
0
votes
1 answer

Implementing Graham Scan in C#

I'm trying to implement a Graham Scan from the Wikipedia pseudo-code, and am running into a little trouble translating things into C#. Perhaps you wouldn't mind taking a look? Here's what I have: public class GrahamScan { public static…
user978122
  • 5,531
  • 7
  • 33
  • 41