I need to code the Graham scan algorithm to find convex hull of a given set of points. I have been trying a lot and, I do not achieve a solution. I have the following code for graham function grahamScanConvexHull<-function(points){ vertices <- data.frame(x=double(), y=double()) flag <- T # Get the most left down_point and leave […]

- Tags 'p' = i)) } Code of quicksort_angle() quicksort_angle<-function(points, 'P': 1, 'p'=i)) } less_angle<-function(check_point, 'Pop', ], ] } }else{ point_0 <- points[1, ] }else{ point_0 <- points[2, ] <- points[j, ] <- temp return(points) }, ]) } next_to_top <- function(stack){ return(stack[2, ]) } return(vertices) } For managing the stack I have code this short auxiliary function top <- function(stack){ return(stack[1, ]) for(i in 1:nrow(points)){ next_to_top <- c(next_to_top(vertices)$x, ]$x < points[2, ]$x){ point_0 <- points[1, ]$y < pivot$y) { points <- swap(points, ]$y == points[2, ]$y) while(nrow(vertices) >= 2 & (rightTurn(next_to_top, ]$y){ if(points[1, 1, 3:nrow(points)), B, C) { val <- (B[1] - A[1]) * (C[2] - A[2]) - (B[2] - A[2]) * (C[1] - A[1]) return(val) } The sorting functions I have checked many ti, e){ if(e$x %in% stack$x & e$y %in% stack$y ){ if(which(e$x %in% stack$x) == which(e$y %in% stack$y)){ return(stack) }else{, flag, High, high) { if (low < high) { list_particion <- partition_bottom_top(points, high) { pivot <- points[high, high) } return(points) } partition_bottom_top <- function(points, high) p <- list_particion[['p']] points <- list_particion[['points']] points <- quicksort_bottom_top(points, high) return(list('points' = points, high) return(list('points'=points, i, I am plenty sure they are fine (also I have been using them for a long time without any problem). I do not know what I am doing wrong so any, I do not achieve a solution. I have the following code for graham function grahamScanConvexHull<-function(points){ vertices <- data.frame, I need to code the Graham scan algorithm to find convex hull of a given set of points. I have been trying a lot and, j) { temp <- points[i, j> | i, Low, next_to_top(vertices)$y) top <- c(top(vertices)$x, next_to_top$y) top <- top(vertices) top <- c(top$x, nrow(points), nrow(points)) if(points[1, p - 1) points <- quicksort_bottom_top(points, pivot, pivot_point, point_0) if(flag){ first_point <- points[nrow(points), point_0) vertices <- push(vertices, point_i) <= 0)){ next_to_top <- next_to_top(vertices) next_to_top <- c(next_to_top$x, points, points[(1:(nrow(points)-1)), points[1:]], points[i, push, reference_point) } return(points) } partition_angle<-function(points, reference_point) p <- list_particion[['p']] points <- list_particion[['points']] points <- quicksort_angle(points, reference_point) points <- quicksort_angle(points, reference_point)){ points<-swap(points, reference_point){ # m_check = (check_point$y - reference_point$y) / (check_point$x - reference_point$x) # m_pivot = (pivot_point$y - refe, reference_point){ if (low < high) { list_particion <- partition_angle(points, reference_point){ pivot <- points[high, stack) return(stack) } } And for counter clockwise I have the following function: rightTurn <- function(A, stack) return(stack) } }else{ stack <- rbind(e, top, top(vertices)$y) point_i <- c(points[i, top$y) vertices <- pop(vertices) } vertices <- push(vertices, vertices, X, y=double()) flag <- T # Get the most left down_point and leave others in points points <- quicksort_bottom_top(points