Please,someone help me.i need help in Opengl and C++.

Hi,i am new begineer. I have assignment in convex hull.
I have to read data from text file to find convex hull.
Below are my code to read data. But i don't know how to find convex hull by using quick hull algorithm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "graphics.h"

#include <iostream>
#include <cmath>
void CPrimitive::LoadObject(char *file, CPrimitive *obj = new CPrimitive)
{
	FILE*fp = fopen(file,"r");

	fscanf(fp,"%d",&TempNum);
	obj->NumTri = TempNum;

	for(i=0;i<obj->NumTri;i++)
	{
		fscanf(fp,"%f %f %f", &A[i].x,&A[i].y,&A[i].z);
		fscanf(fp,"%f %f %f", &B[i].x,&B[i].y,&B[i].z);
		fscanf(fp,"%f %f %f", &C[i].x,&C[i].y,&C[i].z);
	}

	fclose(fp);
}

void CPrimitive::Draw(CPrimitive *obj=new CPrimitive)
{
	int j=0;
	glPushMatrix();

			glBegin(GL_POINTS);

				for(int j=0;j<obj->NumTri;j++)
				{
					glVertex3fv(&A[j].x);
					glVertex3fv(&B[j].x);
					glVertex3fv(&C[j].x);
				}

			glEnd();
	glPopMatrix();
}
Last edited on
convex hull in 2D is quite easy, in 3 dimensions and higher it is hard.

I have O'Rourkes book (Computational Geometry in C)
This is "the most complex implementation in the book"

Are you sure you are "new begineer" with this assignment?

This site gives an overview of the algorithm
http://www.cse.unsw.edu.au/~lambert/java/3d/quickhull.html




Topic archived. No new replies allowed.