// Start Code
// must include at least these
#include <stdio.h>
#include <stdlib.h>
typedef struct fpoint_tag
{
float x;
float y;
} fpoint;
int check_point_in_box(fpoint boxLR, fpoint boxLL, fpoint boxUL, fpoint boxUR, fpoint point)
{
float Xmin, Xmax, Ymin, Ymax;
int answer=FALSE;
// Find Min and Maxs
if( boxLR.x < boxLL.x )
{
Xmin = boxLR.x;
Xmax = boxLL.x;
}
else
{
Xmin = boxLL.x;
Xmax = boxLR.x;
}
if( boxLR.y < boxLL.y )
{
Ymin = boxLR.y;
Ymax = boxLL.y;
}
else
{
Ymin = boxLL.y;
Ymax = boxLR.y;
}
// Now compare points X to boxes Xmax and Xmin
if(point.x >= Xmin && point.x <= Xmax)
{
// pass first part now test Y
{
if(point.y >= Ymin && point.y <= Ymax) answer=TRUE;
}
}
return answer;
}
// End Code
|