Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(C++) Write a function to compute determinant and check whether a point is contained in a polygon #include catch/catch.hpp #include ../polygon.hpp TEST_CASE (Advanced polygon tests)
(C++) Write a function to compute determinant and check whether a point is contained in a polygon
#include "catch/catch.hpp" | |
#include "../polygon.hpp" | |
TEST_CASE ("Advanced polygon tests") | |
{ | |
// prepare list of points to create square | |
Point points[] = {Point(0,0), Point(0,2), Point(2,2), Point(2,0)}; | |
Polygon square("Awesome square", points, 4); | |
Polygon empty; | |
SECTION ("Check for point inside polygon with no vertices") | |
{ | |
CHECK(false == empty.Contains(Point(1,1))); | |
} | |
SECTION ("Check for point inside polygon") | |
{ | |
CHECK(true == square.Contains(Point(1,1))); | |
} | |
SECTION ("Check for point outside polygon") | |
{ | |
CHECK(false == square.Contains(Point(-1,-1))); | |
} | |
SECTION ("Edge cases") | |
{ | |
// at a vertex of the square | |
CHECK(true == square.Contains(Point(0,2))); | |
// on an edge of the square | |
CHECK(true == square.Contains(Point(0,1))); | |
} | |
} |
Help me with Contains function. Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started