i'm trying to implement a brute force approach to the convex hull but i'm having issues. I have the following:
void convexHull(point *array)
{
double a,b,c,checkVal,found;
for (int i = 0; i < 8; i++)
{
for (int j = i+1; j < 8; j++)
{
found = 0;
a = array[j].y - array[i].y;
b = array[j].x - array[i].x;
c = (array[i].x * array[j].y) - (array[i].y * array[j].x);
for (int k = 0; k < 8;k++)
{
checkVal = (a * array[k].x) + (b * array[k].y) - c;
if (checkVal == 0)
{
found = 1;
break;
}
}
if (found == 1)
{
printf("%lf %lf\n",nums[i].x,nums[j].y);
}
}
}
}
I have 8 points which i'm reading in which is why the indexes end at 8. I have been trying to find examples online but can't find much to help me. Once I calculate checkVal
I am pretty sure I have to check if it equals 0 or not and break the loop, and print the points at num[i] and num[j] but I can't seem to get it working. How do I check the condition to print the set of points?