Skip to content

Commit

Permalink
fix ameba warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha committed Mar 31, 2024
1 parent cc94a83 commit ec3d2ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/convex_hull/algorithm.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ConvexHull
def initialize(points : Array(Tuple(Int32 | Float32 | Float64, Int32 | Float32 | Float64)))
raise "There must be at least 3 points" if points.size < 3

points = points.uniq.map { |p| Point.new(p[0], p[1]) }.sort!
points = points.uniq.map { |point| Point.new(point[0], point[1]) }.sort!

@convex_hull = convex_hull(points)
end
Expand Down
12 changes: 6 additions & 6 deletions src/convex_hull/graham_scan.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ module ConvexHull
private def convex_hull(points) : Array(Point)
lower = Array(Point).new

points.each do |p|
while lower.size > 1 && cross(lower[-2], lower[-1], p) <= 0
points.each do |point|
while lower.size > 1 && cross(lower[-2], lower[-1], point) <= 0
lower.pop
end

lower.push(p)
lower.push(point)
end

upper = Array(Point).new

points.reverse_each do |p|
while upper.size > 1 && cross(upper[-2], upper[-1], p) <= 0
points.reverse_each do |point|
while upper.size > 1 && cross(upper[-2], upper[-1], point) <= 0
upper.pop
end

upper.push(p)
upper.push(point)
end

hull = lower[...-1] + upper[...-1]
Expand Down

0 comments on commit ec3d2ed

Please sign in to comment.