diff --git a/.gitignore b/.gitignore index 0bbd4a9..6f60b1d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /lib/ /bin/ /.shards/ +/.vscode/ *.dwarf # Libraries don't need dependency lock diff --git a/README.md b/README.md index ddc6fcb..380f9a4 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Crystal implementation of finding the convex hull of a finite set of points in the plane. -Supported method: +Supported algorithms: -- [Gift wrapping algorithm](https://en.wikipedia.org/wiki/Gift_wrapping_algorithm) +- [Jarvis march](https://en.wikipedia.org/wiki/Gift_wrapping_algorithm) - [Graham scan](https://en.wikipedia.org/wiki/Graham_scan) ## Installation @@ -31,8 +31,8 @@ points = [{0, 3}, {2, 2}, {1, 1}, {2, 1}, {3, 0}, {0, 0}, {3, 3}] graham_scan = ConvexHull::GrahamScan.new(points) graham_scan.convex_hull.should eq(expected) -jarvis = ConvexHull::Jarvis.new(points) -jarvis.convex_hull.should eq(expected) +jarvis_march = ConvexHull::JarvisMarch.new(points) +jarvis_march.convex_hull.should eq(expected) ``` ## Contributing diff --git a/spec/convex_hull/jarvis_spec.cr b/spec/convex_hull/jarvis_march_spec.cr similarity index 83% rename from spec/convex_hull/jarvis_spec.cr rename to spec/convex_hull/jarvis_march_spec.cr index 90b47f7..ac5b362 100644 --- a/spec/convex_hull/jarvis_spec.cr +++ b/spec/convex_hull/jarvis_march_spec.cr @@ -1,6 +1,6 @@ require "../spec_helper" -describe ConvexHull::Jarvis do +describe ConvexHull::JarvisMarch do it "integers" do points = [ {0, 3}, @@ -16,7 +16,7 @@ describe ConvexHull::Jarvis do {0, 3}, {0, 0}, {3, 0}, {3, 3}, ].map { |point| ConvexHull::Point.new(point[0], point[1]) } - jarvis = ConvexHull::Jarvis.new(points) + jarvis = ConvexHull::JarvisMarch.new(points) jarvis.convex_hull.should eq(expected) end @@ -35,7 +35,7 @@ describe ConvexHull::Jarvis do {0.0, 3.0}, {0.0, 0.0}, {3.0, 0.0}, {3.0, 3.0}, ].map { |point| ConvexHull::Point.new(point[0], point[1]) } - jarvis = ConvexHull::Jarvis.new(points) + jarvis = ConvexHull::JarvisMarch.new(points) jarvis.convex_hull.should eq(expected) end @@ -46,7 +46,7 @@ describe ConvexHull::Jarvis do {-1, 1}, {-1, -1}, {1, -1}, {1, 1}, ].map { |point| ConvexHull::Point.new(point[0], point[1]) } - jarvis = ConvexHull::Jarvis.new(points) + jarvis = ConvexHull::JarvisMarch.new(points) jarvis.convex_hull.should eq(expected) end @@ -55,7 +55,7 @@ describe ConvexHull::Jarvis do expected = [] of ConvexHull::Point - jarvis = ConvexHull::Jarvis.new(points) + jarvis = ConvexHull::JarvisMarch.new(points) jarvis.convex_hull.should eq(expected) end end diff --git a/src/convex_hull.cr b/src/convex_hull.cr index ee3a2a0..679912e 100644 --- a/src/convex_hull.cr +++ b/src/convex_hull.cr @@ -1,5 +1,5 @@ require "./convex_hull/point" -require "./convex_hull/jarvis" +require "./convex_hull/jarvis_march" require "./convex_hull/graham_scan" module ConvexHull diff --git a/src/convex_hull/jarvis.cr b/src/convex_hull/jarvis_march.cr similarity index 98% rename from src/convex_hull/jarvis.cr rename to src/convex_hull/jarvis_march.cr index 3b54170..e3b3d1a 100644 --- a/src/convex_hull/jarvis.cr +++ b/src/convex_hull/jarvis_march.cr @@ -1,5 +1,5 @@ module ConvexHull - class Jarvis + class JarvisMarch getter points : Array(Point) def initialize(points : Array(Tuple(Number, Number)))