Help with deriving curved normal vector

Hey all,

So i am generating a half sphere that slants upwards.

I use the following code

for (ph=0;ph<90;ph+=d)
for (th=180;th<=360;th+=180)

      glVertex3d(Sin(th)*Cos(ph) + 0.1, Sin(ph) + 0.1,  Cos(th)*Cos(ph));

	  glVertex3d(1.1 * Sin(th)*Cos(ph) + 0.1, 1.2 * Sin(ph) + 0.16, Cos(th)*Cos(ph) * 1.4);

	  glVertex3d(Sin(th)*Cos(ph + d) + 0.1 , Sin(ph + d) + 0.1 , Cos(th)*Cos(ph + d));  
      glVertex3d(1.1 * Sin(th)*Cos(ph + d) + 0.1 , 1.2 * Sin(ph + d) + 0.16 , Cos(th)*Cos(ph + d) * 1.4);   


How would i derive proper normal vectors for the vertices of this shape such that it would make the surface appear curved? I understand how it works for a normal sphere but not sure how it works in my curved situation


Basically, each of your verticies has position given by (each of the quad verts is differnce, but per vert use the function that is appropriate.

F(ph, th) = (Sin(th)*Cos(ph) + 0.1, Sin(ph) + 0.1, Cos(th)*Cos(ph))

To find the normal, use Maple to find

d/dph F(ph, th) and d/dth F(ph,th) (these will be vectors);

Call these vectors u and v. These are tangent to your surface, in the direction of change represented by ph and th, respectively. The normal is orthogonal to the plane that these vector span, so the easy way to find that is:

u x v (cross product). But that is not unit length, so take
N = u x v / |u x v|.

Again, probably easiest to do using Maple, but could be done numerically as well.