提交 d21f56e8 编写于 作者: R rishabh-997

Added Jarvi algo to find convex hull

上级 bfed4c8f
...@@ -36,19 +36,19 @@ ...@@ -36,19 +36,19 @@
* @brief Geometry algorithms * @brief Geometry algorithms
*/ */
namespace geometry { namespace geometry {
/**
* Structure defining the x and y co-ordinates of the given
* point in space
*/
struct Point {
int x, y;
};
/** /**
* @namespace jarvis * @namespace jarvis
* @brief Functions for [Jarvis’s](https://en.wikipedia.org/wiki/Gift_wrapping_algorithm) algorithm * @brief Functions for [Jarvis’s](https://en.wikipedia.org/wiki/Gift_wrapping_algorithm) algorithm
*/ */
namespace jarvis { 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 * Class which can be called from main and is globally available
* throughout the code * throughout the code
...@@ -148,7 +148,7 @@ namespace geometry { ...@@ -148,7 +148,7 @@ namespace geometry {
* @returns void * @returns void
*/ */
static void test() { static void test() {
std::vector<geometry::Point> points = {{0, 3}, std::vector<geometry::jarvis::Point> points = {{0, 3},
{2, 2}, {2, 2},
{1, 1}, {1, 1},
{2, 1}, {2, 1},
...@@ -158,10 +158,10 @@ static void test() { ...@@ -158,10 +158,10 @@ static void test() {
}; };
int n = points.size(); int n = points.size();
geometry::jarvis::Convexhull hull(points, n); geometry::jarvis::Convexhull hull(points, n);
std::vector<geometry::Point> actualPoint; std::vector<geometry::jarvis::Point> actualPoint;
actualPoint = hull.getConvexHull(); actualPoint = hull.getConvexHull();
std::vector<geometry::Point> expectedPoint = {{0, 3}, std::vector<geometry::jarvis::Point> expectedPoint = {{0, 3},
{0, 0}, {0, 0},
{3, 0}, {3, 0},
{3, 3}}; {3, 3}};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册