1
I need to create a function that checks if a point is inside a polygon. For this, I researched on the Internet some solutions that can help me. I found one that seems to be of great help, but in one of the functions necessary for the functioning of the main function, there was an error. The function is as follows:
// A função checa se o ponto Q está no segmento PR.
bool NoSegmento(Ponto P, Ponto Q, Ponto R)
{
if (Q.x <= max(P.x, R.x) && Q.x >= min(P.x, R.x) && Q.y <= max(P.y, R.y)
&& Q.y >= min(P.y, R.y))
return true;
return false;
}
However, when compiling, I get some warnings and errors, for example:
implicit declaration of function 'max' [-Wimplicit-function-declaration]|
implicit declaration of function 'min' [-Wimplicit-function-declaration]|
undefined reference to `max'|
undefined reference to `min'|
I wonder if the MAX and MIN functions are functions of some library and what is the purpose of sweating bool type for the function.
I’m talking about point-to-polygon belonging in that reply.
– Jefferson Quesado
About the
max
/min
, that answer says you need to declare these functions/macros.– Jefferson Quesado
And its function
NoSegmento
checks whether the pointQ
is within the rectangle defined by the pointsP
andR
, which therefore does not fit into general polygon membership (only rectangles parallel to the axes). It also doesn’t detect if it really belongs to the segment, so the comment is also misleading– Jefferson Quesado