half sphere

hi, can anyone give some idea how to model half a sphere? I will just have half of it and it will look like a sort of shell…
ok, thanks.

This is more of a Maths-related question. Simply look at how a sphere is drawn and restrict one of the two parameters so that you only get half a sphere. I’ll move your topic in the correct section.

Hello Magnuse,

I’ve written a little opengl function for you, which draws a half sphere (without normals):

 /*scalex - scaling of sphere around x-axis
   scaley - scaling of sphere around y-axis
   r - radius of sphere
  */
 void drawHalfSphere(int scaley, int scalex, GLfloat r) {
   int i, j;
   GLfloat v[scalex*scaley][3];

   for (i=0; i<scalex; ++i) {
     for (j=0; j<scaley; ++j) {
       v[i*scaley+j][0]=r*cos(j*2*M_PI/scaley)*cos(i*M_PI/(2*scalex));
       v[i*scaley+j][1]=r*sin(i*M_PI/(2*scalex));
       v[i*scaley+j][2]=r*sin(j*2*M_PI/scaley)*cos(i*M_PI/(2*scalex));
     }
   }

   glBegin(GL_QUADS);
     for (i=0; i<scalex-1; ++i) {
       for (j=0; j<scaley; ++j) {
         glVertex3fv(v[i*scaley+j]);
         glVertex3fv(v[i*scaley+(j+1)%scaley]);
         glVertex3fv(v[(i+1)*scaley+(j+1)%scaley]);
         glVertex3fv(v[(i+1)*scaley+j]);
       }
     }
   glEnd();
 }

You can give as parameters the scaling around the y-axis, the scaling above the x-axis and the radius. I hope it is correct. :rolleyes:

drawHalfSphere(24, 24, 2) would look like

Sumpfratte