Example #1
0
/**
 * Main function
 *
 * Takes user input and finds/prints the convex hull using
 * jarvis algorithm.
 *
 * @param argc the number of arguments
 * @param argv array of arguments
 * @returns int the error code; 0 if no error
 */
int main( int argc, const char* argv[] ) {
	struct Point points[MAX_POINTS];
	int numPoints = readPoints( points );
	
	struct Point results[numPoints];
	int numResults = jarvis( points, numPoints, results );

	printf("Convex hull:\n");
	displayPoints( results, numResults );
}
Example #2
0
int main(void)
{
struct Point jarvisPoints[MAX_POINTS];
int numberOfjarvisPoints=readPoints(jarvisPoints);

if(numberOfjarvisPoints>0)
{
displayPoints(jarvisPoints,numberOfjarvisPoints);
struct Point convexHullSet[numberOfjarvisPoints];
int numberOfConvexPoints=jarvis(jarvisPoints,convexHullSet,numberOfjarvisPoints);
displayConvexPoints(convexHullSet,numberOfConvexPoints);
}	

}
void init_links(Dllist *dll, int const LNK)
{
	switch (LNK)
	{
		case LEX: 
			copy_order(dll, STD, LEX);
			sort(dll->root, dll->length[LEX], dll, LEX);
			break;

		case POL: 
			if (dll->up2date[LEX])
			{
				copy_order(dll, LEX, POL);
				sort(dll->root->links[POL][FWD], dll->length[POL]-1, dll, POL);
			}
			else 
			{
				init_links(dll, LEX);
				init_links(dll, POL);
			}
			break;

		case GRA:
			if (dll->up2date[POL])
				graham(dll); 
			else
			{
				init_links(dll, POL);
				init_links(dll, GRA);
			}
			break;

		case JAR:
			if (dll->up2date[POL])
				jarvis(dll); 
			else
			{
				init_links(dll, POL);
				init_links(dll, JAR);
			}
			break;

		default: printf("Error in init_links function\n");
			break;
	}
}