Hi there, I have a surface of revolution which draws half an egg. It’s working but missing the last like 10 degrees of the egg and I cannot figure out why, have spent so much time trying to figure out. Figured I’d post on the advacned section and see if there are any legends out there.
float vertices[10][16][3]
Latitudes=10;
Longitudes=16;
for(latCount=0; latCount<Latitudes-1; latCount++){ // along z axis
for(longCount=0; longCount<=Longitudes; longCount++){ // x and y
z = sin(Pi*latCount/((float) (Latitudes-1))-Pi/2.0f)/5;
r = cos(Pi*latCount/((float) (Latitudes-1))-Pi/2.0f);
x = (cos(Pi*longCount/(float) Longitudes)*r) /5;
y = (sin(Pi*longCount/(float) Longitudes)*r *2) /5;
vertices[latCount][longCount][0] = x; //x
vertices[latCount][longCount][1] = y; //y
vertices[latCount][longCount][2] = z; //z
z = sin(Pi*(latCount+1)/((float) (Latitudes-1))-Pi/2.0f)/5;
r = cos(Pi*(latCount+1)/((float) (Latitudes-1))-Pi/2.0f);
x = (cos(Pi*longCount/(float) Longitudes)*r) /5;
y = (sin(Pi*longCount/(float) Longitudes)*r *2) /5;
vertices[latCount+1][longCount][0] = x; //x
vertices[latCount+1][longCount][1] = y; //y
vertices[latCount+1][longCount][2] = z; //z
}
}
for(int latCount=0; latCount<Latitudes-1; latCount++){ // along z axis
glBegin(GL_QUAD_STRIP);
for(int longCount=0; longCount<=Longitudes; longCount++){
glVertex3f(vertices[latCount][longCount][0], vertices[latCount][longCount][1], vertices[latCount][longCount][2]);
glVertex3f(vertices[latCount+1][longCount][0], vertices[latCount+1][longCount][1], vertices[latCount+1][longCount][2]);
}
glEnd();
}