From d21f56e8363c10e956bf015bd33e78a408861217 Mon Sep 17 00:00:00 2001 From: rishabh-997 Date: Mon, 17 Aug 2020 02:36:30 +0530 Subject: [PATCH] Added Jarvi algo to find convex hull --- geometry/jarvis_algorithm.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/geometry/jarvis_algorithm.cpp b/geometry/jarvis_algorithm.cpp index 85716e2f..d471a52a 100644 --- a/geometry/jarvis_algorithm.cpp +++ b/geometry/jarvis_algorithm.cpp @@ -36,19 +36,19 @@ * @brief Geometry algorithms */ namespace geometry { - /** - * Structure defining the x and y co-ordinates of the given - * point in space - */ - struct Point { - int x, y; - }; - /** * @namespace jarvis * @brief Functions for [Jarvis’s](https://en.wikipedia.org/wiki/Gift_wrapping_algorithm) algorithm */ namespace jarvis { + /** + * Structure defining the x and y co-ordinates of the given + * point in space + */ + struct Point { + int x, y; + }; + /** * Class which can be called from main and is globally available * throughout the code @@ -148,7 +148,7 @@ namespace geometry { * @returns void */ static void test() { - std::vector points = {{0, 3}, + std::vector points = {{0, 3}, {2, 2}, {1, 1}, {2, 1}, @@ -158,10 +158,10 @@ static void test() { }; int n = points.size(); geometry::jarvis::Convexhull hull(points, n); - std::vector actualPoint; + std::vector actualPoint; actualPoint = hull.getConvexHull(); - std::vector expectedPoint = {{0, 3}, + std::vector expectedPoint = {{0, 3}, {0, 0}, {3, 0}, {3, 3}}; -- GitLab